on master help sign in
Minor bug fixes
a8df7ebevancz
libraries/Dict.elm+4−4
@@ -119,11 +119,11 @@ max t =
119lookup : Comparable k -> Dict (Comparable k) v -> Maybe v
119lookup : Comparable k -> Dict (Comparable k) v -> Maybe v
120lookup k t =
120lookup k t =
121 case t of
121 case t of
122− RBEmpty -> Nothing
122+ RBEmpty -> Maybe.Nothing
123 RBNode _ k' v l r ->
123 RBNode _ k' v l r ->
124 case compare k k' of
124 case compare k k' of
125 LT -> lookup k l
125 LT -> lookup k l
126− EQ -> Just v
126+ EQ -> Maybe.Just v
127 GT -> lookup k r
127 GT -> lookup k r
128
128
129-- Find the value associated with a key. If the key is not found,
129-- Find the value associated with a key. If the key is not found,
@@ -282,11 +282,11 @@ moveRedRight t =
282
282
283moveRedLeftIfNeeded : Dict k v -> Dict k v
283moveRedLeftIfNeeded : Dict k v -> Dict k v
284moveRedLeftIfNeeded t =
284moveRedLeftIfNeeded t =
285− if not (isRedLeft t) && not (isRedLeftLeft t) then moveRedLeft t else t
285+ if isRedLeft t || isRedLeftLeft t then t else moveRedLeft t
286
286
287moveRedRightIfNeeded : Dict k v -> Dict k v
287moveRedRightIfNeeded : Dict k v -> Dict k v
288moveRedRightIfNeeded t =
288moveRedRightIfNeeded t =
289− if not (isRedRight t) && not (isRedRightLeft t) then moveRedRight t else t
289+ if isRedRight t || isRedRightLeft t then t else moveRedRight t
290
290
291deleteMin : Dict k v -> Dict k v
291deleteMin : Dict k v -> Dict k v
292deleteMin t =
292deleteMin t =
libraries/Either.elm+18−3
@@ -24,13 +24,28 @@ isRight e = case e of { Right _ -> True ; _ -> False }
24
24
25-- Keep only the values held in `Left` values.
25-- Keep only the values held in `Left` values.
26lefts : [Either a b] -> [a]
26lefts : [Either a b] -> [a]
27−lefts es = List.filter isLeft es
27+lefts es = List.foldr consLeft [] es
28
28
29-- Keep only the values held in `Right` values.
29-- Keep only the values held in `Right` values.
30rights : [Either a b] -> [b]
30rights : [Either a b] -> [b]
31−rights es = List.filter isRight es
31+rights es = List.foldr consRight [] es
32
32
33-- Split into two lists, lefts on the left and rights on the right. So we
33-- Split into two lists, lefts on the left and rights on the right. So we
34-- have the equivalence: `(partition es == (lefts es, rights es))`
34-- have the equivalence: `(partition es == (lefts es, rights es))`
35partition : [Either a b] -> ([a],[b])
35partition : [Either a b] -> ([a],[b])
36−partition es = List.partition isLeft es
36+partition es = List.foldr consEither ([],[]) es
37+
38+consLeft e vs =
39+ case e of
40+ Left v -> v::vs
41+ Right _ -> vs
42+
43+consRight e vs =
44+ case e of
45+ Left _ -> vs
46+ Right v -> v::vs
47+
48+consEither e (ls,rs) =
49+ case e of
50+ Left l -> (l::ls,rs)
51+ Right r -> (ls,r::rs)
libraries/Native/Signal/Random.js+1−1
@@ -16,6 +16,6 @@ Elm.Native.Random = function(elm) {
16 return A2( Signal.lift, f, signal );
16 return A2( Signal.lift, f, signal );
17 }
17 }
18
18
19− return elm.Native.Random = { range: F3(randomize), float: float };
19+ return elm.Native.Random = { range: F3(range), float: float };
20
20
21};
21};
libraries/Set.elm+1−1
@@ -42,7 +42,7 @@ intersect = Dict.intersect
42-- Get the difference between the first set and the second. Keeps values
42-- Get the difference between the first set and the second. Keeps values
43-- that do not appear in the second set.
43-- that do not appear in the second set.
44diff : Set (Comparable k) -> Set (Comparable k) -> Set (Comparable k)
44diff : Set (Comparable k) -> Set (Comparable k) -> Set (Comparable k)
45−diff s1 s2 = foldl remove s1 s2
45+diff = Dict.diff
46
46
47-- Convert a set into a list.
47-- Convert a set into a list.
48toList : Set (Comparable k) -> [Comparable k]
48toList : Set (Comparable k) -> [Comparable k]