File: iterate.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 (23 lines) | stat: -rw-r--r-- 423 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
20
21
22
23
import Profile

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

comp :: (a -> b) -> (c -> a) -> c -> b
comp f g x = f (g x)

inc :: Int -> Int
inc x = x + 1

-- beyond higher-order macros:
iter f n = if n == 0 then f else iter (comp f f) (n - 1)

goal xs = PEVAL (map (iter inc 2) xs)

main = goal [1..10]

benchmark = do
  let l free
  doSolve (l =:= [1 .. 200000])
  profileTimeNF (goal l)