![]() |
|
|
|
|
1
6th October 01:59
External User
Posts: 1
|
To create a tuple containing the numbers 1 and 2 in an ML (e.g. SML, OCaml),
you just do: (1, 2) The "arity" of a tuple cannot be extended in an ML, by definition. You have two options, if you know at compile time how many times the tuple will be extended then you can nest tuples: (1, 2) ((1, 2), 3) (((1, 2), 3), 4) and so forth. If you do not know, then you must use a list. If the data in your tuples is of different types then you will need to unify the types in a single variant type and then have a list with all elements of that variant type. You will find ML much more concise than Java for this kind of work. ML is also likely to be much faster. Yes, if naming the fields is productive, then records are a good alternative. Overall, ML variants are all excellent at handling complicated data structures. As you are likely to be doing this kind of work, you will almost certainly be much more productive in an ML than in C++/Java/C#. -- Dr Jon D Harrop, Flying Frog Consultancy http://www.ffconsultancy.com |
|
|
|