From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id D09317EEF6 for ; Wed, 3 Jun 2015 18:59:01 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of john@coherentgraphics.co.uk) identity=pra; client-ip=195.216.197.8; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="john@coherentgraphics.co.uk"; x-sender="john@coherentgraphics.co.uk"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of john@coherentgraphics.co.uk) identity=mailfrom; client-ip=195.216.197.8; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="john@coherentgraphics.co.uk"; x-sender="john@coherentgraphics.co.uk"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mx1.ukhost4u.com) identity=helo; client-ip=195.216.197.8; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="john@coherentgraphics.co.uk"; x-sender="postmaster@mx1.ukhost4u.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BfAwBAMW9VlQjF2MNbg2Rkgxi9GYV7AoFBOxEBAQEBAQEBEQEBAQEJCwkJHzBBBYNdAQEEIxVAARALBxECAgUWCwICCQMCAQIBRQYOiDYBt3SjawEBAQEGAQEBAQEdgSGKIoUGB4JogUUBBJ9hhlGLbINZhB2CNIEBAQEB X-IPAS-Result: A0BfAwBAMW9VlQjF2MNbg2Rkgxi9GYV7AoFBOxEBAQEBAQEBEQEBAQEJCwkJHzBBBYNdAQEEIxVAARALBxECAgUWCwICCQMCAQIBRQYOiDYBt3SjawEBAQEGAQEBAQEdgSGKIoUGB4JogUUBBJ9hhlGLbINZhB2CNIEBAQEB X-IronPort-AV: E=Sophos;i="5.13,547,1427752800"; d="scan'208";a="133963576" Received: from mx1.ukhost4u.com ([195.216.197.8]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 03 Jun 2015 18:59:01 +0200 Received: from bluechip4.ukhost4u.com ([188.64.184.40]) by mx1.ukhost4u.com with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.85) (envelope-from ) id 1Z0C0G-0004sH-Nm; Wed, 03 Jun 2015 17:58:59 +0100 Received: from [86.6.29.185] (port=60907 helo=[192.168.0.3]) by bluechip4.ukhost4u.com with esmtpsa (TLSv1:DHE-RSA-CAMELLIA256-SHA:256) (Exim 4.85) (envelope-from ) id 1Z0C02-002xxW-GW; Wed, 03 Jun 2015 17:58:55 +0100 Message-ID: <556F3241.1050302@coherentgraphics.co.uk> Date: Wed, 03 Jun 2015 17:58:41 +0100 From: John Whitington User-Agent: Postbox 3.0.11 (Macintosh/20140602) MIME-Version: 1.0 To: Nils Becker CC: caml-list@inria.fr References: <20150602100015.E87D67EEF7@sympa.inria.fr> <556E2CE1.9040801@bioquant.uni-heidelberg.de> In-Reply-To: <556E2CE1.9040801@bioquant.uni-heidelberg.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-OutGoing-Spam-Status: No, score=-1.0 X-AuthUser: john@coherentgraphics.co.uk X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bluechip4.ukhost4u.com X-AntiAbuse: Original Domain - X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - coherentgraphics.co.uk X-Get-Message-Sender-Via: bluechip4.ukhost4u.com: none X-Filter-ID: s0sct1PQhAABKnZB5plbIf846yA3iTMvdsVmSdrHPMU9CTo+a6AtXGOZ5s/KMzk3GXNQvgP2LFpq 9ASq+UttQe54GsLHFDaYIIq1fxuDkLoALJo5YEyX8N32du8P3wb0xyF+Xs3wrD1BH0yD2aapIpcL LaBecbIx37QUCddVfpn5efmzkpT4qkMKnu8jQ/AfrTYpRPI0yAnEAseAyt9DsCflPnrJPLsWw7rW R7fh6X8zoGwirA1QEVIa2/dR0CuaHHASJNUmoOHSoqgqxfHmWXIj4SeemCSiNEUO0k3CLBEx1bBK 7Dq6GZhWav7R1qsM+xDzHADtBfD+faq0ZEFu6VV3koRXLKJm3JXU3J9VgL4JH6sC5oCk/8v9mZ1n Ys+9egsYGH1fZlV+kalxqYfScKyEYH55mPLBhlsV0aqcCQH3Y80OmAux3oN13+ztUzneac52tVLg wrA/hakwLYKHbntzT6+ScJT7eaLI9HlJOCfcgF/0t5rqsxFF4v9Qp7zQwHk7aTyzjL4TNz8iOsnz 6AoGstjtzxzqwD0gnz5PGWvQMLEQ0cIB6ZfJqnElUdaE9MeUABO8Yy/pti/3wQsT9TWCexnHHS0e Iel15PGPVa+EcB7jKME3nZyTBjs9FhYLcxw3qqhc+N6cuEg4XWh5FvnOF89iqzebsjQjI8oNBSIu sCTTVat+kf46oBYv9mItOVViCQIVHpGoBNTFwE2czcLOSMHDLKUVPR8Qkd7SwNA= X-Report-Abuse-To: spam@mx1.ukhost4u.com X-Filter-Fingerprint: IFrWXGses7OKB5S5G8/dJdIz5bb8V0ykx8BnFBnunHBA3cTUQ1R++keuE7RDJ8Kg3RbMLUalw1oC mj99/u+PoqoVy8a3lsStJtAvpObFX0Wok1JBYnOLzfRIhlEHQynLUpndEJ0YoaLytXXo8BMTaVt0 ARHRi6XGuAluI1udprFy32DUYpEhA3j9NJFmItfypuoazoDH3m92PL21GfhFYWcYmGLKZUTyGy/B A6iJtsD8WFC+rpTT4JYvoDjVeZUw3fI9smEy0EupqfCN6sn6Zg== X-Originating-IP: 188.64.184.40 X-SpamExperts-Domain: bluechip4.ukhost4u.com X-SpamExperts-Username: 188.64.184.40 Authentication-Results: ukhost4u.com; auth=pass smtp.auth=188.64.184.40@bluechip4.ukhost4u.com X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.00) X-Recommended-Action: accept Subject: Re: [Caml-list] pattern matching on mapped lists Hi Nils, Nils Becker wrote: > I find this syntax handy > > let [ii; jj] = List.map float_of_int [i; j] in > ... do stuff with the floats > > because it avoids repeating the function call. The compiler lets this > pass but warns that the matching is not exhaustive since [] is not > matched. This actually can't happen if I'm not mistaken. So, is this > considered good style, or is there a better idiomatic way to do multiple > assignments? If yes, should this be an enhancement request for the type > checker? If the lengths are almost always small, why not just put appropriate functions map_pair, map_tuple3, map_tuple4 etc. into your library? fun map_tuple3 f (x, y, z) = (f x, f y, f z) let (ii, jj) = map_pair float_of_int (i, j) Or, even... let ii, jj = map_pair float (i, j) ...if you really want to save typing. John -- John Whitington Director, Coherent Graphics Ltd http://www.coherentpdf.com/