Skip to main content
added 73 characters in body
Source Link

Programs may take input from a generator or iterator

We already have a rule that programs may output via a generator. Just for completeness, I think we should specify it's a valid input method as well.

Example in rust:

|t:Box<dyn Iterator>|t.flatten()

Other example, taking input via the returned generator in python:

def k():
    yield "Hello, "+str(yield "What is your name")

Which can be used like

t = k()
print(next(k))
print(k.send("Charlie"))

Another example:

def k(f):
    return [int(next(f)),*f]

Programs may take input from a generator or iterator

We already have a rule that programs may output via a generator. Just for completeness, I think we should specify it's a valid input method as well.

Example in rust:

|t:Box<dyn Iterator>|t.flatten()

Other example, taking input via the returned generator in python:

def k():
    yield "Hello, "+str(yield "What is your name")

Which can be used like

t = k()
print(next(k))
print(k.send("Charlie"))

Programs may take input from a generator or iterator

We already have a rule that programs may output via a generator. Just for completeness, I think we should specify it's a valid input method as well.

Example in rust:

|t:Box<dyn Iterator>|t.flatten()

Other example, taking input via the returned generator in python:

def k():
    yield "Hello, "+str(yield "What is your name")

Which can be used like

t = k()
print(next(k))
print(k.send("Charlie"))

Another example:

def k(f):
    return [int(next(f)),*f]
Source Link

Programs may take input from a generator or iterator

We already have a rule that programs may output via a generator. Just for completeness, I think we should specify it's a valid input method as well.

Example in rust:

|t:Box<dyn Iterator>|t.flatten()

Other example, taking input via the returned generator in python:

def k():
    yield "Hello, "+str(yield "What is your name")

Which can be used like

t = k()
print(next(k))
print(k.send("Charlie"))