Skip to content

Instantly share code, notes, and snippets.

@cagerton
Created May 10, 2010 20:46
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 cagerton/396515 to your computer and use it in GitHub Desktop.
Save cagerton/396515 to your computer and use it in GitHub Desktop.
def ones(x):
if x:
print "1",
return ones(x-1)
def tail(fxn):
def _tail(fxn):
while callable(fxn):
fxn=fxn()
return fxn
return lambda x:_tail(fxn(x))
def _ones(x):
if x:
print "1",
return (lambda: _ones(x-1))
ones = lambda x:tail(_ones)(x)
def compress(blocks):
if not_empty(blocks):
return squeeze(first(blocks))+compress(restof(blocks))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment