Skip to content

Instantly share code, notes, and snippets.

@akhileshs
Created April 3, 2015 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akhileshs/d19cc5ed5a88fc93607b to your computer and use it in GitHub Desktop.
Save akhileshs/d19cc5ed5a88fc93607b to your computer and use it in GitHub Desktop.
basic core.typed stuff
(ns typedclj.trial
(:require [clojure.core.typed :refer [check-ns ann ann-form cf ann-protocol ann-datatype] :as t]))
(ann my-inc [Number -> Number])
(defn my-inc [a] (inc a))
(ann collatz [Number -> Number])
(defn collatz [n]
(cond
(= 1 n)
1
(and (integer? n)
(even? n))
(collatz (/ n 2))
:else
(collatz (inc (* 3 n)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment