Created
February 11, 2020 09:04
-
-
Save sparverius/37380de7c8cc33e95611c982441eafb5 to your computer and use it in GitHub Desktop.
This file contains 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
@datacon(Stream) | |
def filter(xs): | |
@fnx | |
def auxmain(xs): lazy(auxloop(eval(xs))) | |
def auxloop(xs): | |
match xs: | |
for nil: return nil | |
for cons(x, xs): | |
match filter.test(x): | |
for tt: return cons(x, auxmain(xs)) | |
for ff: return auxloop(eval(xs)) | |
return auxmain(xs) | |
@datacon(Stream) | |
def filter(xs): | |
@fnx | |
def auxmain(xs): | |
return lazy(auxloop(eval(xs))) | |
def auxloop(xs): | |
match xs as foo: | |
for nil: return nil | |
for cons(x, xs): | |
if filter.test(x): | |
return cons(x, auxmain(xs)) | |
else: | |
return auxloop(eval(xs)) | |
return foo | |
return auxmain(xs) | |
@datacon(Stream) | |
def filter(xs): | |
@fnx | |
def auxmain(xs): | |
return lazy(auxloop(eval(xs))) | |
def auxloop(xs): | |
match xs as foo: | |
for nil: return nil | |
for cons(x, xs): | |
if filter.test(x): | |
return cons(x, auxmain(xs)) | |
else: | |
return auxloop(eval(xs)) | |
return auxmain(xs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment