commit 9e999549bb430394315774765172dbc6aac3ddda parent 3f494dfbb1b0e529b3a55332e31eb293edfaaa5f Author: Ed van Bruggen <edvb@uw.edu> Date: Thu, 21 Feb 2019 19:56:37 -0800 Add tisp standard library Diffstat:
tibs/lib.tsp | | | 64 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 64 insertions(+), 0 deletions(-)
diff --git a/tibs/lib.tsp b/tibs/lib.tsp @@ -0,0 +1,64 @@ +(define (caar x) (car (car x))) +(define (cadr x) (car (cdr x))) +(define (cdar x) (cdr (car x))) +(define (cddr x) (cdr (cdr x))) +(define (caaar x) (car (car (car x)))) +(define (caadr x) (car (car (cdr x)))) +(define (cadar x) (car (cdr (car x)))) +(define (caddr x) (car (cdr (cdr x)))) +(define (cdaar x) (cdr (car (car x)))) +(define (cdadr x) (cdr (car (cdr x)))) +(define (cddar x) (cdr (cdr (car x)))) +(define (cdddr x) (cdr (cdr (cdr x)))) +(define (caaaar x) (car (car (car (car x))))) +(define (caaadr x) (car (car (car (cdr x))))) +(define (caadar x) (car (car (cdr (car x))))) +(define (caaddr x) (car (car (cdr (cdr x))))) +(define (cadaar x) (car (cdr (car (car x))))) +(define (cadadr x) (car (cdr (car (cdr x))))) +(define (caddar x) (car (cdr (cdr (car x))))) +(define (cadddr x) (car (cdr (cdr (cdr x))))) +(define (cdaaar x) (cdr (car (car (car x))))) +(define (cdaadr x) (cdr (car (car (cdr x))))) +(define (cdadar x) (cdr (car (cdr (car x))))) +(define (cdaddr x) (cdr (car (cdr (cdr x))))) +(define (cddaar x) (cdr (cdr (car (car x))))) +(define (cddadr x) (cdr (cdr (car (cdr x))))) +(define (cdddar x) (cdr (cdr (cdr (car x))))) +(define (cddddr x) (cdr (cdr (cdr (cdr x))))) + +(define (void? x) + (cond ((= (type x) "void") t) + (t ()))) +(define (nil? x) + (cond ((= (type x) "nil") t) + (t ()))) +(define (integer? x) + (cond ((= (type x) "integer") t) + (t ()))) +(define (decimal? x) + (cond ((= (type x) "decimal") t) + (t ()))) +(define (ratio? x) + (cond ((= (type x) "ratio") t) + (t ()))) +(define (string? x) + (cond ((= (type x) "string") t) + (t ()))) +(define (symbol? x) + (cond ((= (type x) "symbol") t) + (t ()))) +(define (primitive? x) + (cond ((= (type x) "primitive") t) + (t ()))) +(define (function? x) + (cond ((= (type x) "function") t) + (t ()))) +(define (pair? x) + (cond ((= (type x) "pair") t) + (t ()))) + +(define (not x) + (cond (x ()) (t t))) + +(define (disp x) (print x (newline)))