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 5A8C57F919 for ; Fri, 20 May 2016 09:57:47 +0200 (CEST) IronPort-PHdr: 9a23:y1RFjxfk8IlKkXTbu1yxSFcplGMj4u6mDksu8pMizoh2WeGdxc69YR7h7PlgxGXEQZ/co6odzbGG4ua7AidZucrJmUtBWaIPfidNsd8RkQ0kDZzNImzAB9muURYHGt9fXkRu5XCxPBsdMs//Y1rPvi/6tmZKSV3BPAZ4bt74BpTVx5zukbviqtuIOE4R3Gb1SIgxBSv1hD2ZjtMRj4pmJ/R54TryiVwMRd5rw3h1L0mYhRf265T41pdi9yNNp6BprJYYAu2pN5g/GPZTBTEidmQ0/9HDtB/ZTALJ6GFWGjEdmx9MRgzE9w3SX5HrsyK8uPAriweAOsijB4szVDu+9aBzDFfNiSwHPjM9uimDj817jKtWpFS6oBFw35TTeKmUMuZzeuXWetZMFjkJZdpYSyEUWtD0VIAIFedUZes= Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=michael.soegtrop@intel.com; spf=Pass smtp.mailfrom=michael.soegtrop@intel.com; spf=None smtp.helo=postmaster@mga11.intel.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of michael.soegtrop@intel.com) identity=pra; client-ip=192.55.52.93; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="michael.soegtrop@intel.com"; x-sender="michael.soegtrop@intel.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of michael.soegtrop@intel.com designates 192.55.52.93 as permitted sender) identity=mailfrom; client-ip=192.55.52.93; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="michael.soegtrop@intel.com"; x-sender="michael.soegtrop@intel.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mga11.intel.com) identity=helo; client-ip=192.55.52.93; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="michael.soegtrop@intel.com"; x-sender="postmaster@mga11.intel.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0B4AAA3wj5XgF00N8BegmyBIX4GugMBDYF1FwEChXcCgTE4FAEBAQEBAQEBEQEBCwsJCSEkC4ItghwnBhxCASpWJgEEG4gmAaJwoU4MJYYmiQ2CRwtAGIIuBZguBgGBLpwNj0seAQGEL26HBwF+AQEB X-IPAS-Result: A0B4AAA3wj5XgF00N8BegmyBIX4GugMBDYF1FwEChXcCgTE4FAEBAQEBAQEBEQEBCwsJCSEkC4ItghwnBhxCASpWJgEEG4gmAaJwoU4MJYYmiQ2CRwtAGIIuBZguBgGBLpwNj0seAQGEL26HBwF+AQEB X-IronPort-AV: E=Sophos;i="5.26,338,1459807200"; d="scan'208,217";a="178411873" Received: from mga11.intel.com ([192.55.52.93]) by mail3-smtp-sop.national.inria.fr with ESMTP; 20 May 2016 09:57:45 +0200 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 20 May 2016 00:57:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,338,1459839600"; d="scan'208,217";a="985158841" Received: from irsmsx104.ger.corp.intel.com ([163.33.3.159]) by fmsmga002.fm.intel.com with ESMTP; 20 May 2016 00:57:42 -0700 Received: from irsmsx102.ger.corp.intel.com ([169.254.2.234]) by IRSMSX104.ger.corp.intel.com ([163.33.3.159]) with mapi id 14.03.0248.002; Fri, 20 May 2016 08:57:41 +0100 From: "Soegtrop, Michael" To: "caml-list@inria.fr" Thread-Topic: Syntax for several matches, each with a "when" clause, but only one result Thread-Index: AdGybUih6TsWTxfOTvW3zbwyc9iESw== Date: Fri, 20 May 2016 07:57:41 +0000 Message-ID: <0F7D3B1B3C4B894D824F5B822E3E5A172CF046D5@IRSMSX102.ger.corp.intel.com> Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.181] Content-Type: multipart/alternative; boundary="_000_0F7D3B1B3C4B894D824F5B822E3E5A172CF046D5IRSMSX102gercor_" MIME-Version: 1.0 Subject: [Caml-list] Syntax for several matches, each with a "when" clause, but only one result --_000_0F7D3B1B3C4B894D824F5B822E3E5A172CF046D5IRSMSX102gercor_ Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Dear OCaml Users, sometimes I want to do something like match expr with | case1 when cond1 | case2 when cond2 | case3 when cond3 -> result but this doesn't work. I have to write match expr with | case1 when cond1 -> result | case2 when cond2 -> result | case3 when cond3 -> result Usually only some of the matches have a when clause. Is there a way to avoi= d copying the result term (other than writing a function) ? Best regards, Michael Intel Deutschland GmbH Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Christian Lamprechter Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928 --_000_0F7D3B1B3C4B894D824F5B822E3E5A172CF046D5IRSMSX102gercor_ Content-Type: text/html; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable

Dear OCaml Users,

 

sometimes I want to do something like

 

match expr with

| case1 when cond1

| case2 when cond2

| case3 when cond3 -> result

 

but this doesn’t work. I have to write

 

match expr with

| case1 when cond1 -> result

| case2 when cond2 -> result

| case3 when cond3 -> result

 

Usually only some of the matches have a when clause.= Is there a way to avoid copying the result term (other than writing a func= tion) ?

 

Best regards,

 

Michael

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

--_000_0F7D3B1B3C4B894D824F5B822E3E5A172CF046D5IRSMSX102gercor_--