Initial commit
This commit is contained in:
parent
1ee6f1ab68
commit
f6222363b1
21
SICP/exercise_1_12.janet
Normal file
21
SICP/exercise_1_12.janet
Normal 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)))))
|
||||
Loading…
Reference in New Issue
Block a user