we have a new parser and can parse [] and {} for vectors and hm's
This commit is contained in:
+14
-14
@@ -33,22 +33,22 @@ condition is true.
|
||||
{{{example_end}}}
|
||||
"
|
||||
(if (= (rest body) ())
|
||||
`(if ,condition @body nil)
|
||||
`(if ,condition (begin @body) nil)))
|
||||
`(if ,condition ,@body nil)
|
||||
`(if ,condition (begin ,@body) nil)))
|
||||
|
||||
(define-syntax (unless condition . body)
|
||||
:doc "Special form for when multiple actions should be done if a
|
||||
condition is false."
|
||||
(if (= (rest body) ())
|
||||
`(if ,condition nil @body)
|
||||
`(if ,condition nil (begin @body))))
|
||||
`(if ,condition nil ,@body)
|
||||
`(if ,condition nil (begin ,@body))))
|
||||
|
||||
(define-syntax (n-times times action)
|
||||
:doc "Executes action times times."
|
||||
(define (repeat times elem)
|
||||
(unless (> 1 times)
|
||||
(pair elem (repeat (- times 1) elem))))
|
||||
`(begin @(repeat times action)))
|
||||
`(begin ,@(repeat times action)))
|
||||
|
||||
(define-syntax (let bindings . body)
|
||||
(define (unzip lists)
|
||||
@@ -64,7 +64,7 @@ condition is false."
|
||||
|
||||
(define unzipped (unzip bindings))
|
||||
|
||||
`((,lambda ,(first unzipped) @body) @(first (rest unzipped))))
|
||||
`((,lambda ,(first unzipped) ,@body) ,@(first (rest unzipped))))
|
||||
|
||||
(define-syntax (cond . clauses)
|
||||
(define (rec clauses)
|
||||
@@ -76,7 +76,7 @@ condition is false."
|
||||
(error :syntax-error "There are additional clauses after the else clause!")
|
||||
(pair 'begin (rest (first clauses)))))
|
||||
`(if ,(first (first clauses))
|
||||
(begin @(rest (first clauses)))
|
||||
(begin ,@(rest (first clauses)))
|
||||
,(rec (rest clauses))))))
|
||||
(rec clauses))
|
||||
|
||||
@@ -91,7 +91,7 @@ condition is false."
|
||||
(error :syntax-error "There are additional clauses after the else clause!")
|
||||
(pair 'begin (rest (first clauses)))))
|
||||
`(if (member? ,var ',(first (first clauses)))
|
||||
(begin @(rest (first clauses)))
|
||||
(begin ,@(rest (first clauses)))
|
||||
,(rec (rest clauses))))))
|
||||
(rec clauses))
|
||||
|
||||
@@ -149,14 +149,14 @@ condition is false."
|
||||
(let ((name (first args))
|
||||
(lambda-list (rest args))
|
||||
(arg-names (get-arg-names (rest args))))
|
||||
`(define (,name @arg-names)
|
||||
(assert-types= @lambda-list)
|
||||
@body)))
|
||||
`(define (,name ,@arg-names)
|
||||
(assert-types= ,@lambda-list)
|
||||
,@body)))
|
||||
|
||||
|
||||
(define-syntax (define-module module-name (:imports ()) :exports . body)
|
||||
(let ((module-prefix (concat-strings (symbol->string module-name) "::")))
|
||||
(eval `(begin @(map (lambda (x) `(,import ,x)) imports) @body))
|
||||
(eval `(begin ,@(map (lambda (x) `(,import ,x)) imports) ,@body))
|
||||
(pair 'begin
|
||||
(map (lambda (orig-export-name)
|
||||
(let ((export-name (string->symbol
|
||||
@@ -189,8 +189,8 @@ condition is false."
|
||||
(let ((generic-map-name (string->symbol
|
||||
(concat-strings "generic-" (symbol->string fun-name) "-map"))))
|
||||
(unless (bound? generic-map-name)
|
||||
(define generic-map-name (create-hash-map)))
|
||||
(hm/set! generic-map-name types (eval `(,lambda ,names @body)))
|
||||
(define generic-map-name (hash-map)))
|
||||
(hm/set! generic-map-name types (eval `(,lambda ,names ,@body)))
|
||||
;; now check if the generic procedure already exists
|
||||
(if (bound? fun-name)
|
||||
(let ((exisiting-fun (eval fun-name)))
|
||||
|
||||
Reference in New Issue
Block a user