Skip to content

Commit 23a6718

Browse files
authored
Merge pull request #73 from JohanWiltink/main
unused bindings optimisations
2 parents 0a92f51 + c538e7e commit 23a6718

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

tests/basics-binary-scott/solution.txt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,28 @@ Z = \ f . ( \ x . f \ y . x x y ) ( \ x . f \ y . x x y )
1717

1818
#import Boolean.lc
1919

20-
False = \ f t . f
21-
True = \ f t . t
20+
False = \ f _t . f
21+
True = \ _f t . t
2222

23-
not = \ p . p True False
23+
not = \ p . \ f t . p t f
2424

2525
and = \ p . p p
2626
or = \ p q . p q p
2727
xor = \ p q . p q (not q)
28-
implies = \ p . p (True)
28+
implies = \ p . p True
2929

3030
#import Ordering.lc
3131

32-
LT = \ lt eq gt . lt
33-
EQ = \ lt eq gt . eq
34-
GT = \ lt eq gt . gt
32+
LT = \ lt _eq _gt . lt
33+
EQ = \ _lt eq _gt . eq
34+
GT = \ _lt _eq gt . gt
3535

3636
#import Pair.lc
3737

3838
Pair = \ x y fn . fn x y
3939

40-
fst = \ xy . xy \ x _ . x
41-
snd = \ xy . xy \ _ y . y
40+
fst = \ xy . xy \ x _y . x
41+
snd = \ xy . xy \ _x y . y
4242

4343
first = \ fn xy . xy \ x . Pair (fn x)
4444
second = \ fn xy . xy \ x y . Pair x (fn y)
@@ -48,11 +48,11 @@ curry = \ fn xy . xy fn
4848

4949
# data Number = End | Even Number | Odd Number
5050

51-
zero = \ end even odd . end
51+
zero = \ end _even _odd . end
5252

53-
shiftR0 = \ n . \ end even odd . even n # mind that a shiftR in LE is a multiplication
54-
shiftR1 = \ n . \ end even odd . odd n # mind that a shiftR in LE is a multiplication
55-
shiftL = \ n . n n I I # mind that a shiftL in LE is a division
53+
shiftR0 = \ n . \ _end even _odd . even n # mind that a shiftR in LE is a multiplication
54+
shiftR1 = \ n . \ _end _even odd . odd n # mind that a shiftR in LE is a multiplication
55+
shiftL = \ n . n n I I # mind that a shiftL in LE is a division
5656

5757
isStrictZero = \ n . n True (K False) (K False) # disallow padding zeroes # O(1)
5858
isZero = \ n . n True isZero (K False) # allow padding zeroes # amortised O(2), so don't worry too much

tests/is-prime-scott/solution.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ B = \ f g x . f (g x)
44
I = \ x . x
55
K = \ x _ . x
66
Y = \ f . ( \ x . f (x x) ) ( \ x . f (x x) )
7-
True = \ t f . t
8-
False = \ t f . f
9-
Succ = \ n z s . s n
7+
True = \ t _f . t
8+
False = \ _t f . f
9+
Succ = \ n _z s . s n
1010
Pred = \ n . n 0 I
1111
Plus = \ m n . m n (B Succ (Plus n))
1212
Minus = \ m n . m 0 (B (n m) Minus)

tests/is-prime/solution.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# JohanWiltink
22

33
Y = \ f . ( \ x . f (x x) ) ( \ x . f (x x) )
4-
True = \ t f . t
5-
False = \ t f . f
4+
True = \ t _f . t
5+
False = \ _t f . f
66
Succ = \ n s z . s (n s z)
77
Pred = \ n s z . n ( \ f g . g (f s) ) (\_.z) \x.x
88
Minus = \ m n . n Pred m

tests/prime-sieve/solution.txt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ Z = \ f . ( \ x . f \ y . x x y ) ( \ x . f \ y . x x y )
2020

2121
#import Ordering.lc
2222

23-
LT = \ lt eq gt . lt
24-
EQ = \ lt eq gt . eq
25-
GT = \ lt eq gt . gt
23+
LT = \ lt _eq _gt . lt
24+
EQ = \ _lt eq _gt . eq
25+
GT = \ _lt _eq gt . gt
2626

2727
# import Booleans.lc
2828

29-
False = \ false true . false
30-
True = \ false true . true
29+
False = \ false _true . false
30+
True = \ _false true . true
3131

3232
# data Number = End | Even Number | Odd Number
3333

3434
# zero :: Int
35-
zero = \ end even odd . end
35+
zero = \ end _even _odd . end
3636

3737
# shiftR0,shiftR1 :: Int -> Int
38-
shiftR0 = \ n . \ end even odd . even n # mind that a shiftR in LE is a multiplication
39-
shiftR1 = \ n . \ end even odd . odd n # mind that a shiftR in LE is a multiplication
38+
shiftR0 = \ n . \ _end even _odd . even n # mind that a shiftR in LE is a multiplication
39+
shiftR1 = \ n . \ _end _even odd . odd n # mind that a shiftR in LE is a multiplication
4040

4141
# isZero :: Int -> Bool
4242
isZero = \ n . n True (K False) (K False)
@@ -84,21 +84,21 @@ minus = \ m n . gt m n zero (unpad (unsafeMinus m n)) # needs explicit unpad or
8484
pair = \ x y . \ pair . pair x y
8585

8686
# fst :: Pair a b -> a
87-
fst = \ xy . xy ( \ x y . x )
87+
fst = \ xy . xy ( \ x _y . x )
8888

8989
# snd :: Pair a b -> b
90-
snd = \ xy . xy ( \ x y . y )
90+
snd = \ xy . xy ( \ _x y . y )
9191

9292
# data Stream a :: Cons a (Stream a)
9393

9494
# cons :: a -> Stream a -> Stream a
9595
cons = \ x xs . \ cons . cons x xs
9696

9797
# head :: Stream a -> a
98-
head = \ xs . xs ( \ x xs . x )
98+
head = \ xs . xs ( \ x _xs . x )
9999

100100
# tail :: Stream a -> Stream a
101-
tail = \ xs . xs ( \ x xs . xs )
101+
tail = \ xs . xs ( \ _x xs . xs )
102102

103103
# map :: (a -> b) -> Stream a -> Stream b
104104
map = \ fn xs . xs ( \ x xs . cons (fn x) (map fn xs) )
@@ -112,10 +112,10 @@ le = \ m n . compare (head m) (head n) True True False
112112
# data Set a = Nil | Branch a (Set a) (Set a)
113113

114114
# empty :: Set a
115-
empty = \ nil branch . nil
115+
empty = \ nil _branch . nil
116116

117117
# branch :: a -> Set a -> Set a -> Set a
118-
branch = \ x left right . \ nil branch . branch x left right
118+
branch = \ x left right . \ _nil branch . branch x left right
119119

120120
# insert :: (Ord a) => a -> Set a -> Set a
121121
insert = \ x set .
@@ -129,7 +129,7 @@ insert = \ x set .
129129

130130
# findMin :: (Partial) => Set a -> a
131131
findMin = \ set . set ()
132-
\ x left right .
132+
\ x left _right .
133133
left x ( \ _ _ _ . findMin left )
134134

135135
# minView :: (Partial) => Set a -> (a,Set a)

0 commit comments

Comments
 (0)