Hi,
Thanks for that, it's exactly what I needed.
Just one question though.
In the function used for the outer mapping,
fun {$ A} B in A = B#_ B end}
(and the sort function for that matter!)
It was my understanding that A would be bound to each value in the list
being mapped as each is processed.
How then can A=B#_ within the function , surely this is binding A to
another value?
Obviously it works and I can understand the algorithm, but from what
I've been taught, A can't be bound to a value twice and therefore there
must be a fault somewhere in my understanding of binding/syntax.
If someone could offer a short explanation I would be grateful.
Regards
Mark
Kari Pahula wrote:
Sounds like you're trying to implement a shuffling algorithm. Quickly
adapted from a piece of code that I had lying around:
Is = {List.map {List.sort {List.map [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
fun {$ A} A#{OS.rand} end}
fun {$ A B} M N in A = _#N B = _#M N>M end}
fun {$ A} B in A = B#_ B end}
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users
--
Mark Richardson
Final year undergraduate
University of Teesside
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users