]> gerrit.simantics Code Review - simantics/platform.git/blob - tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/MaximumBy.scl
(refs #7307) Added features field to SCL module header
[simantics/platform.git] / tests / org.simantics.scl.compiler.tests / src / org / simantics / scl / compiler / tests / scl / MaximumBy.scl
1 import "Prelude" hiding (maximumBy)
2
3 maximumBy :: Ord b => (a -> b) -> [a] -> a
4 maximumBy f = snd . foldl1 maxF . map (\x -> (f x, x))
5   where
6     maxF (a @ (aV,_)) (b @ (bV,_)) = if aV >= bV then a else b
7   
8 main = maximumBy (`mod` 10) [1::Integer, 14, 23, 9, 14, 67]  
9 --
10 9