Skip to content

Instantly share code, notes, and snippets.

@animatedlew
Created November 6, 2013 05:31
Show Gist options
  • Save animatedlew/7331407 to your computer and use it in GitHub Desktop.
Save animatedlew/7331407 to your computer and use it in GitHub Desktop.
Here I implement 'and' & 'or' functions using standard if-else expressions.
// If the second parameter isn't set to eval as CBN
// then infinite loops will hang before the method even begins
def and(x: Boolean, y: => Boolean) =
if (x) y else false
and(true, false)
and(false, true)
and(false, false)
and(true, true)
def or(x: Boolean, y: => Boolean) =
if (x) true else if (y) true else false
or(true, true)
or(true, false)
or(false, true)
or(false, false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment