# HG changeset patch # User Mike Pavone # Date 1280893899 14400 # Node ID a34a982ecd320a44b9f4365ee86cbe96d88d1dbd # Parent fa437d23bb248a487eeede853d6ac237dee32c6f Broken port of nworker to compiler diff -r fa437d23bb24 -r a34a982ecd32 functional.rhope --- a/functional.rhope Tue Aug 03 22:38:25 2010 -0400 +++ b/functional.rhope Tue Aug 03 23:51:39 2010 -0400 @@ -91,3 +91,36 @@ } } +_Zip[left,lindex,right,rindex,outlist:out] +{ + nlist <- [outlist]Append[ + [[()]Append[ [left]Index[lindex] ]]Append[ [right]Index[rindex] ] + ] + nlindex <- [left]Next[lindex] + { + [right]Next[rindex] + { + out <- _Zip[left,nlindex,right,~,nlist] + }{ + out <- Val[nlist] + } + }{ + out <- Val[nlist] + } +} + +Zip[left,right:out] +{ + lindex <- [left]First + { + [right]First + { + out <- _Zip[left,lindex,right,~,()] + }{ + out <- () + } + }{ + out <- () + } +} + diff -r fa437d23bb24 -r a34a982ecd32 kernel.rhope --- a/kernel.rhope Tue Aug 03 22:38:25 2010 -0400 +++ b/kernel.rhope Tue Aug 03 23:51:39 2010 -0400 @@ -287,3 +287,13 @@ } } +_Keys[list,val,key:out] +{ + out <- [list]Append[key] +} + +Keys[container:out] +{ + out <- Fold[_Keys[?], (), container] +} + diff -r fa437d23bb24 -r a34a982ecd32 range.rhope --- a/range.rhope Tue Aug 03 22:38:25 2010 -0400 +++ b/range.rhope Tue Aug 03 23:51:39 2010 -0400 @@ -46,3 +46,9 @@ } } +Set@Range[range,index,val:out] +{ + out <- [[()]Concatenate[range] + ]Set[index,val] +} + diff -r fa437d23bb24 -r a34a982ecd32 testnworker.rhope --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testnworker.rhope Tue Aug 03 23:51:39 2010 -0400 @@ -0,0 +1,30 @@ +Import nworker_c.rhope + +Test NWorker[:out] +{ + ref+ <- Worker Ref["+","rhope",2,1] + ref* <- Worker Ref["*","rhope",2,1] + ,a <- [NWorker["rhope"] + ]Add Input["a", 0] { + ,b <- [~]Add Input["b", 1] { + ,c <- [~]Add Input["c", 2] { + ,outref <- [~]Add Output["out", 0] { + ,call+ <- [~]Add Worker Call[ref+] { + ,call* <- [~]Add Worker Call[ref*] { + out <- [[[[[~]Add Wire[a,0,call+,0] + ]Add Wire[b,0,call+,1] + ]Add Wire[call+,0,call*,0] + ]Add Wire[c,0,call*,1] + ]Add Wire[call*,0,outref,0] + }}}}}} +} + +Main[] +{ + Print[ + [[[[NProgram]Register Builtins + ]Bind Worker["Test", Test NWorker[]] + ]Compile Program[C Program[]] + ]Text + ] +}