How to compose `not` with a function of arbitrary arity?

前端 未结 4 1585
囚心锁ツ
囚心锁ツ 2020-11-29 01:21

When I have some function of type like

f :: (Ord a) => a -> a -> Bool
f a b = a > b

I should like make function which wrap this

4条回答
  •  时光取名叫无心
    2020-11-29 01:57

    Your n combinator can be written:

    n = ((not .) .)
    

    As for your bonus question, the typical way around would be to create several of these:

    lift2 = (.).(.)
    lift3 = (.).(.).(.)
    lift4 = (.).(.).(.).(.)
    lift5 = (.).(.).(.).(.).(.)
    

    etc.

提交回复
热议问题