implement vectors
This commit is contained in:
+29
-12
@@ -1,3 +1,5 @@
|
||||
|
||||
|
||||
(define-syntax (pe expr)
|
||||
`(printf ',expr "evaluates to" ,expr))
|
||||
|
||||
@@ -141,18 +143,33 @@ ithe sequence as arguemens."
|
||||
(assert-types= @lambda-list)
|
||||
@body)))
|
||||
|
||||
(define-syntax (define-package name :rest body)
|
||||
`(define ,(string->symbol (concat-strings (symbol->string name) "->"))
|
||||
((lambda ()
|
||||
@body
|
||||
(set-type
|
||||
(special-lambda (:rest args)
|
||||
(let ((op (first args))
|
||||
(args (rest args)))
|
||||
(if (callable? (eval op))
|
||||
(apply op args)
|
||||
(eval op))))
|
||||
:package)))))
|
||||
|
||||
(define-syntax (define-module module-name :keys exports :rest body)
|
||||
(let ((module-prefix (concat-strings (symbol->string module-name) "::")))
|
||||
(eval `(begin @body))
|
||||
(pair 'begin
|
||||
(map (lambda (orig-export-name)
|
||||
(let ((export-name (string->symbol
|
||||
(concat-strings module-prefix
|
||||
(symbol->string orig-export-name)))))
|
||||
`(define ,export-name
|
||||
,(try (eval orig-export-name)
|
||||
(error "The module does not contain" orig-export-name)))))
|
||||
exports))))
|
||||
|
||||
|
||||
;; (define-syntax (define-package name :rest body)
|
||||
;; `(define ,(string->symbol (concat-strings (symbol->string name) "->"))
|
||||
;; ((lambda ()
|
||||
;; @body
|
||||
;; (set-type
|
||||
;; (special-lambda (:rest args)
|
||||
;; (let ((op (first args))
|
||||
;; (args (rest args)))
|
||||
;; (if (callable? (eval op))
|
||||
;; (apply op args)
|
||||
;; (eval op))))
|
||||
;; :package)))))
|
||||
|
||||
(define (null? x)
|
||||
"Checks if the argument is =nil=."
|
||||
|
||||
Reference in New Issue
Block a user