Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(datatype is-prime
if (is-prime? N)
N : number;
==============
N : prime;)
(define is-prime?
X -> (prime* X (/ X 2) 2) where (number? X)
_ -> false)
(define prime*
X Max Div -> false where (integer? (/ X Div))
X Max Div -> true where (> Div Max)
X Max Div -> (prime* X Max (+ 1 Div)))
\*
Sample REPL interaction:
(13+) 1 : prime
1 : prime
(14+) 2 : prime
type error
*\
@shanecelis
Copy link

shanecelis commented Feb 16, 2017

Turn on the Shen type checker with (tc +) to replicate example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment