Trying to apply a map to "internal" function arguments in Haskell

Define an arbitrary function

someFunc a b = ...

If I ever need it, I know that I can do something like

map (someFunc a) [b0, b1, b2, ..., bn]

and I will get the result

[(someFunc a b0), (someFunc a b1), ..., (someFunc a bn)]

There is nothing new here. But what if, instead of using the second argument of the map b, I change it , I would like to change a(the "internal" argument)?

map (someFunc ? b) [?0, ?1, ?2, ..., ?n]

Is there a way to do this in Haskell? If not, what will be the work for this?

I know that I probably did not quite understand what I was posting. If necessary, I can try to reformulate my question :(

+3
source share
2 answers

You can use lambda

map (\a -> someFunc a b) ...

flip, :

map (flip someFunc b) ...
+11

flip :: (a -> b -> c) -> b -> a -> c

,

map (flip someFunc b) [a1...]

. , , , .

+4

Source: https://habr.com/ru/post/1778002/


All Articles