1
0
Fork 0

fix syntax "define"

This commit is contained in:
Alex Kotov 2023-05-08 16:05:25 +04:00
parent 37cff92d0c
commit 3b70624610
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
2 changed files with 8 additions and 1 deletions

View file

@ -46,7 +46,7 @@ struct Object *syntax_define(
struct Object *const environment struct Object *const environment
) { ) {
assert(Object_is_pair(environment)); assert(Object_is_pair(environment));
assert(OBJECT_IS_NULL(environment->pair.cdr)); assert(OBJECT_IS_LIST_HEAD(environment->pair.cdr));
assert(OBJECT_IS_LIST_HEAD(environment->pair.car)); assert(OBJECT_IS_LIST_HEAD(environment->pair.car));
assert(Object_is_pair(args)); assert(Object_is_pair(args));

View file

@ -24,6 +24,13 @@
(define (sum a b) (+ a b)) (define (sum a b) (+ a b))
(define (inc a) (+ a 1)) (define (inc a) (+ a 1))
(sum (inc 1) (inc 2)))) (sum (inc 1) (inc 2))))
(assert-equal
11
(begin
(define (make-inc const-num) (lambda (var-num) (+ var-num const-num)))
(define inc1 (make-inc 1))
(define inc10 (make-inc 10))
(inc1 (inc10 0))))
;;; if ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; if ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(assert-equal 123 (if #true 123 456)) (assert-equal 123 (if #true 123 456))