[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Christophe Raffalli <christophe.raffalli@u...> |
| Subject: | Re: [Caml-list] Puzzle |
David Thomas a écrit : > I have three lists that I would like to have sorted > through user interaction. I can, of course, say > "List.sort ask list" for each list. What if, however, > rather than sorting each list in turn, I wanted the > questions to be interleaved, either randomly or in a > prespecified sequence? Is it possible to do this > without reimplementing sort? I easily could, but it > seems more fun without... > This should work (I did not test ...), But the input output may not work, One should have a separate thread to interact with the user and the sorting thread sending request to this thread ... but you may assume all this is done by the ask function. let tsort l = let r = ref [] in let g l = r := List.sort ask l in let th = Thread.create g l in th, r let result = let th1, r1 = tsort l1 in let th2, r2 = tsort l2 in let th3, r3 = tsort l3 in Thread.join th1; Thread.join th2; Thread.join th3; !r1, !r2, !r3 > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs