feat: Implement enters operator >> #8

Merged
glen merged 2 commits from enters_operator into main 2021-02-01 01:46:31 +00:00
2 changed files with 9 additions and 6 deletions
Showing only changes of commit 132b8432e8 - Show all commits

View File

@ -8,7 +8,10 @@ signature
rules
js: TopLevel(x) -> $[const Stdio = {
receives: v => { process.stdout.write(String(v)); return Stdio; },
forwards: v => { process.stdout.write(String(v)); return v; }
}
function forwards(data, strm) {
strm.receives(data);
return data;
}
[x]]
@ -16,7 +19,7 @@ rules
js: Int(x) -> x
js: Sum(x) -> $[[x].reduce((v,w) => v+w)]
js: Receives(x, y) -> $[[x].receives([y])]
js: Enters(x, y) -> $[[y].forwards([x])]
js: Enters(x, y) -> $[forwards([x],[y])]
jslist: x -> $<[<<join(|", ")>x>]>

View File

@ -12,9 +12,9 @@ rules
def receives(self, v):
print(v, file=sys.stdout, end='')
return self
def forwards(self, v):
self.receives(v)
return v
def forwards(data,strm):
strm.receives(data)
return data
Stdio = StdioC()
[x]]
@ -22,7 +22,7 @@ rules
py: Int(x) -> x
py: Sum(x) -> $[sum([x])]
py: Receives(x, y) -> $[[x].receives([y])]
py: Enters(x, y) -> $[[y].forwards([x])]
py: Enters(x, y) -> $[forwards([x],[y])]
pylist: x -> $<[<<join(|", ")>x>]>