switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
; -*- scheme -*-
|
2008-06-30 21:54:22 -04:00
|
|
|
|
; femtoLisp standard library
|
2009-01-04 21:45:21 -05:00
|
|
|
|
; by Jeff Bezanson (C) 2009
|
2008-08-29 22:56:46 -04:00
|
|
|
|
; Distributed under the BSD License
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(set-constant! 'eq eq?)
|
|
|
|
|
(set-constant! 'eqv eqv?)
|
|
|
|
|
(set-constant! 'equal equal?)
|
|
|
|
|
(set-constant! 'rplaca set-car!)
|
|
|
|
|
(set-constant! 'rplacd set-cdr!)
|
|
|
|
|
(set-constant! 'char? (lambda (x) (eq? (typeof x) 'wchar)))
|
|
|
|
|
|
2008-06-30 21:54:22 -04:00
|
|
|
|
; convert a sequence of body statements to a single expression.
|
|
|
|
|
; this allows define, defun, defmacro, let, etc. to contain multiple
|
|
|
|
|
; body expressions as in Common Lisp.
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(set! f-body (lambda (e)
|
2009-02-08 22:22:31 -05:00
|
|
|
|
(cond ((atom? e) #f)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
((eq (cdr e) ()) (car e))
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(#t (cons 'begin e)))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(set-syntax! 'define-macro
|
|
|
|
|
(lambda (form . body)
|
|
|
|
|
(list 'set-syntax! (list 'quote (car form))
|
|
|
|
|
(list 'lambda (cdr form) (f-body body)))))
|
2008-07-14 21:20:52 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define-macro (label name fn)
|
|
|
|
|
(list (list 'lambda (list name) (list 'set! name fn)) #f))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define-macro (define form . body)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(if (symbol? form)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(list 'set! form (car body))
|
|
|
|
|
(list 'set! (car form) (list 'lambda (cdr form) (f-body body)))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (set s v) (eval (list 'set! s (list 'quote v))))
|
2008-09-06 18:19:51 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (identity x) x)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (map f lst)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(if (atom? lst) lst
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(cons (f (car lst)) (map f (cdr lst)))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define-macro (let binds . body)
|
2009-02-05 22:41:24 -05:00
|
|
|
|
((lambda (lname)
|
|
|
|
|
(begin
|
|
|
|
|
(if (symbol? binds)
|
|
|
|
|
(begin (set! lname binds)
|
|
|
|
|
(set! binds (car body))
|
|
|
|
|
(set! body (cdr body))))
|
|
|
|
|
((lambda (thelambda theargs)
|
|
|
|
|
(cons (if lname
|
|
|
|
|
(list 'label lname thelambda)
|
|
|
|
|
thelambda)
|
|
|
|
|
theargs))
|
|
|
|
|
(list 'lambda
|
|
|
|
|
(map (lambda (c) (if (pair? c) (car c) c)) binds)
|
|
|
|
|
(f-body body))
|
|
|
|
|
(map (lambda (c) (if (pair? c) (cadr c) #f)) binds))))
|
|
|
|
|
#f))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (nconc . lsts)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(cond ((null? lsts) ())
|
|
|
|
|
((null? (cdr lsts)) (car lsts))
|
|
|
|
|
((null? (car lsts)) (apply nconc (cdr lsts)))
|
|
|
|
|
(#t (prog1 (car lsts)
|
|
|
|
|
(rplacd (last (car lsts))
|
|
|
|
|
(apply nconc (cdr lsts)))))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (append . lsts)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(cond ((null? lsts) ())
|
|
|
|
|
((null? (cdr lsts)) (car lsts))
|
|
|
|
|
(#t ((label append2 (lambda (l d)
|
|
|
|
|
(if (null? l) d
|
|
|
|
|
(cons (car l)
|
|
|
|
|
(append2 (cdr l) d)))))
|
|
|
|
|
(car lsts) (apply append (cdr lsts))))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (member item lst)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(cond ((atom? lst) #f)
|
|
|
|
|
((equal (car lst) item) lst)
|
|
|
|
|
(#t (member item (cdr lst)))))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (memq item lst)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(cond ((atom? lst) #f)
|
|
|
|
|
((eq (car lst) item) lst)
|
|
|
|
|
(#t (memq item (cdr lst)))))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (memv item lst)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(cond ((atom? lst) #f)
|
|
|
|
|
((eqv (car lst) item) lst)
|
|
|
|
|
(#t (memv item (cdr lst)))))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
|
|
|
|
|
(define (assoc item lst)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(cond ((atom? lst) #f)
|
|
|
|
|
((equal (caar lst) item) (car lst))
|
|
|
|
|
(#t (assoc item (cdr lst)))))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (assv item lst)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(cond ((atom? lst) #f)
|
|
|
|
|
((eqv (caar lst) item) (car lst))
|
|
|
|
|
(#t (assv item (cdr lst)))))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(define (macrocall? e) (and (symbol? (car e))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(symbol-syntax (car e))))
|
|
|
|
|
|
|
|
|
|
(define (function? x)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(or (builtin? x)
|
|
|
|
|
(and (pair? x) (eq (car x) 'lambda))))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define procedure? function?)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (macroexpand-1 e)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(if (atom? e) e
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(let ((f (macrocall? e)))
|
|
|
|
|
(if f (apply f (cdr e))
|
|
|
|
|
e))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
|
|
|
|
; convert to proper list, i.e. remove "dots", and append
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (append.2 l tail)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(cond ((null? l) tail)
|
|
|
|
|
((atom? l) (cons l tail))
|
|
|
|
|
(#t (cons (car l) (append.2 (cdr l) tail)))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
|
|
|
|
(define (cadr x) (car (cdr x)))
|
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
;(set! *special-forms* '(quote cond if and or while lambda trycatch
|
|
|
|
|
; set! begin))
|
2008-07-11 22:58:55 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (macroexpand e)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
((label mexpand
|
|
|
|
|
(lambda (e env f)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(begin
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(while (and (pair? e)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(not (member (car e) env))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(set! f (macrocall? e)))
|
|
|
|
|
(set! e (apply f (cdr e))))
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(cond ((and (pair? e)
|
2008-07-11 22:58:55 -04:00
|
|
|
|
(not (eq (car e) 'quote)))
|
|
|
|
|
(let ((newenv
|
2008-12-23 23:43:36 -05:00
|
|
|
|
(if (and (eq (car e) 'lambda)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(pair? (cdr e)))
|
2008-07-11 22:58:55 -04:00
|
|
|
|
(append.2 (cadr e) env)
|
|
|
|
|
env)))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(map (lambda (x) (mexpand x newenv ())) e)))
|
2009-01-31 20:53:58 -05:00
|
|
|
|
;((and (symbol? e) (constant? e)) (eval e))
|
|
|
|
|
;((and (symbol? e)
|
2008-07-11 22:58:55 -04:00
|
|
|
|
; (not (member e *special-forms*))
|
|
|
|
|
; (not (member e env))) (cons '%top e))
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(#t e)))))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
e () ()))
|
|
|
|
|
|
|
|
|
|
(define-macro (define form . body)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(if (symbol? form)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(list 'set! form (car body))
|
|
|
|
|
(list 'set! (car form)
|
|
|
|
|
(macroexpand (list 'lambda (cdr form) (f-body body))))))
|
|
|
|
|
(define-macro (define-macro form . body)
|
|
|
|
|
(list 'set-syntax! (list 'quote (car form))
|
|
|
|
|
(macroexpand (list 'lambda (cdr form) (f-body body)))))
|
|
|
|
|
(define macroexpand (macroexpand macroexpand))
|
|
|
|
|
|
2009-02-05 22:41:24 -05:00
|
|
|
|
(define = eqv)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define eql eqv)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(define (/= a b) (not (equal a b)))
|
|
|
|
|
(define != /=)
|
|
|
|
|
(define (> a b) (< b a))
|
|
|
|
|
(define (<= a b) (not (< b a)))
|
|
|
|
|
(define (>= a b) (not (< a b)))
|
|
|
|
|
(define (1+ n) (+ n 1))
|
|
|
|
|
(define (1- n) (- n 1))
|
|
|
|
|
(define (mod x y) (- x (* (/ x y) y)))
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(define remainder mod)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(define (abs x) (if (< x 0) (- x) x))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define K prog1) ; K combinator ;)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
|
|
|
|
(define (caar x) (car (car 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))))
|
2008-12-28 03:01:18 -05:00
|
|
|
|
(define (cadddr x) (car (cdr (cdr (cdr x)))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(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))))
|
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (every pred lst)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(or (atom? lst)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(and (pred (car lst))
|
|
|
|
|
(every pred (cdr lst)))))
|
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (any pred lst)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(and (pair? lst)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(or (pred (car lst))
|
|
|
|
|
(any pred (cdr lst)))))
|
|
|
|
|
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(define (listp a) (or (null? a) (pair? a)))
|
|
|
|
|
(define (list? a) (or (null? a) (and (pair? a) (list? (cdr a)))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (nthcdr lst n)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(if (<= n 0) lst
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(nthcdr (cdr lst) (- n 1))))
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(define list-tail nthcdr)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (list-ref lst n)
|
2009-01-04 21:45:21 -05:00
|
|
|
|
(car (nthcdr lst n)))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (list* . l)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(if (atom? (cdr l))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(car l)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(cons (car l) (apply list* (cdr l)))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (nlist* . l)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(if (atom? (cdr l))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(car l)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(rplacd l (apply nlist* (cdr l)))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (lastcdr l)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(if (atom? l) l
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(lastcdr (cdr l))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (last l)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(cond ((atom? l) l)
|
|
|
|
|
((atom? (cdr l)) l)
|
|
|
|
|
(#t (last (cdr l)))))
|
|
|
|
|
(define last-pair last)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (map! f lst)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(prog1 lst
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(while (pair? lst)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(rplaca lst (f (car lst)))
|
|
|
|
|
(set! lst (cdr lst)))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (mapcar f . lsts)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
((label mapcar-
|
|
|
|
|
(lambda (lsts)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(cond ((null? lsts) (f))
|
|
|
|
|
((atom? (car lsts)) (car lsts))
|
|
|
|
|
(#t (cons (apply f (map car lsts))
|
|
|
|
|
(mapcar- (map cdr lsts)))))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
lsts))
|
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (transpose M) (apply mapcar (cons list M)))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (filter pred lst) (filter- pred lst ()))
|
|
|
|
|
(define (filter- pred lst accum)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(cond ((null? lst) accum)
|
2008-11-05 23:04:04 -05:00
|
|
|
|
((pred (car lst))
|
|
|
|
|
(filter- pred (cdr lst) (cons (car lst) accum)))
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(#t
|
2008-11-05 23:04:04 -05:00
|
|
|
|
(filter- pred (cdr lst) accum))))
|
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (separate pred lst) (separate- pred lst () ()))
|
|
|
|
|
(define (separate- pred lst yes no)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(cond ((null? lst) (cons yes no))
|
2008-11-05 23:04:04 -05:00
|
|
|
|
((pred (car lst))
|
|
|
|
|
(separate- pred (cdr lst) (cons (car lst) yes) no))
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(#t
|
2008-11-05 23:04:04 -05:00
|
|
|
|
(separate- pred (cdr lst) yes (cons (car lst) no)))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
|
|
|
|
(define (foldr f zero lst)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(if (null? lst) zero
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(f (car lst) (foldr f zero (cdr lst)))))
|
|
|
|
|
|
|
|
|
|
(define (foldl f zero lst)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(if (null? lst) zero
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(foldl f (f (car lst) zero) (cdr lst))))
|
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (reverse lst) (foldl cons () lst))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
|
|
|
|
(define (copy-list l)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(if (atom? l) l
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(cons (car l)
|
|
|
|
|
(copy-list (cdr l)))))
|
|
|
|
|
(define (copy-tree l)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(if (atom? l) l
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(cons (copy-tree (car l))
|
|
|
|
|
(copy-tree (cdr l)))))
|
|
|
|
|
|
|
|
|
|
(define (nreverse l)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(let ((prev ()))
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(while (pair? l)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(set! l (prog1 (cdr l)
|
|
|
|
|
(rplacd l (prog1 prev
|
|
|
|
|
(set! prev l))))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
prev))
|
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define-macro (let* binds . body)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(cons (list 'lambda (map car binds)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(cons 'begin
|
|
|
|
|
(nconc (map (lambda (b) (cons 'set! b)) binds)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
body)))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(map (lambda (x) #f) binds)))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define-macro (labels binds . body)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(cons (list 'lambda (map car binds)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(cons 'begin
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(nconc (map (lambda (b)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(list 'set! (car b) (cons 'lambda (cdr b))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
binds)
|
|
|
|
|
body)))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(map (lambda (x) #f) binds)))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define-macro (when c . body) (list 'if c (f-body body) #f))
|
|
|
|
|
(define-macro (unless c . body) (list 'if c #f (f-body body)))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define-macro (dotimes var . body)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(let ((v (car var))
|
2008-12-22 01:36:50 -05:00
|
|
|
|
(cnt (cadr var)))
|
|
|
|
|
`(for 0 (- ,cnt 1)
|
|
|
|
|
(lambda (,v) ,(f-body body)))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (map-int f n)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(if (<= n 0)
|
|
|
|
|
()
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(let ((first (cons (f 0) ()))
|
|
|
|
|
(acc ()))
|
|
|
|
|
(set! acc first)
|
2008-07-26 18:04:02 -04:00
|
|
|
|
(for 1 (- n 1)
|
|
|
|
|
(lambda (i)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(begin (rplacd acc (cons (f i) ()))
|
|
|
|
|
(set! acc (cdr acc)))))
|
2008-07-26 18:04:02 -04:00
|
|
|
|
first)))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (iota n) (map-int identity n))
|
2009-01-03 00:30:22 -05:00
|
|
|
|
(define ι iota)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (error . args) (raise (cons 'error args)))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define-macro (throw tag value) `(raise (list 'thrown-value ,tag ,value)))
|
|
|
|
|
(define-macro (catch tag expr)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(let ((e (gensym)))
|
|
|
|
|
`(trycatch ,expr
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(lambda (,e) (if (and (pair? ,e)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(eq (car ,e) 'thrown-value)
|
|
|
|
|
(eq (cadr ,e) ,tag))
|
|
|
|
|
(caddr ,e)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(raise ,e))))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define-macro (unwind-protect expr finally)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(let ((e (gensym)))
|
|
|
|
|
`(prog1 (trycatch ,expr
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(lambda (,e) (begin ,finally (raise ,e))))
|
|
|
|
|
,finally)))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
|
|
|
|
; (try expr
|
|
|
|
|
; (catch (type-error e) . exprs)
|
|
|
|
|
; (catch (io-error e) . exprs)
|
|
|
|
|
; (catch (e) . exprs)
|
|
|
|
|
; (finally . exprs))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define-macro (try expr . forms)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(let* ((e (gensym))
|
|
|
|
|
(reraised (gensym))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(final (f-body (cdr (or (assq 'finally forms) '(())))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(catches (filter (lambda (f) (eq (car f) 'catch)) forms))
|
|
|
|
|
(catchblock `(cond
|
|
|
|
|
,.(map (lambda (catc)
|
|
|
|
|
(let* ((specific (cdr (cadr catc)))
|
|
|
|
|
(extype (caadr catc))
|
|
|
|
|
(var (if specific (car specific)
|
|
|
|
|
extype))
|
|
|
|
|
(todo (cddr catc)))
|
|
|
|
|
`(,(if specific
|
2009-01-31 20:53:58 -05:00
|
|
|
|
; exception matching logic
|
2008-06-30 21:54:22 -04:00
|
|
|
|
`(or (eq ,e ',extype)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(and (pair? ,e)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(eq (car ,e)
|
|
|
|
|
',extype)))
|
2009-01-31 20:53:58 -05:00
|
|
|
|
#t); (catch (e) ...), match anything
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(let ((,var ,e)) (begin ,@todo)))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
catches)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(#t (raise ,e))))) ; no matches, reraise
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(if final
|
|
|
|
|
(if catches
|
|
|
|
|
; form with both catch and finally
|
|
|
|
|
`(prog1 (trycatch ,expr
|
|
|
|
|
(lambda (,e)
|
|
|
|
|
(trycatch ,catchblock
|
|
|
|
|
(lambda (,reraised)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(begin ,final
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(raise ,reraised))))))
|
|
|
|
|
,final)
|
|
|
|
|
; finally only; same as unwind-protect
|
|
|
|
|
`(prog1 (trycatch ,expr (lambda (,e)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(begin ,final (raise ,e))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
,final))
|
|
|
|
|
; catch, no finally
|
|
|
|
|
`(trycatch ,expr (lambda (,e) ,catchblock)))))
|
|
|
|
|
|
|
|
|
|
; setf
|
|
|
|
|
; expands (setf (place x ...) v) to (mutator (f x ...) v)
|
|
|
|
|
; (mutator (identity x ...) v) is interpreted as (mutator x ... v)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(set! *setf-place-list*
|
2008-06-30 21:54:22 -04:00
|
|
|
|
; place mutator f
|
|
|
|
|
'((car rplaca identity)
|
|
|
|
|
(cdr rplacd identity)
|
|
|
|
|
(caar rplaca car)
|
|
|
|
|
(cadr rplaca cdr)
|
|
|
|
|
(cdar rplacd car)
|
|
|
|
|
(cddr rplacd cdr)
|
|
|
|
|
(caaar rplaca caar)
|
|
|
|
|
(caadr rplaca cadr)
|
|
|
|
|
(cadar rplaca cdar)
|
|
|
|
|
(caddr rplaca cddr)
|
|
|
|
|
(cdaar rplacd caar)
|
|
|
|
|
(cdadr rplacd cadr)
|
|
|
|
|
(cddar rplacd cdar)
|
|
|
|
|
(cdddr rplacd cddr)
|
2009-01-04 21:45:21 -05:00
|
|
|
|
(list-ref rplaca nthcdr)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(get put! identity)
|
|
|
|
|
(aref aset! identity)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(symbol-syntax set-syntax! identity)))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (setf-place-mutator place val)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(if (symbol? place)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(list 'set! place val)
|
|
|
|
|
(let ((mutator (assq (car place) *setf-place-list*)))
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(if (null? mutator)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(error "setf: unknown place " (car place))
|
|
|
|
|
(if (eq (caddr mutator) 'identity)
|
|
|
|
|
(cons (cadr mutator) (append (cdr place) (list val)))
|
|
|
|
|
(list (cadr mutator)
|
|
|
|
|
(cons (caddr mutator) (cdr place))
|
|
|
|
|
val))))))
|
|
|
|
|
|
|
|
|
|
(define-macro (setf . args)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(f-body
|
|
|
|
|
((label setf-
|
|
|
|
|
(lambda (args)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(if (null? args)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
()
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(cons (setf-place-mutator (car args) (cadr args))
|
|
|
|
|
(setf- (cddr args))))))
|
|
|
|
|
args)))
|
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (revappend l1 l2) (nconc (reverse l1) l2))
|
|
|
|
|
(define (nreconc l1 l2) (nconc (nreverse l1) l2))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (list-to-vector l) (apply vector l))
|
|
|
|
|
(define (vector-to-list v)
|
2008-07-26 18:04:02 -04:00
|
|
|
|
(let ((n (length v))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(l ()))
|
2008-07-26 18:04:02 -04:00
|
|
|
|
(for 1 n
|
|
|
|
|
(lambda (i)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(set! l (cons (aref v (- n i)) l))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
l))
|
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (self-evaluating? x)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(or (and (atom? x)
|
|
|
|
|
(not (symbol? x)))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(and (constant? x)
|
2008-12-22 01:36:50 -05:00
|
|
|
|
(eq x (eval x)))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
|
|
|
|
; backquote
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define-macro (backquote x) (bq-process x))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (splice-form? x)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(or (and (pair? x) (or (eq (car x) '*comma-at*)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(eq (car x) '*comma-dot*)))
|
|
|
|
|
(eq x '*comma*)))
|
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (bq-process x)
|
|
|
|
|
(cond ((self-evaluating? x)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(if (vector? x)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(let ((body (bq-process (vector-to-list x))))
|
|
|
|
|
(if (eq (car body) 'list)
|
|
|
|
|
(cons vector (cdr body))
|
|
|
|
|
(list apply vector body)))
|
|
|
|
|
x))
|
2009-01-31 20:53:58 -05:00
|
|
|
|
((atom? x) (list 'quote x))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
((eq (car x) 'backquote) (bq-process (bq-process (cadr x))))
|
|
|
|
|
((eq (car x) '*comma*) (cadr x))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
((not (any splice-form? x))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(let ((lc (lastcdr x))
|
|
|
|
|
(forms (map bq-bracket1 x)))
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(if (null? lc)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(cons 'list forms)
|
|
|
|
|
(nconc (cons 'nlist* forms) (list (bq-process lc))))))
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(#t (let ((p x) (q ()))
|
|
|
|
|
(while (and (pair? p)
|
|
|
|
|
(not (eq (car p) '*comma*)))
|
|
|
|
|
(set! q (cons (bq-bracket (car p)) q))
|
|
|
|
|
(set! p (cdr p)))
|
|
|
|
|
(let ((forms
|
|
|
|
|
(cond ((pair? p) (nreconc q (list (cadr p))))
|
|
|
|
|
((null? p) (nreverse q))
|
|
|
|
|
(#t (nreconc q (list (bq-process p)))))))
|
|
|
|
|
(if (null? (cdr forms))
|
|
|
|
|
(car forms)
|
|
|
|
|
(cons 'nconc forms)))))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (bq-bracket x)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(cond ((atom? x) (list list (bq-process x)))
|
2008-12-30 23:45:08 -05:00
|
|
|
|
((eq (car x) '*comma*) (list list (cadr x)))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
((eq (car x) '*comma-at*) (list 'copy-list (cadr x)))
|
|
|
|
|
((eq (car x) '*comma-dot*) (cadr x))
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(#t (list list (bq-process x)))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
|
|
|
|
; bracket without splicing
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (bq-bracket1 x)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(if (and (pair? x) (eq (car x) '*comma*))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(cadr x)
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(bq-process x)))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(define-macro (assert expr) `(if ,expr #t (raise '(assert-failed ,expr))))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define-macro (time expr)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
(let ((t0 (gensym)))
|
|
|
|
|
`(let ((,t0 (time.now)))
|
|
|
|
|
(prog1
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
,expr
|
|
|
|
|
(princ "Elapsed time: " (- (time.now) ,t0) " seconds\n")))))
|
|
|
|
|
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(define (display x) (princ x) #t)
|
|
|
|
|
|
|
|
|
|
(define (vu8 . elts) (apply array (cons 'uint8 elts)))
|
2008-12-21 00:55:00 -05:00
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (vector.map f v)
|
2008-12-21 00:55:00 -05:00
|
|
|
|
(let* ((n (length v))
|
|
|
|
|
(nv (vector.alloc n)))
|
|
|
|
|
(for 0 (- n 1)
|
|
|
|
|
(lambda (i)
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(aset! nv i (f (aref v i)))))
|
2008-12-21 00:55:00 -05:00
|
|
|
|
nv))
|
|
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (table.pairs t)
|
2008-12-21 00:55:00 -05:00
|
|
|
|
(table.foldl (lambda (k v z) (cons (cons k v) z))
|
|
|
|
|
() t))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (table.keys t)
|
2008-12-21 00:55:00 -05:00
|
|
|
|
(table.foldl (lambda (k v z) (cons k z))
|
|
|
|
|
() t))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (table.values t)
|
2008-12-21 00:55:00 -05:00
|
|
|
|
(table.foldl (lambda (k v z) (cons v z))
|
|
|
|
|
() t))
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
(define (table.clone t)
|
2008-12-22 01:36:50 -05:00
|
|
|
|
(let ((nt (table)))
|
2009-01-31 20:53:58 -05:00
|
|
|
|
(table.foldl (lambda (k v z) (put! nt k v))
|
2008-12-22 01:36:50 -05:00
|
|
|
|
() t)
|
|
|
|
|
nt))
|
2009-02-05 22:41:24 -05:00
|
|
|
|
|
|
|
|
|
(define *whitespace*
|
|
|
|
|
(string.encode #array(wchar 9 10 11 12 13 32 133 160 5760 6158 8192
|
|
|
|
|
8193 8194 8195 8196 8197 8198 8199 8200
|
|
|
|
|
8201 8202 8232 8233 8239 8287 12288)))
|