git @ Cat's Eye Technologies Robin / 4d4cfa7
Rewrite definitions of comparators as functions. Chris Pressey 1 year, 5 months ago
4 changed file(s) with 24 addition(s) and 30 deletion(s). Raw diff Collapse all Expand all
3939 `gt?` expects exactly two arguments, both numbers.
4040
4141 | (gt? 14)
42 ? abort (illegal-arguments (14))
42 ? abort (illegal-arguments
4343
4444 | (gt? 14 23 57)
45 ? abort (illegal-arguments (14 23 57))
45 ? abort (illegal-arguments
4646
4747 | (gt? 14 #t)
4848 ? abort (expected-number #t)
5252
5353 '<<SPEC'
5454
55 (define gt? (fexpr (args env)
56 (bind cmp-same-sign? (fexpr (args env)
57 (bind-args (a b c) args env
58 (equal? (sign (subtract a b)) c)))
59 (bind-args (a b) args env
60 (if (equal? (sign a) (sign b))
61 (cmp-same-sign? a b 1)
62 (cmp-same-sign? (subtract (sign a) 1) (subtract (sign b) 1) 1))))))
55 (define gt? (fun (a b)
56 (bind cmp-same-sign? (fun (a b c)
57 (equal? (sign (subtract a b)) c))
58 (if (equal? (sign a) (sign b))
59 (cmp-same-sign? a b 1)
60 (cmp-same-sign? (subtract (sign a) 1) (subtract (sign b) 1) 1)))))
2424 `gte?` expects exactly two arguments, both numbers.
2525
2626 | (gte? 14)
27 ? abort (illegal-arguments (14))
27 ? abort (illegal-arguments
2828
2929 | (gte? 14 23 57)
30 ? abort (illegal-arguments (14 23 57))
30 ? abort (illegal-arguments
3131
3232 | (gte? 14 #t)
3333 ? abort (expected-number #t)
3737
3838 '<<SPEC'
3939
40 (define gte? (fexpr (args env)
41 (bind-args (a b) args env
42 (if (equal? a b) #t (gt? a b)))))
40 (define gte? (fun (a b)
41 (if (equal? a b) #t (gt? a b))))
3939 `lt?` expects exactly two arguments, both numbers.
4040
4141 | (lt? 14)
42 ? abort (illegal-arguments (14))
42 ? abort (illegal-arguments
4343
4444 | (lt? 14 23 57)
45 ? abort (illegal-arguments (14 23 57))
45 ? abort (illegal-arguments
4646
4747 | (lt? 14 #t)
4848 ? abort (expected-number #t)
5252
5353 '<<SPEC'
5454
55 (define lt? (fexpr (args env)
56 (bind cmp-same-sign? (fexpr (args env)
57 (bind-args (a b c) args env
58 (equal? (sign (subtract a b)) c)))
59 (bind-args (a b) args env
60 (if (equal? (sign a) (sign b))
61 (cmp-same-sign? a b (subtract 0 1))
62 (cmp-same-sign? (subtract (sign a) 1) (subtract (sign b) 1) (subtract 0 1)))))))
55 (define lt? (fun (a b)
56 (bind cmp-same-sign? (fun (a b c)
57 (equal? (sign (subtract a b)) c))
58 (if (equal? (sign a) (sign b))
59 (cmp-same-sign? a b (subtract 0 1))
60 (cmp-same-sign? (subtract (sign a) 1) (subtract (sign b) 1) (subtract 0 1))))))
2424 `lte?` expects exactly two arguments, both numbers.
2525
2626 | (lte? 14)
27 ? abort (illegal-arguments (14))
27 ? abort (illegal-arguments
2828
2929 | (lte? 14 23 57)
30 ? abort (illegal-arguments (14 23 57))
30 ? abort (illegal-arguments
3131
3232 | (lte? 14 #t)
3333 ? abort (expected-number #t)
3737
3838 '<<SPEC'
3939
40 (define lte? (fexpr (args env)
41 (bind-args (a b) args env
42 (if (equal? a b) #t (lt? a b)))))
40 (define lte? (fun (a b)
41 (if (equal? a b) #t (lt? a b))))