Hi all, Call me crazy if you want but I'm programming Haskell Code in PHP :-). I need some help to find a way to implement the Haskell flip function. Let me introduce flip:
Flip receives two arguments: arg1 and arg2 arg1 must be the name of a function taking two arguments, name it f(x1,x2) arg2 is any variable Flip returns a function taking one argument, name it g(x), if you call g(foo) then the result will be the same as calling f(foo,arg2). Example: function add($x1,$x2) {return $x1+$x2;} $newfunc = flip("add",23); $result = $newfunc(12); // $result should be 23+12 I've tried with create function, for example: function flip($f,$arg) { return create_function('$y','return '.$f."($arg".',$y);'); } But if you use flip("foo",$o1) where o1 is an object then it won't work. There should be some workaround using references and who knows what... but I'm too old to find it, ideas? Garland. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php