Dot operator in haskell with multi-parameter functions

前端 未结 2 612
北海茫月
北海茫月 2021-01-01 00:12

I want to write a function point-free in haskell, to keep things simple lets say I want to make this function:

maxmin :: Ord a => a -> a -> a ->          


        
2条回答
  •  别那么骄傲
    2021-01-01 00:50

    I wouldn't say this is simplier but here you go:

    maxmin :: Ord a => a -> a -> a -> a                                             
    maxmin = (. min) . (.) . max 
    

    (Generated with pl tool from lambdabot http://www.haskell.org/haskellwiki/Pointfree)

    lambdabot> pl maxmin a b c = max a (min b c)
    maxmin = (. min) . (.) . max
    

提交回复
热议问题