From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q0K99Knc025262 for ; Fri, 20 Jan 2012 10:09:20 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AskBAKotGU/RVaG2kGdsb2JhbABDhQSYPYgzAYd+CCIBAQEBCQkNBxQEIYFyAQEBAwESAg8EGQEbEgsBAwELBgMCBAcNDR0CAh8DAREBBQEKEgYTEhCHWgibYgqLIkiCb4R2P4hxAgULg3OHEoEWBIJciVVNiBqOED2CUIEv X-IronPort-AV: E=Sophos;i="4.71,541,1320620400"; d="scan'208";a="128191965" Received: from mail-gx0-f182.google.com ([209.85.161.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 20 Jan 2012 10:09:14 +0100 Received: by ggki1 with SMTP id i1so179068ggk.27 for ; Fri, 20 Jan 2012 01:09:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=keC1Oq08KrwofYPkOz0biNFmaiJR5XUMDG5vkjGtdgA=; b=NZua00tvonhuo14r7juTKm17cnKV6StRsDTb96LHnJZw/aBthCPmgSNmKC/5ldTwy/ ZRyUFtQOEYZOzcDQInXExH2Urgk+N7a2Dn5JtqotPkt40/Tklzxb4D0DzHKfPzqo/mpp RkaVESwxu5C/Nf/OeZQQk5SJ4w5dRcerGPkVs= Received: by 10.100.81.4 with SMTP id e4mr3555231anb.26.1327050553245; Fri, 20 Jan 2012 01:09:13 -0800 (PST) MIME-Version: 1.0 Received: by 10.236.66.98 with HTTP; Fri, 20 Jan 2012 01:08:52 -0800 (PST) In-Reply-To: <4F192B4E.9000406@163.com> References: <4F192B4E.9000406@163.com> From: Valentin ROBERT Date: Fri, 20 Jan 2012 10:08:52 +0100 Message-ID: To: Lin Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=005045017040d341a104b6f20863 Subject: Re: [Caml-list] is there a more concise way to write this? --005045017040d341a104b6f20863 Content-Type: text/plain; charset=UTF-8 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 > > --005045017040d341a104b6f20863 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Rather (in this case):

let a =3D List.map fst (List.filt= er (fun x -> snd x) [(out, o); (value, v)])

Tha= t seems reasonable.

On Fri, Jan 20, 2012 = at 09:52, Lin <mys= nowls@163.com> wrote:
What about:

let a =3D List.filter (fun x -> x) =C2=A0[out; value]

Lin



On 01/20/2012 02:38 PM, Martin DeMello wrote:
=C2=A0 =C2=A0 =C2=A0 let a =3D match (out, value) with
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (true, true) =C2=A0-> =C2=A0[o; v]
=C2=A0 =C2=A0 =C2=A0 | (false, true) -> =C2=A0[v]
=C2=A0 =C2=A0 =C2=A0 | (true, false) -> =C2=A0[o]
=C2=A0 =C2=A0 =C2=A0 | (false, false) -> =C2=A0[]




--
Caml-list mailing list. =C2=A0Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners<= /a>
Bug reports:
http://caml.inria.fr/bin/caml-bugs


--005045017040d341a104b6f20863--