Ask Your Question

Transpose a pattern down

asked 2016-07-19 20:56:28 -0500

jarm gravatar image

updated 2016-12-16 03:01:06 -0500

lennart gravatar image

How do you transpose a pattern down? I am aware of this to transpose up:

fmap (+12)

But this does not work:

fmap (-12)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-07-19 21:04:57 -0500

Dioxylin gravatar image

You'll need to wrap the minus sign in parentheses, like so:

fmap ((-)12)

It's because -12 is seen as a number, so you need to transform minus into a prefix function via (-) so it basically becomes a function (-) 12 that takes an argument (and since you're using fmap, it maps over the functor you're giving it).

edit flag offensive delete link more


Also you can do: `fmap(subtract 12)` if you don't feel like using parenthesis :-)

lvm gravatar imagelvm ( 2016-07-19 21:07:12 -0500 )edit

Question Tools

1 follower


Asked: 2016-07-19 20:56:28 -0500

Seen: 190 times

Last updated: Jul 19 '16