Created
February 16, 2017 02:42
-
-
Save deech/39b63fc1543c47af3da60a161fcd739f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(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 | |
*\ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Turn on the Shen type checker with
(tc +)
to replicate example.