From: Brian Hurt <bhurt@spnz.org>
To: Jon Harrop <jon@ffconsultancy.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Amb
Date: Fri, 9 Feb 2007 20:12:45 -0500 (EST) [thread overview]
Message-ID: <Pine.LNX.4.64.0702092012100.19734@localhost> (raw)
In-Reply-To: <200702100001.55094.jon@ffconsultancy.com>
On Sat, 10 Feb 2007, Jon Harrop wrote:
> On Friday 09 February 2007 21:55, Brian Hurt wrote:
>> let rec amb = function
>>
>> | [] -> None
>> | h :: t ->
>>
>> let r =
>> try
>> Some(h ())
>> with
>>
>> | _ -> None
>>
>> in
>> match r with
>>
>> | None -> amb t
>> | Some(_) as e -> e
>>
>> As a slightly better implementation.
>
> I think you're trying to box the returned value in order to evade non-tail
> recursion but the OPs function was actually already tail recursive because
> the recursive call to "amb" occurs outside the try..with.
He was doing the boxing on the return as well. And note, in the above
code I only box once.
Brian
prev parent reply other threads:[~2007-02-10 1:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-09 21:31 Amb Jonathan Bryant
2007-02-09 21:55 ` [Caml-list] Amb Brian Hurt
2007-02-09 22:12 ` Andrej Bauer
2007-02-09 22:42 ` Tom
2007-02-10 0:03 ` Jon Harrop
2007-02-10 0:01 ` Jon Harrop
2007-02-10 1:12 ` Brian Hurt [this message]
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=Pine.LNX.4.64.0702092012100.19734@localhost \
--to=bhurt@spnz.org \
--cc=caml-list@yquem.inria.fr \
--cc=jon@ffconsultancy.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