mirror of
https://github.com/ilyakooo0/Idris-dev.git
synced 2024-11-15 01:25:05 +03:00
31 lines
808 B
Plaintext
31 lines
808 B
Plaintext
data Nil 0
|
|
data Cons 2
|
|
|
|
fun twice(f, x) = f(f(x))
|
|
|
|
fun map(f, xs) = case xs of {
|
|
Nil => Nil
|
|
| Cons(y, ys) => Cons(f(y), map(f, ys))
|
|
}
|
|
|
|
fun dumpList(xs) = case xs of {
|
|
Nil => "END"
|
|
| Cons(y, ys) => %IntString(y) ++ ", " ++ dumpList(ys)
|
|
}
|
|
|
|
fun countFrom(x) = Cons(x, countFrom@(x+1))
|
|
|
|
fun take(n, xs) = case n of {
|
|
0 => Nil
|
|
| _ => case xs of {
|
|
Nil => Nil
|
|
| Cons(y, ys) => Cons(y, take(n-1, ys))
|
|
}
|
|
}
|
|
|
|
fun double(x) = x + x
|
|
|
|
fun main() = let mult = 2 in
|
|
%WriteString(dumpList(map(twice(\ x => x*mult), take(1010, countFrom(10)))))
|
|
|