comparison src/requests.tp @ 20:92db3d1e8809

strJoin finally works.
author William Morgan <bill@mrgn.org>
date Fri, 09 Aug 2013 15:52:16 -0700
parents 5a025e6c6f89
children a4ac42c69285
comparison
equal deleted inserted replaced
19:5a025e6c6f89 20:92db3d1e8809
1 #{ 1 #{
2
3 strJoin <- :str arr {
4 //head <- arr.get(0)
5 //tail <- arr.
6 print: "go\n"
7 //print: (string: (arr length))
8 acc <- ""
9 arr foreach: :i el {
10 print: (string: i) . " " . (string: el) . "\n"
11 if: i = 0 {
12 acc <- (string: el)
13 } else: {
14 acc <- acc . ", " . (string: el)
15 }
16 }
17 print: "stop\n"
18 acc
19 //arr fold: "" with: :acc el {acc . el}
20 }
2 21
3 quote <- :str { 22 quote <- :str {
4 "\"" . str . "\"" 23 "\"" . str . "\""
5 } 24 }
6 25
7 evalRequest <- :id args { 26 evalRequest <- :id args {
8 #{ 27 #{
9 // id <- _id
10 string <- { 28 string <- {
11 // idStr <- "a"//good 29 idStr <- (quote: "id") . ":" . (quote: id)
12 idStr <- quote("id") . quote(id)//segfault 30 argsStr <- (quote: "arguments") . ":" . (quote: (strJoin: "," args))
13 // idStr <- "\"id\":\"" . id . "\""// method not implemented
14 // argsStr <- ""//arguments fold: "" with: :acc el {acc . el}
15 argsStr <- "b"
16 "{" . idStr . "," . argsStr . "}" 31 "{" . idStr . "," . argsStr . "}"
17 } 32 }
18 } 33 }
19 } 34 }
20 35
27 } 42 }
28 } 43 }
29 } 44 }
30 45
31 main <- { 46 main <- {
32 print: ((evalRequest: "someId" #[1 2 3]) string) . "\n" 47 print: ((evalRequest: "someId" #[1 2i64 3i64]) string) . "\n"
33 print: ((guessRequest: "someId" "someProg") string) . "\n" 48 print: ((guessRequest: "someId" "someProg") string) . "\n"
34 } 49 }
35 } 50 }