mirror of
https://github.com/ilyakooo0/Idris-dev.git
synced 2024-11-11 14:57:30 +03:00
22 lines
587 B
Plaintext
22 lines
587 B
Plaintext
data Nil 0
|
|
data Cons 2
|
|
|
|
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 dumpList(xs) = case xs of {
|
|
Nil => "END"
|
|
| Cons(y, ys) => %IntString(y) ++ ", " ++ dumpList(ys)
|
|
}
|
|
|
|
fun double(x) = x + x
|
|
|
|
fun main() = %WriteString(dumpList(take(5, countFrom(10))))
|