Skip to content

Commit 42fa719

Browse files
committed
fix more examples
1 parent a3cd88b commit 42fa719

File tree

1 file changed

+64
-46
lines changed

1 file changed

+64
-46
lines changed

v0.3/handbook/libraries/stdlib.md

Lines changed: 64 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,14 @@ title: "Standard Library"
3030
</td>
3131
<td>
3232
<code>
33-
{% raw %}
3433
Sorts the students by GPA
35-
3634
~~~
3735
search
3836
[#student GPA]
3937
index = gather/sort[for: GPA]
40-
4138
bind
4239
[#ui/text sort: index, text: "{{name}} {{GPA}}"]
4340
~~~
44-
{% endraw %}
4541
</code>
4642
</td>
4743
</tr>
@@ -62,18 +58,14 @@ bind
6258
</td>
6359
<td>
6460
<code>
65-
{{ %raw% }}
66-
Counts the number of citizens in each state
67-
61+
Count the number of citizens in each state
6862
~~~
6963
search
7064
residents = [#citizen state]
7165
population = gather/count[given: residents, per: state]
72-
7366
bind
7467
[#ui/text text: "{{population}} people live in {{state}}"]
7568
~~~
76-
{{ %endraw% }}
7769
</code>
7870
</td>
7971
</tr>
@@ -96,18 +88,14 @@ bind
9688
</td>
9789
<td>
9890
<code>
99-
{{ %raw% }}
10091
Sum of salaries for each department
101-
10292
~~~
10393
search
10494
employees = [#employee salary department]
10595
payroll = gather/sum[for: employees, value: salary, per: department]
106-
10796
bind
10897
[#ui/text text: "{{department}} - ${{payroll}}.00"]
10998
~~~
110-
{{ %endraw% }}
11199
</code>
112100
</td>
113101
</tr>
@@ -131,11 +119,9 @@ bind
131119
<td>
132120
<code>
133121
x rounded down to 34
134-
135122
~~~
136123
search
137124
x = math/floor[value: 34.2]
138-
139125
bind
140126
[#ui/text text: x]
141127
~~~
@@ -160,11 +146,9 @@ bind
160146
<td>
161147
<code>
162148
x rounded up to 35
163-
164149
~~~
165150
search
166151
x = math/ceiling[value: 34.2]
167-
168152
bind
169153
[#ui/text text: x]
170154
~~~
@@ -189,11 +173,9 @@ bind
189173
<td>
190174
<code>
191175
x rounded to 34
192-
193176
~~~
194177
search
195178
x = math/round[value: 34.2]
196-
197179
bind
198180
[#ui/text text: x]
199181
~~~
@@ -218,11 +200,9 @@ bind
218200
<td>
219201
<code>
220202
r calculated to 1
221-
222203
~~~
223204
search
224205
r = math/sin[degrees: 90]
225-
226206
bind
227207
[#ui/text text: x]
228208
~~~
@@ -247,11 +227,9 @@ bind
247227
<td>
248228
<code>
249229
r calculated to 0
250-
251230
~~~
252231
search
253232
r = math/cos[degrees: 90]
254-
255233
bind
256234
[#ui/text text: x]
257235
~~~
@@ -276,7 +254,6 @@ bind
276254
<td>
277255
<code>
278256
r calculated to 1
279-
280257
~~~
281258
search
282259
r = math/tan[degrees: 45]
@@ -304,9 +281,16 @@ bind
304281
</ul>
305282
</td>
306283
<td>
307-
<code>// takes the higher score
308-
[#scores pac-man donkey-kong]
309-
best-score = math/min[a: pac-man, b: donkey-kong]</code>
284+
<code>
285+
takes the higher score
286+
~~~
287+
search
288+
[#scores pac-man donkey-kong]
289+
best-score = math/min[a: pac-man, b: donkey-kong]
290+
bind
291+
[#ui/text text: "The winning score is {{best-score}}"]
292+
~~~
293+
</code>
310294
</td>
311295
</tr>
312296
</table>
@@ -326,9 +310,16 @@ bind
326310
</ul>
327311
</td>
328312
<td>
329-
<code>// takes the lower score
330-
[#scores pac-man donkey-kong]
331-
worst-score = math/min[a: pac-man, b: donkey-kong]</code>
313+
<code>
314+
takes the lower score
315+
~~~
316+
search
317+
[#scores pac-man donkey-kong]
318+
worst-score = math/min[a: pac-man, b: donkey-kong]
319+
bind
320+
[#ui/text text: "The losing score is {{worst-score}}"]
321+
~~~
322+
</code>
332323
</td>
333324
</tr>
334325
</table>
@@ -348,8 +339,15 @@ bind
348339
</ul>
349340
</td>
350341
<td>
351-
<code>// m is the remainder, 1
352-
m = math/mod[value: 5, by: 2]</code>
342+
<code>
343+
m is the remainder, 1
344+
~~~
345+
search
346+
m = math/mod[value: 5, by: 2]
347+
bind
348+
[#ui/text text: "5 mod 2 is {{m}}"]
349+
~~~
350+
</code>
353351
</td>
354352
</tr>
355353
</table>
@@ -368,9 +366,19 @@ bind
368366
</ul>
369367
</td>
370368
<td>
371-
<code>// number of hours from the prime meridian
369+
<code>//
372370
[#city latitude longitude]
373371
hours-from-gmt = math/absolute[value: latitude] / 15</code>
372+
<code>
373+
number of hours from the Prime Meridian
374+
~~~
375+
search
376+
[#city latitude longitude]
377+
hours-from-gmt = math/absolute[value: latitude] / 15
378+
bind
379+
[#ui/text text: "{{city}} is {{hours-from-gmt}} hours from the Prime Meridian"]
380+
~~~
381+
</code>
374382
</td>
375383
</tr>
376384
</table>
@@ -390,7 +398,8 @@ bind
390398
</ul>
391399
</td>
392400
<td>
393-
<code>// pi represented as the string "3.14"
401+
<code>
402+
// pi represented as the string "3.14"
394403
[#circle circumference diameter]
395404
pi = math/to-fixed[a: (circumference / diameter), b: 2]</code>
396405
</td>
@@ -1399,7 +1408,9 @@ commit
13991408
<li><strong>autocomplete</strong> - the autocomplete being opened</li>
14001409
</ul>
14011410
</td>
1402-
<td><code>// changes the font color of the autocomplete input to red when the list is opened; the color will not revert once the menu is closed unless another block is specifically written to do so
1411+
<td>
1412+
<code>
1413+
changes the font color of the autocomplete input to red when the list is opened; the color will not revert once the menu is closed unless another block is specifically written to do so
14031414
~~~
14041415
search
14051416
autocomplete = [#ui/autocomplete]
@@ -1408,7 +1419,8 @@ search
14081419

14091420
commit
14101421
input.style <- [color: #ff0000]
1411-
~~~</code>
1422+
~~~
1423+
</code>
14121424
</td>
14131425
</tr>
14141426
</table>
@@ -1426,7 +1438,9 @@ commit
14261438
<li><strong>autocomplete</strong> - the autocomplete being closed</li>
14271439
</ul>
14281440
</td>
1429-
<td><code>// changes the font color of the autocomplete input to black when the list is closed; reverts the change in the example for #ui/event/open
1441+
<td>
1442+
<code>
1443+
changes the font color of the autocomplete input to black when the list is closed; reverts the change in the example for #ui/event/open
14301444
~~~
14311445
search
14321446
autocomplete = [#ui/autocomplete]
@@ -1435,7 +1449,8 @@ search
14351449

14361450
commit
14371451
input.style <- [color: #000000]
1438-
~~~</code>
1452+
~~~
1453+
</code>
14391454
</td>
14401455
</tr>
14411456
</table>
@@ -1453,7 +1468,9 @@ commit
14531468
<li><strong>autocomplete</strong> - the autocomplete being closed</li>
14541469
</ul>
14551470
</td>
1456-
<td><code>// as a follow-up to the #ui/autocomplete example, this waits for the user to pick a birth state, then creates a new autocomplete tagged #birth-county to ask which county within that particular state the user was born in
1471+
<td>
1472+
<code>
1473+
as a follow-up to the #ui/autocomplete example, this waits for the user to pick a birth state, then creates a new autocomplete tagged #birth-county to ask which county within that particular state the user was born in
14571474
~~~
14581475
search
14591476
birth-state = [#ui/autocomplete #birth-state selected]
@@ -1462,7 +1479,8 @@ search
14621479

14631480
commit
14641481
[#ui/autocomplete #birth-county placeholder: “Which county?” | completion: [text: counties]]
1465-
~~~</code>
1482+
~~~
1483+
</code>
14661484
</td>
14671485
</tr>
14681486
</table>
@@ -1480,15 +1498,18 @@ commit
14801498
<li><strong>autocomplete</strong> - the autocomplete whose input field changed</li>
14811499
</ul>
14821500
</td>
1483-
<td><code>// when an autocomplete asking what the magic word is changes to the correct answer, adds the tag #magic-word to the autocomplete
1501+
<td>
1502+
<code>
1503+
when an autocomplete asking what the magic word is changes to the correct answer, adds the tag `#magic-word` to the autocomplete
14841504
~~~
14851505
search
14861506
[#ui/event/change autocomplete]
14871507
autocomplete = [#ui/autocomplete placeholder: “What’s the magic word?” value: “please”]
14881508

14891509
bind
14901510
autocomplete <- [#magic-word]
1491-
~~~</code>
1511+
~~~
1512+
</code>
14921513
</td>
14931514
</tr>
14941515
</table>
@@ -1523,21 +1544,18 @@ The system library provides various system-level utilities for Eve.
15231544
<td>
15241545
<code>
15251546
Commits a timer that ticks every 1000 milliseconds
1526-
15271547
~~~
15281548
commit
15291549
[#system/timer resolution: 1000]
15301550
~~~
15311551
15321552
Displays the current time
1533-
15341553
~~~
15351554
search
15361555
[#system/timer hour minute second]
1537-
15381556
bind
15391557
[#ui/text text: "{{hour}}:{{minute}}:{{second}}"]
1540-
```
1558+
~~~
15411559
</code>
15421560
</td>
15431561
</tr>

0 commit comments

Comments
 (0)