changeset 98:a34a982ecd32

Broken port of nworker to compiler
author Mike Pavone <pavone@retrodev.com>
date Tue, 03 Aug 2010 23:51:39 -0400
parents fa437d23bb24
children e09c2d1d6d5b
files functional.rhope kernel.rhope range.rhope testnworker.rhope
diffstat 4 files changed, 79 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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 <- ()
+	}
+}
+
--- 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]
+}
+
--- 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]
+}
+
--- /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
+	]
+}