Skip to content

Instantly share code, notes, and snippets.

@frenchy64
Last active June 16, 2021 20:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frenchy64/9092128 to your computer and use it in GitHub Desktop.
Save frenchy64/9092128 to your computer and use it in GitHub Desktop.
(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)
0
#(funb (dec n))))
(defn funb [n]
(if (= n 0)
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