added PEnum
This commit is contained in:
parent
d6d0fb7146
commit
41fc863658
5 changed files with 43 additions and 20 deletions
26
test_program
26
test_program
|
|
@ -12,30 +12,32 @@ hello_world = Cons 'h' (Cons 'e' (Cons 'l' (Cons 'l' (Cons 'o' (Cons ' ' (Cons '
|
|||
|
||||
length : List (a) -> Int ;
|
||||
length xs = case xs of {
|
||||
Nil => 0,
|
||||
Cons x xs => length xs
|
||||
Nil => 0;
|
||||
Cons x xs => length xs;
|
||||
};
|
||||
|
||||
head : List (a) -> a ;
|
||||
head xs = case xs of {
|
||||
Cons x xs => x
|
||||
Cons x xs => x;
|
||||
};
|
||||
|
||||
firstIsOne : List (Int) -> Bool () ;
|
||||
firstIsOne xs = case xs of {
|
||||
Cons x xs => case x of {
|
||||
0 => True ,
|
||||
0 => True;
|
||||
_ => case xs of {
|
||||
Cons x xs => False ,
|
||||
_ => False
|
||||
}
|
||||
},
|
||||
_ => False
|
||||
Cons x xs => False;
|
||||
_ => False;
|
||||
};
|
||||
};
|
||||
_ => False;
|
||||
};
|
||||
|
||||
main = firstIsOne (Cons 1 Nil);
|
||||
|
||||
deepPat xs = case xs of {
|
||||
Cons 1 _ => True ,
|
||||
_ => False
|
||||
}
|
||||
Cons (Nil) _ => True;
|
||||
_ => False;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue