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 q0K9HeMZ025847 for ; Fri, 20 Jan 2012 10:17:40 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArQOAC4wGU97fTKEY2dsb2JhbABDgw2Bd5g9kDoYFwoKBxUmgXIBAQUjBBkBASwMDwkCGAkEEggDAgIJAwIBAgEzARETBgIBAQ4Jh2mmJmqDNwGOJQeDfoUMggaBFoJghV6ETk2NGI0D X-IronPort-AV: E=Sophos;i="4.71,541,1320620400"; d="scan'208,217";a="128193388" Received: from m50-132.163.com ([123.125.50.132]) by mail4-smtp-sop.national.inria.fr with ESMTP; 20 Jan 2012 10:17:33 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Received:Message-ID:Date:From:User-Agent: MIME-Version:To:Subject:References:In-Reply-To:Content-Type; bh=ErqayndYxLzLxWb0VackZd3jyl4KIJn2Cbve+6ywkzw=; b=KdrP894A9lGQQ LZZ/R3+BBDcIoTCpUGtOK1WrUkXJV0N4tE7J38+nfLw03hS/tVdycQnYxZSrvfag fsd1qGAR3B3rAT9cRpyOOl2p1M8LoTwf2bQrW/RT4jgQQ8giNbNxLJnYy6RVdupC GD6NvxRz+wj9/5gQp8JOVbTqPWL0dM= Received: from [192.168.1.102] (unknown [182.146.31.7]) by smtp2 (Coremail) with SMTP id DNGowEApR1giMRlPXT81BQ--.15194S2; Fri, 20 Jan 2012 17:17:27 +0800 (CST) Message-ID: <4F19318F.8010704@163.com> Date: Fri, 20 Jan 2012 17:19:11 +0800 From: Lin User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110808 Thunderbird/3.1.10 MIME-Version: 1.0 To: caml-list@inria.fr References: <4F192B4E.9000406@163.com> In-Reply-To: Content-Type: multipart/alternative; boundary="------------000809000502070107060909" X-CM-TRANSID: DNGowEApR1giMRlPXT81BQ--.15194S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7XF47Kr1fCw45AF13ZryUGFg_yoWfurc_WF Wvgwn7Z398A3Z8Ga48trsIg3y7CryUCr4Sy3ZI9r13tF1Fq3Z8Wrs2kFnxZFyxtrnxZFnr Z3s0gFW2ka9rKjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU0HxR3UUUUU== X-CM-SenderInfo: xp1v00xzovqiywtou0bp/1tbiOQg7bkjh+6qICwAAsf Subject: Re: [Caml-list] is there a more concise way to write this? This is a multi-part message in MIME format. --------------000809000502070107060909 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Oh sorry I assumed `o' is short for `out' and `v' for `value', which seems not the case. By the way, in your solution `fst' and `snd' should be exchanged, i.e. let a = List.map snd (List.filter (fun x -> fst x) [(out, o); (value, v)]) On 01/20/2012 05:08 PM, 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 > > --------------000809000502070107060909 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit Oh sorry I assumed `o' is short for `out' and `v' for `value', which seems not the case.

By the way, in your solution  `fst' and `snd' should be exchanged, i.e.

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


On 01/20/2012 05:08 PM, 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 <mysnowls@163.com> 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



--------------000809000502070107060909--