From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q0KALcBp029303 for ; Fri, 20 Jan 2012 11:21:38 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArgBALA/GU/RVdY2kGdsb2JhbABDnUGQMggiAQEBAQkJDQcUBCGBcgEBAQQSAhMZARsSCwEDDAYFCw0NISEBAREBBQEKEgYTEhCHYpt+Cotqgm+Ecz+IcQIFC4NziCgEiDyMXIsBgw89hB8 X-IronPort-AV: E=Sophos;i="4.71,541,1320620400"; d="scan'208";a="140703157" Received: from mail-bk0-f54.google.com ([209.85.214.54]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 20 Jan 2012 11:21:35 +0100 Received: by mail-bk0-f54.google.com with SMTP id c12so552875bkb.27 for ; Fri, 20 Jan 2012 02:21:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=ozPVudvt1QxfaIxfUaypfO0s6ZMvBB0XenCTfzct9+g=; b=N0e93y+FVH3XBkd3PCjMXKYuv181JHr3XALjkTg4AMuSXpIsRM7+u9piOk71yxfR9L dZnAbC+h9AjRrTb6/EQU2nursbyRa/uLY4LsliJ5fWuetEqK+vKGtNi5sDuwLP9TPmUS W71DmOzYc6s2AnDQU+P0YJ+Kd6qYGxlYSYkSk= MIME-Version: 1.0 Received: by 10.204.145.82 with SMTP id c18mr8373293bkv.121.1327054895469; Fri, 20 Jan 2012 02:21:35 -0800 (PST) Received: by 10.204.171.79 with HTTP; Fri, 20 Jan 2012 02:21:35 -0800 (PST) In-Reply-To: References: <4F192B4E.9000406@163.com> Date: Fri, 20 Jan 2012 02:21:35 -0800 Message-ID: From: Martin DeMello To: Valentin ROBERT Cc: Lin , caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id q0KALcBp029303 Subject: Re: [Caml-list] is there a more concise way to write this? I ended up using let (>>?) x y = if x then [y] else [] in let a = (out >>? ...) @ (value >>? ...) which had the advantage that it let me inline the definitions of o and v while keeping things readable. martin On Fri, Jan 20, 2012 at 1:08 AM, Valentin ROBERT wrote: > Rather (in this case): > > let a = List.map fst (List.filter (fun x -> snd x) [(out, o); (value, v)]) > > That seems reasonable. > > > On Fri, Jan 20, 2012 at 09:52, Lin wrote: >> >> What about: >> >> let a = List.filter (fun x -> x)  [out; value] >> >> Lin >> >> >> >> On 01/20/2012 02:38 PM, Martin DeMello wrote: >>> >>>       let a = match (out, value) with >>>         (true, true)  ->  [o; v] >>>       | (false, true) ->  [v] >>>       | (true, false) ->  [o] >>>       | (false, false) ->  [] >>> >> >> >> >> -- >> Caml-list mailing list.  Subscription management and archives: >> https://sympa-roc.inria.fr/wws/info/caml-list >> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >> Bug reports: http://caml.inria.fr/bin/caml-bugs >> >