caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Christophe Raffalli <christophe.raffalli@univ-savoie.fr>
To: David Thomas <david_hd@yahoo.com>, caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Puzzle
Date: Fri, 26 Aug 2005 22:27:19 +0200	[thread overview]
Message-ID: <430F7B27.4040208@univ-savoie.fr> (raw)
In-Reply-To: <20050826192117.98447.qmail@web30503.mail.mud.yahoo.com>

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


  reply	other threads:[~2005-08-26 20:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-26 19:21 Puzzle David Thomas
2005-08-26 20:27 ` Christophe Raffalli [this message]
2005-08-27 11:53 ` [Caml-list] Puzzle Berke Durak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=430F7B27.4040208@univ-savoie.fr \
    --to=christophe.raffalli@univ-savoie.fr \
    --cc=caml-list@inria.fr \
    --cc=david_hd@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).