diff options
author | Camil Staps | 2016-10-04 20:16:56 +0200 |
---|---|---|
committer | Camil Staps | 2016-10-04 20:16:56 +0200 |
commit | 2cd524e55f4d3057fe82db119541b1b5284629dc (patch) | |
tree | 5ed4dc27682c39a9c3f4c1e3a9f731c02a32b63b /examples/list.fusp | |
parent | Debug graph readability improvements (diff) |
Examples
Diffstat (limited to 'examples/list.fusp')
-rw-r--r-- | examples/list.fusp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/list.fusp b/examples/list.fusp index 2fce492..de3059e 100644 --- a/examples/list.fusp +++ b/examples/list.fusp @@ -1,3 +1,5 @@ +import int; + append [] ys = ys; append [x:xs] ys = [x:append xs ys]; @@ -9,3 +11,21 @@ isEmpty _ = 0; hd [x:_] = x; tl [_:x] = x; + +last [x:[]] = x; +last [_:xs] = last xs; + +init [] = []; +init [x:[]] = []; +init [x:xs] = [x:init xs]; + +length_tl i [] = i; +length_tl i [_:xs] = length_tl (add 1 i) xs; + +length xs = length_tl 0 xs; + +repeat 0 _ = []; +repeat n x = [x:repeat (sub 1 n) x]; + +map f [] = []; +map f [x:xs] = [f x:map f xs]; |