Initial commit

This commit is contained in:
Folkert Kevelam 2025-03-23 21:37:05 +01:00
parent 1ee6f1ab68
commit f6222363b1

21
SICP/exercise_1_12.janet Normal file
View File

@ -0,0 +1,21 @@
(defn pascal [x y]
(cond
(<= x 0) 0
(> x y) 0
(<= y 1) 1
(+ (pascal (- x 1) (- y 1)) (pascal x (- y 1)))))
(def max_val 15)
(var x 1)
(var y 0)
(while (< y max_val)
(cond
(> x y) (do
(set x 1)
(set y (+ y 1))
(print "")
(prin (string/repeat " " (- max_val y))))
(do
(prin (string/format " %d" (pascal x y)))
(set x (+ x 1)))))