From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id B000FBC69 for ; Fri, 9 Feb 2007 22:32:02 +0100 (CET) Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l19LW1Hm024527 for ; Fri, 9 Feb 2007 22:32:02 +0100 Received: from [192.168.0.104] (12-208-241-105.client.mchsi.com[12.208.241.105]) by sccmmhc91.asp.att.net (sccmmhc91) with SMTP id <20070209213200m91003k5phe>; Fri, 9 Feb 2007 21:32:00 +0000 Mime-Version: 1.0 (Apple Message framework v752.3) Content-Transfer-Encoding: 7bit Message-Id: <1197BD5D-1373-4876-8DC1-FED84797E4A6@valdosta.edu> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed To: caml-list@yquem.inria.fr From: Jonathan Bryant Subject: Amb Date: Fri, 9 Feb 2007 16:31:38 -0500 X-Mailer: Apple Mail (2.752.3) X-Miltered: at concorde with ID 45CCE851.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; node:01 ocaml:01 val:01 amb:98 amb:98 16.:98 chap:98 rec:01 ccs:01 exception:01 neu:02 implemented:02 match:02 seems:03 seems:03 All, I'm having to learn Scheme for a class, and I ran across a simple but really useful predicate: amb. More info on this can be found here: http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z- H-16.html#node_chap_14 Since OCaml doesn't seem to have this, I implemented it: exception Amb let rec amb l = match l with | [] -> raise Amb | h::t -> try h () with Amb -> amb t let amb l = try Some (amb l) with Amb -> None (* val amb : (unit -> 'a) list -> 'a option *) I know things are not added to the standard library lightly, but it seems that this one function doesn't really need it's own library and could be easily added somewhere. It just seems that this would be a small but convenient addition. --Jonathan Bryant