|
|
@ -1,6 +1,7 @@ |
|
|
|
#!/usr/bin/guile -s |
|
|
|
#!/usr/bin/guile -s |
|
|
|
!# |
|
|
|
!# |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;=============== functions with side effects (I/O) ====================== |
|
|
|
(use-modules (ice-9 rdelim)) |
|
|
|
(use-modules (ice-9 rdelim)) |
|
|
|
|
|
|
|
|
|
|
|
(define (read-lines) |
|
|
|
(define (read-lines) |
|
|
@ -8,17 +9,18 @@ |
|
|
|
(if (eof-object? line) '() (cons line (read-lines)))) |
|
|
|
(if (eof-object? line) '() (cons line (read-lines)))) |
|
|
|
(read-line))) |
|
|
|
(read-line))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define (display-ln value) (list (display value) (display "\n"))) |
|
|
|
|
|
|
|
|
|
|
|
(define (assert-eq error-message expected actual) |
|
|
|
(define (assert-eq error-message expected actual) |
|
|
|
(if (not (equal? expected actual)) |
|
|
|
(if (not (equal? expected actual)) |
|
|
|
(list |
|
|
|
(display-ln (list error-message (list "expected" expected) (list "actual" actual))) |
|
|
|
(display (list error-message (list "expected" expected) (list "actual" actual))) |
|
|
|
|
|
|
|
(display "\n")) |
|
|
|
|
|
|
|
'())) |
|
|
|
'())) |
|
|
|
|
|
|
|
|
|
|
|
(define (tee value) (car (list value (display value) (display "\n")))) |
|
|
|
(define (tee value) (car (list value (display-ln value)))) |
|
|
|
|
|
|
|
;=============== end of functions with side effects ====================== |
|
|
|
|
|
|
|
|
|
|
|
(define (id value) value) |
|
|
|
(define (id value) value) |
|
|
|
(define (is-not value) (lambda (x) (not (= x value)))) |
|
|
|
(define (is-not value) (lambda (x) (not (equal? x value)))) |
|
|
|
(define is-not-empty (lambda (x) (not (null? x)))) |
|
|
|
(define is-not-empty (lambda (x) (not (null? x)))) |
|
|
|
|
|
|
|
|
|
|
|
(define (prepend first-value) (lambda (rest) (cons first-value rest))) |
|
|
|
(define (prepend first-value) (lambda (rest) (cons first-value rest))) |
|
|
|