Created
April 3, 2015 12:51
-
-
Save akhileshs/d19cc5ed5a88fc93607b to your computer and use it in GitHub Desktop.
basic core.typed stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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