summaryrefslogtreecommitdiff
path: root/lc
diff options
context:
space:
mode:
authorPéter Diviánszky <divipp@gmail.com>2016-02-05 07:17:02 +0100
committerPéter Diviánszky <divipp@gmail.com>2016-02-05 07:17:02 +0100
commit1e99274564b711a161fd7cb812af3177626541b4 (patch)
tree07398292ecebcffa00c0bffbe981fcb6d65d9085 /lc
parent98cd7ed424454502d98aafe193b8cda61ef3b692 (diff)
cleanup
Diffstat (limited to 'lc')
-rw-r--r--lc/Prelude.lc18
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
9infixr 9 . 9infixr 9 .
10infixl 7 `PrimMulMatVec`, `PrimDot` 10infixl 7 `PrimMulMatVec`, `PrimDot`
11infixr 5 ++
11infixr 3 *** 12infixr 3 ***
12infixr 0 $ 13infixr 0 $
13--infixl 0 & 14--infixl 0 &
@@ -54,12 +55,15 @@ pairs v = zip v (tail v)
54foldl' f e [] = e 55foldl' f e [] = e
55foldl' f e (x: xs) = foldl' f (f e x) xs 56foldl' f e (x: xs) = foldl' f (f e x) xs
56 57
57singleton a = [a] 58foldr f e [] = e
59foldr f e (x: xs) = f x (foldr f e xs)
60
61foldr1 f (x: xs) = foldr f x xs
58 62
59append [] ys = ys 63[] ++ ys = ys
60append (x:xs) ys = x : append xs ys 64x:xs ++ ys = x : xs ++ ys
61 65
62concat = foldl' append [] 66concat = foldr (++) []
63 67
64map _ [] = [] 68map _ [] = []
65map f (x:xs) = f x : map f xs 69map f (x:xs) = f x : map f xs
@@ -80,9 +84,6 @@ sortBy f [] = []
80sortBy f [x] = [x] 84sortBy f [x] = [x]
81sortBy f xs = uncurry (mergeBy f) ((sortBy f *** sortBy f) (split xs)) 85sortBy f xs = uncurry (mergeBy f) ((sortBy f *** sortBy f) (split xs))
82 86
83(++) = append
84infixr 5 ++
85
86iterate :: (a -> a) -> a -> [a] 87iterate :: (a -> a) -> a -> [a]
87iterate f x = x : iterate f (f x) 88iterate f x = x : iterate f (f x)
88 89
@@ -96,9 +97,6 @@ tuptype (x:xs) = '(x, tuptype xs)
96data RecordC (xs :: [(String, Type)]) 97data RecordC (xs :: [(String, Type)])
97 = RecordCons (tuptype (map snd xs)) 98 = RecordCons (tuptype (map snd xs))
98 99
99foldr1 f [x] = x
100foldr1 f (x: xs) = f x (foldr1 f xs)
101
102False ||| x = x 100False ||| x = x
103True ||| x = True 101True ||| x = True
104 102