mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-21 02:31:50 +03:00
a972778eab
They don't all pass yet, for minor reasons. Coming shortly... Unfortunately the startup overhead for chez is really noticeable here!
27 lines
632 B
Plaintext
27 lines
632 B
Plaintext
data Nat : Type where
|
|
Z : Nat
|
|
S : Nat -> Nat
|
|
|
|
namespace Stream
|
|
public export
|
|
data Stream : Type -> Type where
|
|
Cons : $a -> Inf (Stream $a) -> Stream $a
|
|
|
|
ones : Stream Integer
|
|
ones = Cons 1 ones
|
|
|
|
countFrom : Integer -> Stream Integer
|
|
countFrom $x = Cons x (countFrom (prim__add_Integer 1 x))
|
|
|
|
data List : Type -> Type where
|
|
Nil : List $a
|
|
Cons : $a -> List $a -> List $ a
|
|
|
|
take : Nat -> Stream $a -> List $a
|
|
take Z $xs = Nil
|
|
take (S $k) (Cons $x $xs) = Cons x (take k xs)
|
|
|
|
every2nd : Nat -> Stream $a -> List $a
|
|
every2nd Z $xs = Nil
|
|
every2nd (S $k) (Cons _ (Cons $x $xs)) = Cons x (every2nd k xs)
|