Point-free in Haskell

后端 未结 5 1008
刺人心
刺人心 2020-12-14 09:30

I have this code that I want to make point-free;

(\\k t -> chr $ a + flip mod 26 (ord k + ord t -2*a))

How do I do that?

Also are the

5条回答
  •  别那么骄傲
    2020-12-14 09:55

    Also are there some general rules for point free style other than "think about this amd come up with something"?

    You can always cheat and use the "pl" tool from lambdabot (either by going to #haskell on freenode or by using e.g. ghci on acid). For your code pl gives:

    ((chr . (a +) . flip mod 26) .) . flip flip (2 * a) . ((-) .) . (. ord) . (+) . ord

    Which isn't really an improvement if you ask me.

提交回复
热议问题