diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-02-05 07:17:02 +0100 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-02-05 07:17:02 +0100 |
commit | 1e99274564b711a161fd7cb812af3177626541b4 (patch) | |
tree | 07398292ecebcffa00c0bffbe981fcb6d65d9085 /lc | |
parent | 98cd7ed424454502d98aafe193b8cda61ef3b692 (diff) |
cleanup
Diffstat (limited to 'lc')
-rw-r--r-- | lc/Prelude.lc | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lc/Prelude.lc b/lc/Prelude.lc index f5d1fee6..ee18d1e9 100644 --- a/lc/Prelude.lc +++ b/lc/Prelude.lc | |||
@@ -8,6 +8,7 @@ import Builtins | |||
8 | 8 | ||
9 | infixr 9 . | 9 | infixr 9 . |
10 | infixl 7 `PrimMulMatVec`, `PrimDot` | 10 | infixl 7 `PrimMulMatVec`, `PrimDot` |
11 | infixr 5 ++ | ||
11 | infixr 3 *** | 12 | infixr 3 *** |
12 | infixr 0 $ | 13 | infixr 0 $ |
13 | --infixl 0 & | 14 | --infixl 0 & |
@@ -54,12 +55,15 @@ pairs v = zip v (tail v) | |||
54 | foldl' f e [] = e | 55 | foldl' f e [] = e |
55 | foldl' f e (x: xs) = foldl' f (f e x) xs | 56 | foldl' f e (x: xs) = foldl' f (f e x) xs |
56 | 57 | ||
57 | singleton a = [a] | 58 | foldr f e [] = e |
59 | foldr f e (x: xs) = f x (foldr f e xs) | ||
60 | |||
61 | foldr1 f (x: xs) = foldr f x xs | ||
58 | 62 | ||
59 | append [] ys = ys | 63 | [] ++ ys = ys |
60 | append (x:xs) ys = x : append xs ys | 64 | x:xs ++ ys = x : xs ++ ys |
61 | 65 | ||
62 | concat = foldl' append [] | 66 | concat = foldr (++) [] |
63 | 67 | ||
64 | map _ [] = [] | 68 | map _ [] = [] |
65 | map f (x:xs) = f x : map f xs | 69 | map f (x:xs) = f x : map f xs |
@@ -80,9 +84,6 @@ sortBy f [] = [] | |||
80 | sortBy f [x] = [x] | 84 | sortBy f [x] = [x] |
81 | sortBy f xs = uncurry (mergeBy f) ((sortBy f *** sortBy f) (split xs)) | 85 | sortBy f xs = uncurry (mergeBy f) ((sortBy f *** sortBy f) (split xs)) |
82 | 86 | ||
83 | (++) = append | ||
84 | infixr 5 ++ | ||
85 | |||
86 | iterate :: (a -> a) -> a -> [a] | 87 | iterate :: (a -> a) -> a -> [a] |
87 | iterate f x = x : iterate f (f x) | 88 | iterate f x = x : iterate f (f x) |
88 | 89 | ||
@@ -96,9 +97,6 @@ tuptype (x:xs) = '(x, tuptype xs) | |||
96 | data RecordC (xs :: [(String, Type)]) | 97 | data RecordC (xs :: [(String, Type)]) |
97 | = RecordCons (tuptype (map snd xs)) | 98 | = RecordCons (tuptype (map snd xs)) |
98 | 99 | ||
99 | foldr1 f [x] = x | ||
100 | foldr1 f (x: xs) = f x (foldr1 f xs) | ||
101 | |||
102 | False ||| x = x | 100 | False ||| x = x |
103 | True ||| x = True | 101 | True ||| x = True |
104 | 102 | ||