-----Alexandre Campos wrote: -----
>That's exactly what I need! ... so, I tried to extract the values of the
> set but I don't know the type of the result set variable, e.g.
>I require to assign the element "2": first element of the second "row"
in:
Use the function 'part'. Here is an example:
(%i1) load(nset)$
(%i2) a : integer_partitions(4);
(%o2) {[1,1,1,1],[2,1,1],[2,2],[3,1],[4]}
(%i3) part(a,1);
(%o3) [1,1,1,1]
(%i4) part(a,2);
(%o4) [2,1,1]
Alternatively, convert the set to a list and and use [] to extract
list members. For example:
(%i5) b : listify(a);
(%o5) [[1,1,1,1],[2,1,1],[2,2],[3,1],[4]]
(%i6) b[1];
(%o6) [1,1,1,1]
(%i7) b[2];
(%o7) [2,1,1]
For large sets, the second method might be faster
(%i2) a : integer_partitions(58)$
(%i3) cardinality(a);
(%o3) 715220
(%i4) showtime : all;
Evaluation took 0.00 seconds (0.00 elapsed)
(%o4) ALL
(%i5) part(a,700000);
Evaluation took 2.05 seconds (2.05 elapsed)
(%o5) [30,14,4,2,2,2,2,2]
(%i6) b : listify(a)$
Evaluation took 0.00 seconds (0.00 elapsed)
(%i7) b[700000];
Evaluation took 0.53 seconds (0.53 elapsed)
(%o7) [30,14,4,2,2,2,2,2]
Barton