From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 29BAEBC88 for ; Tue, 8 Feb 2005 15:24:54 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j18EOrLF023468 for ; Tue, 8 Feb 2005 15:24:53 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA24951 for ; Tue, 8 Feb 2005 15:24:53 +0100 (MET) Received: from mail1.telekom.de (tcmail22.telekom.de [217.6.95.236]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j18EOqdg025254 for ; Tue, 8 Feb 2005 15:24:53 +0100 Received: from g9jbr.mgb01.telekom.de (g9jbr.mgb01.telekom.de [164.20.31.6]) by tcmail21.dmz.telekom.de with ESMTP for caml-list@inria.fr; Tue, 8 Feb 2005 15:24:52 +0100 Received: by G9JBR.mgb01.telekom.de with Internet Mail Service (5.5.2653.19) id <13M5M9D8>; Tue, 8 Feb 2005 15:24:52 +0100 Message-Id: <76C27E1CE3FFC847B4D51C645D6F42AA15FE3B@E9JDF.mgb01.telekom.de> From: "Beck01, Wolfgang" To: caml-list@inria.fr Subject: AW: [Caml-list] paralell assignment problem Date: Tue, 8 Feb 2005 15:24:50 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain X-Miltered: at concorde with ID 4208CBB5.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4208CBB4.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; t-systems:01 caml-list:01 wolfgang:02 wolfgang:02 expressions:03 swap:04 problem:05 probably:05 certainly:08 example:10 assignments:11 assignments:11 but:12 solution:12 solution:12 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: > The solution is a sequence of assignments involving > only xi, ei, and ti, where ti are temporaries introduced > to save the values of the expressions. For example, > a solution to > > x,y = y,x > > is > > t = x; x = y; y = t > > I seek a solution which minimises the number of assignments. > Note that the relation you probably know the 'xor trick' to swap value without a temporary: // x = A; y = B x = x lxor y; // x = A XOR B; y = B y = x lxor y; // x = A XOR B; y = A XOR B XOR B // x = A XOR B; y = A x = x lxor y; // x = A XOR B XOR A; y = A // x = B; y = A Certainly not what you were looking for, but always nice :-) Wolfgang