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 rules
js: TopLevel(x) -> $[const Stdio = { js: TopLevel(x) -> $[const Stdio = {
receives: v => { process.stdout.write(String(v)); return 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]] [x]]
@ -16,7 +19,7 @@ rules
js: Int(x) -> x js: Int(x) -> x
js: Sum(x) -> $[[x].reduce((v,w) => v+w)] js: Sum(x) -> $[[x].reduce((v,w) => v+w)]
js: Receives(x, y) -> $[[x].receives([y])] 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>]> jslist: x -> $<[<<join(|", ")>x>]>

View File

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