|
|
Subject:
Haskell question
Category: Computers > Programming Asked by: exitmusic_-ga List Price: $15.00 |
Posted:
19 Apr 2005 05:13 PDT
Expires: 19 May 2005 05:13 PDT Question ID: 511271 |
I want to know an elegant way to convert from coordinates (any amount of dimensions) using a list of lists, to coordinates using a list of tuples (eg pairs). I'm using Floats. for example, 3 points in 2 dimensions from [[1,2],[4,5],[7,8]] to [(1,2),(4,5),(7,8)] or 2 points in 3 dimensions from [[1,2,3],[4,5,6]] to [(1,2,3),(4,5,6)] So the function type would probably be [[Float]] -> [(Float)] Thanks |
|
There is no answer at this time. |
|
Subject:
Re: Haskell question
From: dmpots-ga on 22 Apr 2005 03:26 PDT |
I think that the function you want may be impossible. The problem is that there is no type that is a tuple of arbitrary length. This makes it impossible to define the function you want. Check out the "Gentle Introduction to Haskell" (http://www.haskell.org/tutorial/goodies.html) for more details. In particular the section describing tuples states: --- At this point the reader should note carefully the differences between tuples and lists, which the above definitions make abundantly clear. In particular, note the recursive nature of the list type whose elements are homogeneous and of arbitrary length, and the non-recursive nature of a (particular) tuple type whose elements are heterogeneous and of fixed length. --- You could rather easily define a function that could take a list of lists into a tuple of fixed size. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |