[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2005-02-08 (14:24) |
From: | Beck01, Wolfgang <BeckW@t...> |
Subject: | AW: [Caml-list] paralell assignment problem |
> 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