I want to apply a lambda function through a map
on a list of vectors and be able to get a list of Booleans from the results and then compare all elements in the list of Booleans
lambda = (\ list x -> distance (x (5,5)) < 10)
[(0,1),(1,6),(15,36)] ->
Apply the lambda on each elements, which would give: [True, True, False]
and then check if all elements are True
I tried to do this
checkConvergence :: [Vector] -> Vector -> Bool
checkConvergence list y = map (\ list x -> distance (x y) < 10) list
But I got this:
Couldn't match expected type 'Bool' with actual type [(Vector -> Vector) -> Bool]
Three problems:
\ x ->
instead of \ list x ->
.map
will give you a list of Bool
s. If you want to know if they're all true, then you need to either use all
instead, or wrap the result in and
.Vector
is an alias for some weird function type, you probably meant distance xy
or distance (x,y)
instead of distance (xy)
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.