# HG changeset patch # User William Morgan # Date 1376088736 25200 # Node ID 92db3d1e88096cda40ea6209fe4d16f44156fdfd # Parent 5a025e6c6f89b56296c05a5384895aa91e5db029 strJoin finally works. diff -r 5a025e6c6f89 -r 92db3d1e8809 src/requests.tp --- 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" } }