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