Mercurial > repos > icfp2013
annotate 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 |
rev | line source |
---|---|
10
79c1db5e7ebd
sending broken file for mike to check error
William Morgan <bill@mrgn.org>
parents:
diff
changeset
|
1 #{ |
18 | 2 |
20 | 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 } | |
21 | |
18 | 22 quote <- :str { |
23 "\"" . str . "\"" | |
24 } | |
25 | |
19
5a025e6c6f89
simple parallel requests limit test
William Morgan <bill@mrgn.org>
parents:
18
diff
changeset
|
26 evalRequest <- :id args { |
12
7d8b8f82cbef
Help Bill work around some compiler bugs
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
27 #{ |
7d8b8f82cbef
Help Bill work around some compiler bugs
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
28 string <- { |
20 | 29 idStr <- (quote: "id") . ":" . (quote: id) |
30 argsStr <- (quote: "arguments") . ":" . (quote: (strJoin: "," args)) | |
18 | 31 "{" . idStr . "," . argsStr . "}" |
12
7d8b8f82cbef
Help Bill work around some compiler bugs
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
32 } |
7d8b8f82cbef
Help Bill work around some compiler bugs
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
33 } |
7d8b8f82cbef
Help Bill work around some compiler bugs
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
34 } |
10
79c1db5e7ebd
sending broken file for mike to check error
William Morgan <bill@mrgn.org>
parents:
diff
changeset
|
35 |
15
18ec9131f594
one more compiler bug for mike.
William Morgan <bill@mrgn.org>
parents:
14
diff
changeset
|
36 guessRequest <- :id :prog { |
18ec9131f594
one more compiler bug for mike.
William Morgan <bill@mrgn.org>
parents:
14
diff
changeset
|
37 #{ |
18ec9131f594
one more compiler bug for mike.
William Morgan <bill@mrgn.org>
parents:
14
diff
changeset
|
38 string <- { |
17
566960135ea1
Small bit of cleanup now that the string escaping bug is fixed.
Mike Pavone <pavone@retrodev.com>
parents:
16
diff
changeset
|
39 idStr <- "\"id\":\"" . id . "\"" |
566960135ea1
Small bit of cleanup now that the string escaping bug is fixed.
Mike Pavone <pavone@retrodev.com>
parents:
16
diff
changeset
|
40 progStr <- "\"program\":\"" . prog . "\"" |
566960135ea1
Small bit of cleanup now that the string escaping bug is fixed.
Mike Pavone <pavone@retrodev.com>
parents:
16
diff
changeset
|
41 "{" . idStr . "," . progStr . "}" |
15
18ec9131f594
one more compiler bug for mike.
William Morgan <bill@mrgn.org>
parents:
14
diff
changeset
|
42 } |
18ec9131f594
one more compiler bug for mike.
William Morgan <bill@mrgn.org>
parents:
14
diff
changeset
|
43 } |
18ec9131f594
one more compiler bug for mike.
William Morgan <bill@mrgn.org>
parents:
14
diff
changeset
|
44 } |
18ec9131f594
one more compiler bug for mike.
William Morgan <bill@mrgn.org>
parents:
14
diff
changeset
|
45 |
12
7d8b8f82cbef
Help Bill work around some compiler bugs
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
46 main <- { |
20 | 47 print: ((evalRequest: "someId" #[1 2i64 3i64]) string) . "\n" |
15
18ec9131f594
one more compiler bug for mike.
William Morgan <bill@mrgn.org>
parents:
14
diff
changeset
|
48 print: ((guessRequest: "someId" "someProg") string) . "\n" |
12
7d8b8f82cbef
Help Bill work around some compiler bugs
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
49 } |
10
79c1db5e7ebd
sending broken file for mike to check error
William Morgan <bill@mrgn.org>
parents:
diff
changeset
|
50 } |