on master help sign in
Minor bug fixes
commita8df7eb28a0dc232453cb991f8145355480d2a45 authorevancz <info@elm-lang.org> dateMon 6 May 2013, 02:30 (13 years ago) parent3f8ce38
4 files changed+24−9
libraries/Dict.elm+4−4 libraries/Either.elm+18−3 libraries/Native/Signal/Random.js+1−1 libraries/Set.elm+1−1
libraries/Dict.elm+4−4
@@ -119,11 +119,11 @@ max t =
119119lookup : Comparable k -> Dict (Comparable k) v -> Maybe v
120120lookup k t =
121121 case t of
122− RBEmpty -> Nothing
122+ RBEmpty -> Maybe.Nothing
123123 RBNode _ k' v l r ->
124124 case compare k k' of
125125 LT -> lookup k l
126− EQ -> Just v
126+ EQ -> Maybe.Just v
127127 GT -> lookup k r
128128
129129-- Find the value associated with a key. If the key is not found,
@@ -282,11 +282,11 @@ moveRedRight t =
282282
283283moveRedLeftIfNeeded : Dict k v -> Dict k v
284284moveRedLeftIfNeeded 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
286286
287287moveRedRightIfNeeded : Dict k v -> Dict k v
288288moveRedRightIfNeeded 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
290290
291291deleteMin : Dict k v -> Dict k v
292292deleteMin t =
libraries/Either.elm+18−3
@@ -24,13 +24,28 @@ isRight e = case e of { Right _ -> True ; _ -> False }
2424
2525-- Keep only the values held in `Left` values.
2626lefts : [Either a b] -> [a]
27−lefts es = List.filter isLeft es
27+lefts es = List.foldr consLeft [] es
2828
2929-- Keep only the values held in `Right` values.
3030rights : [Either a b] -> [b]
31−rights es = List.filter isRight es
31+rights es = List.foldr consRight [] es
3232
3333-- Split into two lists, lefts on the left and rights on the right. So we
3434-- have the equivalence: `(partition es == (lefts es, rights es))`
3535partition : [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) {
1616 return A2( Signal.lift, f, signal );
1717 }
1818
19− return elm.Native.Random = { range: F3(randomize), float: float };
19+ return elm.Native.Random = { range: F3(range), float: float };
2020
2121};
libraries/Set.elm+1−1
@@ -42,7 +42,7 @@ intersect = Dict.intersect
4242-- Get the difference between the first set and the second. Keeps values
4343-- that do not appear in the second set.
4444diff : Set (Comparable k) -> Set (Comparable k) -> Set (Comparable k)
45−diff s1 s2 = foldl remove s1 s2
45+diff = Dict.diff
4646
4747-- Convert a set into a list.
4848toList : Set (Comparable k) -> [Comparable k]