Hacker News new | past | comments | ask | show | jobs | submit login

A little example I've come up with is writing a bunch of tests for a function you are implementing and seeing them automatically executed.

Try to fix fib by changing a, b and i values:

  (defn fib [n]
    (loop [a 1, b 1, i 1]
      (if (= i n)
        a
        (recur b (+ a b) (inc i)))))

  (= (fib 0) 0)
  (= (fib 1) 1)
  (= (fib 2) 1)
  (= (fib 3) 2)
  (= (fib 4) 3)
  (= (fib 10) 55)



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: