Skip to content

Instantly share code, notes, and snippets.

@tonetheman
Created November 1, 2022 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonetheman/2847a349ea335a33b296a3ccfa3a7241 to your computer and use it in GitHub Desktop.
Save tonetheman/2847a349ea335a33b296a3ccfa3a7241 to your computer and use it in GitHub Desktop.
Mutually recursive even and odd function in nim
# 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