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 q0K6lRFV020040 for ; Fri, 20 Jan 2012 07:47:27 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aj4DAEwNGU/RVdW0k2dsb2JhbABDhQSYPYgzAYd+CCIBAQEBCQkLCRQEIYFyAQEBAwESAg8EGQEbEgsBAwELBgMCBAEGGh0CAh8CAQERAQUBChIGEwgKEIdaCJtjCosiSIJvhG0/iHECBQuDc4cSgRYEglyJVU2IGosBgw89g38 X-IronPort-AV: E=Sophos;i="4.71,540,1320620400"; d="scan'208";a="140666585" Received: from mail-yx0-f180.google.com ([209.85.213.180]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 20 Jan 2012 07:47:21 +0100 Received: by yenl2 with SMTP id l2so127751yen.39 for ; Thu, 19 Jan 2012 22:47:20 -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=Gh/gukFJnbDsW2hMLs1Pc0OCwzy+xUUF3cS1cCx3rgY=; b=pMvW9+RLjptClgK6QUAFSMNRts3xsIxI6r4dNglnzKxWij63CM0JoWSPpljaS/RuXq qLvtzVtDoe+Ez6c3PO6WwKjQE/TE9LdPbbFdq3bS7ai5M9PWEaRqw98l38lewzWZqwQH w7Pu5CuHR7Q8Ys3icvLd3R9AwxKIYNL3ySJ0Y= Received: by 10.236.153.226 with SMTP id f62mr43477039yhk.62.1327042039173; Thu, 19 Jan 2012 22:47:19 -0800 (PST) MIME-Version: 1.0 Received: by 10.236.66.98 with HTTP; Thu, 19 Jan 2012 22:46:58 -0800 (PST) In-Reply-To: References: From: Valentin ROBERT Date: Fri, 20 Jan 2012 07:46:58 +0100 Message-ID: To: Martin DeMello Cc: OCaml List Content-Type: multipart/alternative; boundary=20cf303a2bb958d3b404b6f00d73 Subject: Re: [Caml-list] is there a more concise way to write this? --20cf303a2bb958d3b404b6f00d73 Content-Type: text/plain; charset=UTF-8 I guess you can write it like: let a = (if out then [o] else []) @ (if value then [v] else []) But it's not particularly more pleasant to the eye. Still it reduces the exponential explosion of the code, at a small additional cost (the @), I believe. On Fri, Jan 20, 2012 at 07:38, 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 > > --20cf303a2bb958d3b404b6f00d73 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I guess you can write it like:

let a =3D (if out then [o= ] else []) @ (if value then [v] else [])

But it= 9;s not=C2=A0particularly more pleasant to the eye.
Still it redu= ces the exponential explosion of the code, at a small additional cost (the = @), I believe.

On Fri, Jan 20, 2012 at 07:38, Martin DeMell= o <martinde= mello@gmail.com> wrote:
=C2=A0 =C2=A0 =C2=A0let a =3D match (out, value) with
=C2=A0 =C2=A0 =C2=A0 =C2=A0(true, true) =C2=A0-> [o; v]
=C2=A0 =C2=A0 =C2=A0| (false, true) -> [v]
=C2=A0 =C2=A0 =C2=A0| (true, false) -> [o]
=C2=A0 =C2=A0 =C2=A0| (false, false) -> []

--
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
Bug reports: http://caml.inria.fr/bin/caml-bugs


--20cf303a2bb958d3b404b6f00d73--