@@ -9,8 +9,8 @@ import Native.List as L
10-- Puts two appendable things together:
10-- Puts two appendable things together:
12−-- [1,1] ++ [2,3] == [1,1,2,3]
12+-- [1,1] ++ [2,3] == [1,1,2,3]
13−-- "abc" ++ "123" == "abc123"
13+-- "abc" ++ "123" == "abc123"
14(++) : Appendable a -> Appendable a -> Appendable a
14(++) : Appendable a -> Appendable a -> Appendable a
16-- Extract the first element of a list. List must be non-empty.
16-- Extract the first element of a list. List must be non-empty.
@@ -25,6 +25,13 @@ tail : [a] -> [a]
25-- `(last [1,2,3] == 3)`
25-- `(last [1,2,3] == 3)`
26last : [a] -> a
26last : [a] -> a
28+-- Check if a list is empty `(isEmpty [] == True)`
28-- Apply a function to every element of a list: `(map sqrt [1,4,9] == [1,2,3])`
35-- Apply a function to every element of a list: `(map sqrt [1,4,9] == [1,2,3])`
29map : (a -> b) -> [a] -> [b]
36map : (a -> b) -> [a] -> [b]
@@ -42,12 +49,12 @@ foldr1 : (a -> a -> a) -> [a] -> a
43-- Reduce a list from the left, building up all of the intermediate results into a list.
50-- Reduce a list from the left, building up all of the intermediate results into a list.
45−-- scanl (+) 0 [1,2,3,4] == [0,1,3,6,10]
52+-- scanl (+) 0 [1,2,3,4] == [0,1,3,6,10]
46scanl : (a -> b -> b) -> b -> [a] -> [b]
53scanl : (a -> b -> b) -> b -> [a] -> [b]
48-- Same as scanl but it doesn't require a base case. List must be non-empty.
55-- Same as scanl but it doesn't require a base case. List must be non-empty.
50−-- scanl1 (+) [1,2,3,4] == [1,3,6,10]
57+-- scanl1 (+) [1,2,3,4] == [1,3,6,10]
51scanl1 : (a -> a -> a) -> [a] -> [a]
58scanl1 : (a -> a -> a) -> [a] -> [a]
53-- Filter out elements which do not satisfy the predicate: `(filter isLower "AaBbCc" == "abc")`
60-- Filter out elements which do not satisfy the predicate: `(filter isLower "AaBbCc" == "abc")`
@@ -73,12 +80,12 @@ or : [Bool] -> Bool
74-- Concatenate a list of appendable things:
81-- Concatenate a list of appendable things:
76−-- concat ["tree","house"] == "treehouse"
83+-- concat ["tree","house"] == "treehouse"
77concat : [Appendable a] -> Appendable a
84concat : [Appendable a] -> Appendable a
79-- Map a given function onto a list and flatten the resulting lists.
86-- Map a given function onto a list and flatten the resulting lists.
81−-- concatMap f xs == concat (map f xs)
88+-- concatMap f xs == concat (map f xs)
82concatMap : (a -> Appendable b) -> [a] -> Appendable b
89concatMap : (a -> Appendable b) -> [a] -> Appendable b
83concatMap f = L.concat . L.map f
90concatMap f = L.concat . L.map f
@@ -109,14 +116,14 @@ partition pred lst =
109-- Combine two lists, combining them into tuples pairwise.
116-- Combine two lists, combining them into tuples pairwise.
110-- If one list is longer, the extra elements are dropped.
117-- If one list is longer, the extra elements are dropped.
112−-- zip [1,2,3] [6,7] == [(1,6),(2,7)]
119+-- zip [1,2,3] [6,7] == [(1,6),(2,7)]
113−-- zip == zipWith (,)
120+-- zip == zipWith (,)
114zip : [a] -> [b] -> [(a,b)]
121zip : [a] -> [b] -> [(a,b)]
116-- Combine two lists, combining them with the given function.
123-- Combine two lists, combining them with the given function.
117-- If one list is longer, the extra elements are dropped.
124-- If one list is longer, the extra elements are dropped.
119−-- zipWith (+) [1,2,3] [1,2,3,4] == [2,4,6]
126+-- zipWith (+) [1,2,3] [1,2,3,4] == [2,4,6]
120zipWith : (a -> b -> c) -> [a] -> [b] -> [c]
127zipWith : (a -> b -> c) -> [a] -> [b] -> [c]
122-- Decompose a list of tuples.
129-- Decompose a list of tuples.
@@ -128,18 +135,18 @@ unzip pairs =
129-- Split a list with a given seperator.
136-- Split a list with a given seperator.
131−-- split "," "hello,there,friend" == ["hello", "there", "friend"]
138+-- split "," "hello,there,friend" == ["hello", "there", "friend"]
132split : [a] -> [a] -> [[a]]
139split : [a] -> [a] -> [[a]]
134-- Places the given value between all of the lists in the second argument
141-- Places the given value between all of the lists in the second argument
135-- and concatenates the result.
142-- and concatenates the result.
137−-- join "a" ["H","w","ii","n"] == "Hawaiian"
144+-- join "a" ["H","w","ii","n"] == "Hawaiian"
138join : Appendable a -> [Appendable a] -> Appendable a
145join : Appendable a -> [Appendable a] -> Appendable a
140-- Places the given value between all members of the given list.
147-- Places the given value between all members of the given list.
142−-- intersperse ' ' "INCEPTION" == "I N C E P T I O N"
149+-- intersperse ' ' "INCEPTION" == "I N C E P T I O N"
143intersperse : a -> [a] -> [a]
150intersperse : a -> [a] -> [a]
144intersperse sep xs =
151intersperse sep xs =
145 case xs of
152 case xs of