Skip to content

Instantly share code, notes, and snippets.

@bonclay7
Last active August 15, 2018 09:57
Show Gist options
  • Select an option

  • Save bonclay7/44959e36c2da93d299b44592e5ca2eee to your computer and use it in GitHub Desktop.

Select an option

Save bonclay7/44959e36c2da93d299b44592e5ca2eee to your computer and use it in GitHub Desktop.

Lazy evaluation - Haskell vs. Python

Haskell

newOr a b = if a then a else b

example may causing infinite loop:

newOr True (length [1..] > 0)

Python

def new_or(a, b): return a if a else b

example may causing infinite loop:

new_or(True, len([i for i in xrange(sys.maxint)]) > 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment