This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (grand scheme)) ;; https://github.com/plande/grand-scheme | |
(define ((in? l) x) | |
(match l | |
((h . t) | |
(or (eq? x h) | |
((in? t) x))) | |
(_ | |
#f))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (passing-arguments arguments names final) | |
(assert (= (length arguments) (length names))) | |
(match arguments | |
(() | |
(assert (null? names)) | |
final) | |
((argument . next) | |
(let (((name . names) names)) | |
(if (compound? argument) | |
(passing-arguments next names |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (grand scheme)) | |
(define (all-the-same? xs) | |
(match xs | |
[(x x) #t] | |
[(x x . xs*) (all-the-same? `(,x . ,xs*))] | |
[_ #f])) | |
(e.g. (all-the-same? '(1 1 1))) | |
(e.g. (not (all-the-same? '(1 1 2)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define old-lisp-program " | |
DEFINE (( | |
(THEOREM (LAMBDA (S) (TH1 NIL NIL (CADR S) (CADDR S)))) | |
(TH1 (LAMBDA (A1 A2 A C) (COND ((NULL A) | |
(TH2 A1 A2 NIL NIL C)) (T | |
(OR (MEMBER (CAR A) C) (COND ((ATOM (CAR A)) | |
(TH1 (COND ((MEMBER (CAR A) A1) A1) | |
(T (CONS (CAR A) A1))) A2 (CDR A) C)) | |
(T (TH1 A1 (COND ((MEMBER (CAR A) A2) A2) |