This file contains hidden or 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
(defun plus1. (lst) | |
(cond ((null. lst) (cons '1 '())) | |
((eq (car lst) '1) | |
(cons '0 (plus1. (cdr lst)))) | |
('t (cons '1 (cdr lst))))) | |
(defun minus1. (lst) | |
(cond ((null. lst) '()) | |
((and. (null. (cdr lst)) (eq (car lst) '1)) '()) | |
((eq (car lst) '0) |
This file contains hidden or 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
(defun null. (x) | |
(eq x '())) | |
(defun and. (x y) | |
(cond (x | |
(cond (y 't) | |
('t '()))) | |
('t '()))) | |
(defun or. (x y) |
This file contains hidden or 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
(defun fullness. (tree size) | |
(cond ((null. size) | |
'(1)) | |
((null. (cdr tree)) | |
(fullness. (car tree) (minus1. size))) | |
('t (+. (ash+. '(1) (minus1. size)) (fullness. (cdr tree) (minus1. size)))))) | |
(defun length. (glf size) | |
(cond ((null. glf) '()) | |
((or. (null. (cdr glf)) |
This file contains hidden or 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
(defun assoc. (atom a x) | |
(cond ((eq atom (car (g-nth. x a '()))) | |
(cdr (g-nth. x a '()))) | |
('t (assoc. atom a (minus1. x))))) | |
(defun append. (glf1 glf2 x) | |
(cond ((eqnum. x (length. glf2 '())) | |
glf1) | |
('t (append. (g-add. (g-nth. x glf2 '()) glf1 '() (length. glf1 '())) glf2 (plus1. x))))) |
This file contains hidden or 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
(defun eval. (e a) | |
(cond | |
((atom e) (assoc. e a (minus1. (length. a '())))) | |
((atom (car e)) | |
(cond | |
((eq (car e) 'quote) (caadr e)) | |
((eq (car e) 'atom) (atom (eval. (caadr e) a))) | |
((eq (car e) 'eq) (eq (eval. (caadr e) a) | |
(eval. (cdadr e) a))) | |
((eq (car e) 'car) (car (eval. (caadr e) a))) |
This file contains hidden or 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
(defun trellis (&rest args) | |
(if (and (oddp (length args)) (null (car (last args)))) | |
(sentinel-change. (trellis-1 0 args)) | |
(trellis-1 0 args))) | |
(defun trellis-1 (size lst) | |
(cond ((null lst) nil) | |
((= size 0) (cons (car lst) (trellis-1 1 (cdr lst)))) | |
(t (let ((siz (expt 2 size))) | |
(if (> siz (length lst)) |
This file contains hidden or 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
(cond ((eq 'a 'a) 't) | |
('t '())) |
This file contains hidden or 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
(cond (eq 'a 'a) 't | |
't '()) |
This file contains hidden or 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
((label conser (lambda (x) (cons x x))) '1) |
This file contains hidden or 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
> (cdr '(1 2 3)) | |
((2 . 3) . NIL) |
OlderNewer