Created
August 26, 2014 17:33
-
-
Save gofer/2d7a2c5a669fc1f98bcd 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
fun op ** (a, b) = let | |
val succ = fn x => x + 1 | |
val pred = fn x => x - 1 | |
val c = if a < b then succ a else pred a | |
in | |
if a = b then [a] else a::(op ** (c ,b)) | |
end; | |
infix **; | |
fun op *** (a, b) = let | |
val succ = fn x => x + 1 | |
val pred = fn x => x - 1 | |
val c = if a < b then succ a else pred a | |
in | |
if a = b then [] else a::(op *** (c, b)) | |
end; | |
infix ***; | |
1 ** 10; | |
(* val it = [1,2,3,4,5,6,7,8,9,10] : int list *) | |
1 *** 10; | |
(* val it = [1,2,3,4,5,6,7,8,9] : int list *) | |
3 ** ~3; | |
(* val it = [3,2,1,0,~1,~2,~3] : int list *) | |
~3 *** ~10; | |
(* val it = [~3,~4,~5,~6,~7,~8,~9] : int list *) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment