ref: 6818b86eb85580ed3634afe2a0c97c411022778f
parent: 04e2c93067759dd7376b293a40699e86a16d3262
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Nov 14 12:20:49 EST 2024
test: lambda → λ
--- a/test/color.lsp
+++ b/test/color.lsp
@@ -44,7 +44,7 @@
(not (member
color-of-node
(map
- (lambda (n)
+ (λ (n)
(let ((color-pair (assq n coloring)))
(if (pair? color-pair) (cdr color-pair) ())))
(graph-neighbors g node-to-color)))))
@@ -60,7 +60,7 @@
((node-colorable? g coloring (car uncolored-nodes) color)
(let ((new-coloring
(cons (cons (car uncolored-nodes) color) coloring)))
- (try-each (lambda (c)
+ (try-each (λ (c)
(color-node g new-coloring colors (cdr uncolored-nodes) c))
colors)))))
--- a/test/err.lsp
+++ b/test/err.lsp
@@ -1,4 +1,4 @@
(define (f x) (begin (list-tail '(1) 3) 3))
(f 2)
a
-(trycatch a (lambda (e) (print (stacktrace))))
+(trycatch a (λ (e) (print (stacktrace))))
--- a/test/perf.lsp
+++ b/test/perf.lsp
@@ -9,7 +9,7 @@
(assert (equal? (time (yfib 32)) 2178309))
(princ "sort: ")
-(set! r (map-int (lambda (x) (mod (+ (* x 9421) 12345) 1024)) 1000))
+(set! r (map-int (λ (x) (mod (+ (* x 9421) 12345) 1024)) 1000))
(time (simple-sort r))
(princ "expand: ")
@@ -18,7 +18,7 @@
(define (my-append . lsts)
(cond ((null? lsts) ())
((null? (cdr lsts)) (car lsts))
- (else (letrec ((append2 (lambda (l d)
+ (else (letrec ((append2 (λ (l d)
(if (null? l) d
(cons (car l)
(append2 (cdr l) d))))))
@@ -25,7 +25,7 @@
(append2 (car lsts) (apply my-append (cdr lsts)))))))
(princ "append: ")
-(set! L (map-int (lambda (x) (map-int identity 20)) 20))
+(set! L (map-int (λ (x) (map-int identity 20)) 20))
(time (dotimes (n 1000) (apply my-append L)))
#| FIXME(sigrid): broken
--- a/test/pisum.lsp
+++ b/test/pisum.lsp
@@ -1,7 +1,7 @@
(define (pisum)
(dotimes (j 500)
((label sumloop
- (lambda (i sum)
+ (λ (i sum)
(if (> i 10000)
sum
(sumloop (+ i 1) (+ sum (/ (* i i)))))))
--- a/test/printcases.lsp
+++ b/test/printcases.lsp
@@ -3,7 +3,7 @@
bq-process
(define (syntax-environment)
- (map (lambda (s) (cons s (symbol-syntax s)))
+ (map (λ (s) (cons s (symbol-syntax s)))
(filter symbol-syntax (environment))))
(syntax-environment)
@@ -10,15 +10,15 @@
(symbol-syntax 'try)
-(map-int (lambda (x) `(a b c d e)) 90)
+(map-int (λ (x) `(a b c d e)) 90)
-(list->vector (map-int (lambda (x) `(a b c d e)) 90))
+(list->vector (map-int (λ (x) `(a b c d e)) 90))
-'((lambda (x y) (if (< x y) x y)) (a b c) (d e f) 2 3 (r t y))
+'((λ (x y) (if (< x y) x y)) (a b c) (d e f) 2 3 (r t y))
-'((lambda (x y) (if (< x y) x yffffffffffffffffffff)) (a b c) (d e f) 2 3 (r t y))
+'((λ (x y) (if (< x y) x yffffffffffffffffffff)) (a b c) (d e f) 2 3 (r t y))
-'((lambda (x y) (if (< x y) x y)) (a b c) (d (e zz zzz) f) 2 3 (r t y))
+'((λ (x y) (if (< x y) x y)) (a b c) (d (e zz zzz) f) 2 3 (r t y))
'((23 . a) (9 . a) (22 . b) (17 . d) (14 . d) (8 . b) (21 . e)
(19 . b) (16 . c) (13 . c) (11 . b) (7 . e) (24 . c) (20 . d)
--- a/test/test.lsp
+++ b/test/test.lsp
@@ -8,7 +8,7 @@
`(let (,name) (set! ,name ,f)))
;(define (reverse lst)
-; ((label rev-help (lambda (lst result)
+; ((label rev-help (λ (lst result)
; (if (null? lst) result
; (rev-help (cdr lst) (cons (car lst) result)))))
; lst ()))
@@ -15,10 +15,10 @@
(define (append- . lsts)
((label append-h
- (lambda (lsts)
+ (λ (lsts)
(cond ((null? lsts) ())
((null? (cdr lsts)) (car lsts))
- (#t ((label append2 (lambda (l d)
+ (#t ((label append2 (λ (l d)
(if (null? l) d
(cons (car l)
(append2 (cdr l) d)))))
@@ -26,10 +26,10 @@
lsts))
;(princ 'Hello '| | 'world! "\n")
-;(filter (lambda (x) (not (< x 0))) '(1 -1 -2 5 10 -8 0))
+;(filter (λ (x) (not (< x 0))) '(1 -1 -2 5 10 -8 0))
(define (fib n) (if (< n 2) n (+ (fib (- n 1)) (fib (- n 2)))))
;(princ (time (fib 34)) "\n")
-;(dotimes (i 20000) (map-int (lambda (x) (list 'quote x)) 8))
+;(dotimes (i 20000) (map-int (λ (x) (list 'quote x)) 8))
;(dotimes (i 40000) (append '(a b) '(1 2 3 4) () '(c) () '(5 6)))
;(dotimes (i 80000) (list 1 2 3 4 5))
;(set! a (map-int identity 10000))
@@ -50,7 +50,7 @@
()
(let ((first (cons (f 0) ())))
((label map-int-
- (lambda (acc i n)
+ (λ (acc i n)
(if (= i n)
first
(begin (set-cdr! acc (cons (f i) ()))
@@ -59,7 +59,7 @@
|#
(define-macro (labl name fn)
- `((lambda (,name) (set! ,name ,fn)) ()))
+ `((λ (,name) (set! ,name ,fn)) ()))
(define (square x) (* x x))
(define (expt b p)
@@ -89,7 +89,7 @@
(define (mapl f . lsts)
((label mapl-
- (lambda (lsts)
+ (λ (lsts)
(if (null? (car lsts)) ()
(begin (apply f lsts) (mapl- (map cdr lsts))))))
lsts))
@@ -105,7 +105,7 @@
(set-car! c (swapad (cdr c)))))))
(define (without x l)
- (filter (lambda (e) (not (eq e x))) l))
+ (filter (λ (e) (not (eq e x))) l))
(define (conscount c)
(if (pair? c) (+ 1
@@ -123,7 +123,7 @@
; |
(define-macro (while- test . forms)
- `((label -loop- (lambda ()
+ `((label -loop- (λ ()
(if ,test
(begin ,@forms
(-loop-))
@@ -142,11 +142,11 @@
(body (foldr
; create a function to check for and handle one exception
; type, and pass off control to the next when no match
- (lambda (catc next)
+ (λ (catc next)
(let ((var (cadr (cadr catc)))
(extype (caadr catc))
(todo (f-body (cddr catc))))
- `(lambda (,var)
+ `(λ (,var)
(if (or (eq ,var ',extype)
(and (pair? ,var)
(eq (car ,var) ',extype)))
@@ -154,24 +154,24 @@
(,next ,var)))))
; default function; no matches so re-raise
- '(lambda (e) (begin (*_try_finally_thunk_*) (raise e)))
+ '(λ (e) (begin (*_try_finally_thunk_*) (raise e)))
; make list of catch forms
- (filter (lambda (f) (eq (car f) 'catch)) forms))))
- `(let ((*_try_finally_thunk_* (lambda () ,final)))
+ (filter (λ (f) (eq (car f) 'catch)) forms))))
+ `(let ((*_try_finally_thunk_* (λ () ,final)))
(prog1 (attempt ,expr ,body)
(*_try_finally_thunk_*)))))
(define Y
- (lambda (f)
- ((lambda (h)
- (f (lambda (x) ((h h) x))))
- (lambda (h)
- (f (lambda (x) ((h h) x)))))))
+ (λ (f)
+ ((λ (h)
+ (f (λ (x) ((h h) x))))
+ (λ (h)
+ (f (λ (x) ((h h) x)))))))
(define yfib
- (Y (lambda (fib)
- (lambda (n)
+ (Y (λ (fib)
+ (λ (n)
(if (< n 2) n (+ (fib (- n 1)) (fib (- n 2))))))))
;(defun tt () (time (dotimes (i 500000) (* 0x1fffffff 1) )))
@@ -195,7 +195,7 @@
(cdr
(prog1 ,acc
(for ,lo ,hi
- (lambda (,var)
+ (λ (,var)
(begin (set! ,acc
(cdr (set-cdr! ,acc (cons ,what ()))))
,@body))))))))
@@ -209,11 +209,11 @@
(let ((*profiles* (table)))
(set! profile
- (lambda (s)
+ (λ (s)
(let ((f (top-level-value s)))
(put! *profiles* s (cons 0 0))
(set-top-level-value! s
- (lambda args
+ (λ args
(define tt (get *profiles* s))
(define count (car tt))
(define time (cdr tt))
@@ -223,12 +223,12 @@
(set-car! tt (+ count 1))
v)))))
(set! show-profiles
- (lambda ()
- (define pr (filter (lambda (x) (> (cadr x) 0))
+ (λ ()
+ (define pr (filter (λ (x) (> (cadr x) 0))
(table-pairs *profiles*)))
(define width (+ 4
(apply max
- (map (lambda (x)
+ (map (λ (x)
(length (string x)))
(cons 'Function
(map car pr))))))
@@ -239,16 +239,16 @@
"------ --------------")
(newline)
(for-each
- (lambda (p)
+ (λ (p)
(princ (string-rpad (string (caddr p)) width #\ )
(string-rpad (string (cadr p)) 11 #\ )
(car p))
(newline))
- (simple-sort (map (lambda (l) (reverse (to-proper l)))
+ (simple-sort (map (λ (l) (reverse (to-proper l)))
pr)))))
(set! clear-profiles
- (lambda ()
- (for-each (lambda (k)
+ (λ ()
+ (for-each (λ (k)
(put! *profiles* k (cons 0 0)))
(table-keys *profiles*)))))
--- a/test/torture.scm
+++ b/test/torture.scm
@@ -1,4 +1,4 @@
-(define ones (map (lambda (x) 1) (iota 1000000)))
+(define ones (map (λ (x) 1) (iota 1000000)))
(write (apply + ones))
(newline)
--- a/test/unittest.lsp
+++ b/test/unittest.lsp
@@ -1,8 +1,8 @@
; -*- scheme -*-
(define-macro (assert-fail expr . what)
`(assert (trycatch (begin ,expr #f)
- (lambda (e) ,(if (null? what) #t
- `(eq? (car e) ',(car what)))))))
+ (λ (e) ,(if (null? what) #t
+ `(eq? (car e) ',(car what)))))))
(define (every-int n)
(list (fixnum n) (int8 n) (uint8 n) (int16 n) (uint16 n) (int32 n) (uint32 n)
@@ -17,10 +17,10 @@
(each f (cdr l)))))
(define (each^2 f l m)
- (each (lambda (o) (each (lambda (p) (f o p)) m)) l))
+ (each (λ (o) (each (λ (p) (f o p)) m)) l))
(define (test-lt a b)
- (each^2 (lambda (neg pos)
+ (each^2 (λ (neg pos)
(begin
(eval `(assert (= -1 (compare ,neg ,pos))))
(eval `(assert (= 1 (compare ,pos ,neg))))))
@@ -28,7 +28,7 @@
b))
(define (test-eq a b)
- (each^2 (lambda (a b)
+ (each^2 (λ (a b)
(begin
(eval `(assert (= 0 (compare ,a ,b))))))
a
@@ -40,7 +40,7 @@
(test-eq (every-sint -88) (every-sint -88))
(define (test-square a)
- (each (lambda (i) (eval `(assert (>= (* ,i ,i) 0))))
+ (each (λ (i) (eval `(assert (>= (* ,i ,i) 0))))
a))
(test-square (every-sint -67))
@@ -158,18 +158,18 @@
(assert (= 0.0 -0.0))
; this crashed once
-(for 1 10 (lambda (i) 0))
+(for 1 10 (λ (i) 0))
; failing applications
-(assert-fail ((lambda (x) x) 1 2))
-(assert-fail ((lambda (x) x)))
-(assert-fail ((lambda (x y . z) z) 1))
+(assert-fail ((λ (x) x) 1 2))
+(assert-fail ((λ (x) x)))
+(assert-fail ((λ (x y . z) z) 1))
(assert-fail (car 'x) type-error)
(assert-fail gjegherqpfdf___trejif unbound-error)
; long argument lists
(assert (= (apply + (iota 100000)) 4999950000))
-(define ones (map (lambda (x) 1) (iota 80000)))
+(define ones (map (λ (x) 1) (iota 80000)))
(assert (= (eval `(if (< 2 1)
(+ ,@ones)
(+ ,@(cdr ones))))
@@ -177,47 +177,47 @@
(define MAX_ARGS 255)
-(define as (apply list* (map-int (lambda (x) (gensym)) (+ MAX_ARGS 1))))
-(define f (compile `(lambda ,as ,(lastcdr as))))
+(define as (apply list* (map-int (λ (x) (gensym)) (+ MAX_ARGS 1))))
+(define f (compile `(λ ,as ,(lastcdr as))))
(assert (equal? (apply f (iota (+ MAX_ARGS 0))) `()))
(assert (equal? (apply f (iota (+ MAX_ARGS 1))) `(,MAX_ARGS)))
(assert (equal? (apply f (iota (+ MAX_ARGS 2))) `(,MAX_ARGS ,(+ MAX_ARGS 1))))
-(define as (apply list* (map-int (lambda (x) (gensym)) (+ MAX_ARGS 100))))
-(define ff (compile `(lambda ,as (set! ,(car (last-pair as)) 42)
- ,(car (last-pair as)))))
+(define as (apply list* (map-int (λ (x) (gensym)) (+ MAX_ARGS 100))))
+(define ff (compile `(λ ,as (set! ,(car (last-pair as)) 42)
+ ,(car (last-pair as)))))
(assert (equal? (apply ff (iota (+ MAX_ARGS 100))) 42))
-(define ff (compile `(lambda ,as (set! ,(car (last-pair as)) 42)
- (lambda () ,(car (last-pair as))))))
+(define ff (compile `(λ ,as (set! ,(car (last-pair as)) 42)
+ (λ () ,(car (last-pair as))))))
(assert (equal? ((apply ff (iota (+ MAX_ARGS 100)))) 42))
-(define as (map-int (lambda (x) (gensym)) 1000))
-(define f (compile `(lambda ,as ,(car (last-pair as)))))
+(define as (map-int (λ (x) (gensym)) 1000))
+(define f (compile `(λ ,as ,(car (last-pair as)))))
(assert (equal? (apply f (iota 1000)) 999))
-(define as (apply list* (map-int (lambda (x) (gensym)) 995)))
-(define f (compile `(lambda ,as ,(lastcdr as))))
+(define as (apply list* (map-int (λ (x) (gensym)) 995)))
+(define f (compile `(λ ,as ,(lastcdr as))))
(assert (equal? (apply f (iota 994)) '()))
(assert (equal? (apply f (iota 995)) '(994)))
(assert (equal? (apply f (iota 1000)) '(994 995 996 997 998 999)))
; optional arguments
-(assert (equal? ((lambda ((b 0)) b)) 0))
-(assert (equal? ((lambda (a (b 2)) (list a b)) 1) '(1 2)))
-(assert (equal? ((lambda (a (b 2)) (list a b)) 1 3) '(1 3)))
-(assert (equal? ((lambda (a (b 2) (c 3)) (list a b c)) 1) '(1 2 3)))
-(assert (equal? ((lambda (a (b 2) (c 3)) (list a b c)) 1 8) '(1 8 3)))
-(assert (equal? ((lambda (a (b 2) (c 3)) (list a b c)) 1 8 9) '(1 8 9)))
-(assert (equal? ((lambda ((x 0) . r) (list x r))) '(0 ())))
-(assert (equal? ((lambda ((x 0) . r) (list x r)) 1 2 3) '(1 (2 3))))
+(assert (equal? ((λ ((b 0)) b)) 0))
+(assert (equal? ((λ (a (b 2)) (list a b)) 1) '(1 2)))
+(assert (equal? ((λ (a (b 2)) (list a b)) 1 3) '(1 3)))
+(assert (equal? ((λ (a (b 2) (c 3)) (list a b c)) 1) '(1 2 3)))
+(assert (equal? ((λ (a (b 2) (c 3)) (list a b c)) 1 8) '(1 8 3)))
+(assert (equal? ((λ (a (b 2) (c 3)) (list a b c)) 1 8 9) '(1 8 9)))
+(assert (equal? ((λ ((x 0) . r) (list x r))) '(0 ())))
+(assert (equal? ((λ ((x 0) . r) (list x r)) 1 2 3) '(1 (2 3))))
; keyword arguments
(assert (keyword? kw:))
(assert (not (keyword? 'kw)))
(assert (not (keyword? ':)))
-(assert (equal? ((lambda (x (a 2) (b: a) . r) (list x a b r)) 1 0 8 4 5)
+(assert (equal? ((λ (x (a 2) (b: a) . r) (list x a b r)) 1 0 8 4 5)
'(1 0 0 (8 4 5))))
-(assert (equal? ((lambda (x (a 2) (b: a) . r) (list x a b r)) 0 b: 3 1)
+(assert (equal? ((λ (x (a 2) (b: a) . r) (list x a b r)) 0 b: 3 1)
'(0 2 3 (1))))
(define (keys4 (a: 8) (b: 3) (c: 7) (d: 6)) (list a b c d))
(assert (equal? (keys4 a: 10) '(10 3 7 6)))
@@ -341,7 +341,7 @@
(iostream->string b)))
(let ((c #\a))
- (assert (equal? (with-output-to-string #f (lambda () (print (list c c))))
+ (assert (equal? (with-output-to-string #f (λ () (print (list c c))))
"(#\\a #\\a)")))
(assert-fail (eval '(set! (car (cons 1 2)) 3)))
--- a/test/wt.lsp
+++ b/test/wt.lsp
@@ -1,5 +1,5 @@
(define-macro (while- test . forms)
- `((label -loop- (lambda ()
+ `((label -loop- (λ ()
(if ,test
(begin ,@forms
(-loop-))
@@ -10,7 +10,7 @@
(while (< i 10000000) (set! i (+ i 1))))
(define (tw2)
- (letrec ((loop (lambda ()
+ (letrec ((loop (λ ()
(if (< i 10000000)
(begin (set! i (+ i 1))
(loop))