~tim/lisp200

53a3c3b9ca8bedeaba16ba9eb5d2f830666a3420 — Tim Morgan 1 year, 2 months ago f4f7ac7 master
Allow passing upper bound into fib script
2 files changed, 11 insertions(+), 1 deletions(-)

M core.lisp
M fib.lisp
M core.lisp => core.lisp +8 -0
@@ 111,6 111,14 @@
                     (f i (first l))
                     (mi f (rest l) (+ i 1) mi)))))))

(def string->number
     (fn [s]
         (. s "to_i")))

(def number->string
     (fn [s]
         (. s "to_s")))

(def str
     (fn [& args]
         (if (empty? args)

M fib.lisp => fib.lisp +3 -1
@@ 6,5 6,7 @@
          (fib (- n 1))
          (fib (- n 2))))))

(def upper (string->number (if (> (length ARGV) 1) (nth ARGV 1) 10)))

(each (fn [n] (prn (fib n)))
      '(1 2 3 4 5 6 7 8 9 10))
      (range 1 (+ 1 upper)))