Fixed a bug with pattern matching on literals.
This commit is contained in:
parent
82f1b38f1b
commit
f69151a7ce
2 changed files with 19 additions and 4 deletions
|
|
@ -4,7 +4,21 @@ data List () where {
|
|||
Nil : List ()
|
||||
};
|
||||
|
||||
main = sumlength (Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 Nil)))));
|
||||
main = head (repeat 10 5);
|
||||
|
||||
head : List () -> Int ;
|
||||
head x = case x of {
|
||||
Cons h _ => h ;
|
||||
};
|
||||
|
||||
repeat : Int -> Int -> List () ;
|
||||
repeat x n = case n of {
|
||||
0 => Nil ;
|
||||
n => Cons x (repeat x (n + minusOne)) ;
|
||||
};
|
||||
|
||||
minusOne : Int ;
|
||||
minusOne = 9223372036854775807 + 9223372036854775807 + 1;
|
||||
|
||||
-- take the length of a list
|
||||
length : List () -> Int ;
|
||||
|
|
@ -13,7 +27,7 @@ length x = case x of {
|
|||
Nil => 0 ;
|
||||
};
|
||||
-- sum a list
|
||||
sum : List () -> Int ;
|
||||
sum : List () -> Int ;
|
||||
sum x = case x of {
|
||||
Cons a xs => a + sum xs ;
|
||||
Nil => 0 ;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue