Carp/examples/mutual_recursion.carp

20 lines
452 B
Plaintext
Raw Permalink Normal View History

; This is dangerous because you've now told the Carp compiler that `f`
; _will_ exist. So you won't get a compile error from Carp if you don't
; implement it or change the signature. You should get a error in the C
; compiler though.
(register f (Fn [Int] Int))
2017-12-05 19:08:10 +03:00
(defn-do g [i]
(println* "I'm g")
(f (inc i)))
2017-12-05 19:08:10 +03:00
(defn-do f [i]
(println* "I'm f")
(if (> i 10)
i
(g (inc i))))
2017-12-05 19:08:10 +03:00
(defn main []
(println* (fmt "Final result: %i" (g 0))))