Created
November 1, 2022 19:59
-
-
Save tonetheman/2847a349ea335a33b296a3ccfa3a7241 to your computer and use it in GitHub Desktop.
Mutually recursive even and odd function in nim
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
# forward declarations | |
proc even(x: int) : bool; | |
proc odd(x: int) : bool; | |
proc odd(x : int) : bool = | |
if x==0: | |
return false | |
else: | |
return even(x-1) | |
proc even(x : int) : bool = | |
if x==0: | |
return true | |
else: | |
return odd(x-1) | |
echo(even(4)) | |
echo(odd(4)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment