Skip to content

Instantly share code, notes, and snippets.

@frenchy64 frenchy64/trampoline.clj
Last active Aug 29, 2015

What would you like to do?
(ns clojure.core.typed.test.trampoline
(:require [clojure.core.typed :as t]))
(declare funb)
(t/ann-many [Number -> (Rec [f]
(U Number [-> (U Number f)]))]
funa funb)
(defn funa [n]
(if (= n 0)
#(funb (dec n))))
(defn funb [n]
(if (= n 0)
#(funa (dec n))))
(t/ann ^:no-check clojure.core/trampoline
(All [r b ...]
[[b ... b -> (Rec [f] (U r [-> (U f r)]))]
b ... b -> r]))
(trampoline funa 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.