File: filtermap.curry

package info (click to toggle)
curry-tools 1.0.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,492 kB
  • ctags: 121
  • sloc: makefile: 470; sh: 421
file content (19 lines) | stat: -rw-r--r-- 468 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

flip :: (a -> b -> c) -> b -> a -> c
flip f x y = f y x

map :: (a -> b) -> [a] -> [b]
map _ []     = []
map f (x:xs) = f x : map f xs

filter :: (a -> Bool) -> [a] -> [a]
filter _ []     = []
filter p (x:xs) = if p x then x : filter p xs
                         else     filter p xs

goal xs = PEVAL (filter (flip (>) 100) (map (flip (*) 3) xs))

main = goal [10, 20 .. 200]

benchmark = let l,r free in l =:= [1..20000] &>
                            goal l =:= r