Joe*_*hoi 4 haskell filtering pointfree tacit-programming
是否存在一个无点函数,filter用于查找列表中对的第一个元素的最小值?例如:
findMinimum xs = filter ((== minimum (map fst xs)) . fst ) xs
-- example:
findMinimum [(0, 0), (0, 1), (2, 2), (3, 2), (1, 4)] = [(0, 0), (0, 1)]
Run Code Online (Sandbox Code Playgroud)
如何将findMinimum函数转换为无点:
findMinimum = ??
Run Code Online (Sandbox Code Playgroud)
pointfree.io输出这个,这不是太糟糕.不过,我仍然更喜欢原始代码.
findMinimum = filter =<< (. fst) . (==) . minimum . map fst
Run Code Online (Sandbox Code Playgroud)