changeset 20:92db3d1e8809

strJoin finally works.
author William Morgan <bill@mrgn.org>
date Fri, 09 Aug 2013 15:52:16 -0700
parents 5a025e6c6f89
children a4ac42c69285
files src/requests.tp
diffstat 1 files changed, 22 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/requests.tp	Fri Aug 09 13:53:45 2013 -0700
+++ b/src/requests.tp	Fri Aug 09 15:52:16 2013 -0700
@@ -1,18 +1,33 @@
 #{
 
+	strJoin <- :str arr {
+		//head <- arr.get(0)
+		//tail <- arr.
+		print: "go\n"
+		//print: (string: (arr length))
+		acc <- ""
+		arr foreach: :i el {
+			print: (string: i) . " " . (string: el) . "\n"
+			if: i = 0 {
+				acc <- (string: el)
+			} else: {
+				acc <- acc . ", " . (string: el)
+			}
+		}
+		print: "stop\n"
+		acc
+		//arr fold: "" with: :acc el {acc . el}
+	}
+
 	quote <- :str {
 		"\"" . str . "\"" 
 	}
 
 	evalRequest <- :id args {
 		#{
-//			id <- _id
 			string <- {
-// 				idStr <- "a"//good
-				idStr <- quote("id") . quote(id)//segfault
-//				idStr <- "\"id\":\"" . id . "\""// method not implemented
-//				argsStr <- ""//arguments fold: "" with: :acc el {acc . el}
-				argsStr <- "b"
+				idStr <- (quote: "id") . ":" . (quote: id)
+				argsStr <- (quote: "arguments") . ":" . (quote: (strJoin: "," args))
 				"{" . idStr . "," . argsStr . "}"
 			}
 		}
@@ -29,7 +44,7 @@
 	}
 
 	main <- {
-		print: ((evalRequest: "someId" #[1 2 3]) string) . "\n"
+		print: ((evalRequest: "someId" #[1 2i64 3i64]) string) . "\n"
 		print: ((guessRequest: "someId" "someProg") string) . "\n"
 	}
 }