Ask Your Question
0

Transpose a pattern down

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

jarm gravatar image

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

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
3

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

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

Comments

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

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

Question Tools

1 follower

Stats

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

Seen: 172 times

Last updated: Jul 19 '16