(define-syntax my-if
  (syntax-rules (then else)
    [(_ e1 then e2 else e3) (if e1 e2 e3)]
    [(_ e1 then e2) (if e1 e2)]
    ))

(define a 5)

(my-if (< a 5) then 6 else 7)
(expand '(my-if (< a 5) then 6 else 7))
(list (my-if (< a 5) then 6))

(define-syntax ++
  (syntax-rules ()
    [(++ x) (begin (set! x (add1 x))
		   x)]))

(++ a)
a

(define-syntax ++post
  (syntax-rules ()
    [(_ x)
     (let ([temp x])
       (++ x)
       temp)]))
    
(define b (++post a))
(list a b)

(define-syntax my-and
  (syntax-rules ()
    [(_) #t]
    [(_ e1) e1]
    [(_ e1 e2 ...)
     (if e1
	 (my-and e2 ...)
	 #f)]))

(my-and)
(my-and 5)
(my-and #f 2)
(my-and 3 4 5 6)
(expand '(my-and 3 4 5 6))

(define-syntax for
  (syntax-rules (:)
    [(for ((init ...) : test : update ...)
	  body ...)
     (begin
       init ...
       (let loop ()
	 (if test
	     (begin body ...
		    update ...
		    (loop)))))]))

(for (((define i 0) (define j 1)) :
      (< i 12) :
      (++ i) (set! j (* j 2)))
     (display i) (display "   ")
     (display j) (display "   ") (newline))