Here is an factorial example in Shen.
Code: Select all
(26-) (define factorial
0 -> 1
X -> (* X (factorial (- X 1))))
factorial
(27-) (factorial 6)
720
Thanks and Cheers.
Code: Select all
(26-) (define factorial
0 -> 1
X -> (* X (factorial (- X 1))))
factorial
(27-) (factorial 6)
720
Code: Select all
(define (factorial n)
(case n
(0 1)
(true (eval (letex (X n) '(* X (factorial (- X 1))))))))
Code: Select all
(define-macro (xxxx name)
(letn ((argv (explode (args) 3)) (tail (pop argv -1)))
(eval (letex ((ARG (tail 0)) (NAME name)
(BODY (extend (list 'case (tail 0))
(map (fn (a) (select a 0 2)) argv)
(list (list true (tail 2))))))
'(define (NAME ARG) BODY)))))