[Haskell-cafe] Matlab Style Logic Operations ala V1.*(V2>0) on Vectors and Matrices with HMatrix ??
lemming at henning-thielemann.de
Sun Dec 26 00:52:40 CET 2010
On Sat, 25 Dec 2010, gutti wrote:
> this line works :
> matrixfunction x y = liftMatrix2 (zipVectorWith(\a1 a2 -> if a2>=0 then a1 else 0)) x y
> but when I use this line :
> matrixfunction f x y = liftMatrix2 (zipVectorWith f) x y
> how can / do I have to define f in a seperate line a way, that it works and
> gives the same result ?
The same way you have literally replaced
(\a1 a2 -> if a2>=0 then a1 else 0)
by 'f' at the right hand side, you can use that phrase as argument to the
matrixfunction (\a1 a2 -> if a2>=0 then a1 else 0) x y
The lambda expression (\ ...) really is just a notation for a function.
More information about the Haskell-Cafe