Skip to content

Commit 339ce00

Browse files
committed
add more examples
1 parent e4c09dd commit 339ce00

File tree

1 file changed

+125
-25
lines changed

1 file changed

+125
-25
lines changed

v0.3/handbook/libraries/stdlib.md

Lines changed: 125 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,19 @@ title: "Standard Library"
3333
Sorts the students by GPA
3434
~~~
3535
search
36-
[#student GPA]
36+
[#student name GPA]
3737
index = gather/sort[for: GPA]
3838
bind
3939
[#ui/text sort: index, text: "{{name}} {{GPA}}"]
4040
~~~
41+
42+
Add some students
43+
~~~
44+
commit
45+
[#student name: "Ashley" GPA: 3.10]
46+
[#student name: "Jerome" GPA: 2.37]
47+
[#student name: "Iggy" GPA: 3.97]
48+
~~~
4149
</code>
4250
</td>
4351
</tr>
@@ -66,6 +74,14 @@ search
6674
bind
6775
[#ui/text text: "{{population}} people live in {{state}}"]
6876
~~~
77+
78+
Add some citizens
79+
~~~
80+
commit
81+
[#citizen name: "Regina" state: "CA"]
82+
[#citizen name: "Travis" state: "WA"]
83+
[#citizen name: "Sally" state: "CA"]
84+
~~~
6985
</code>
7086
</td>
7187
</tr>
@@ -96,6 +112,14 @@ search
96112
bind
97113
[#ui/text text: "{{department}} - ${{payroll}}.00"]
98114
~~~
115+
116+
Add some employees
117+
~~~
118+
commit
119+
[#employee name:"Cooper" salary:2 department:"engineering"]
120+
[#employee name:"Adrienne" salary:5 department:"engineering"]
121+
[#employee name:"Najib" salary:10 department:"marketing"]
122+
~~~
99123
</code>
100124
</td>
101125
</tr>
@@ -395,9 +419,17 @@ bind
395419
</td>
396420
<td>
397421
<code>
398-
pi represented as the string "3.14"
399-
[#circle circumference diameter]
400-
pi = math/to-fixed[a: (circumference / diameter), b: 2]</code>
422+
pi represented as the string "3.14"
423+
~~~
424+
search
425+
circumference = 6
426+
diameter = 1.910
427+
pi = math/to-fixed[a: (circumference / diameter), b: 2]
428+
429+
bind
430+
[#ui/text text: pi]
431+
~~~
432+
</code>
401433
</td>
402434
</tr>
403435
</table>
@@ -417,8 +449,15 @@ bind
417449
</ul>
418450
</td>
419451
<td>
420-
<code> generates integers 1 through 10
421-
y = math/range[start: 1, stop: 10]</code>
452+
<code>
453+
generates integers 1 through 10
454+
~~~
455+
search
456+
y = math/range[start: 1, stop: 10]
457+
bind
458+
[#ui/text text: y]
459+
~~~
460+
</code>
422461
</td>
423462
</tr>
424463
</table>
@@ -437,9 +476,22 @@ bind
437476
</ul>
438477
</td>
439478
<td>
440-
<code> generates a random number every second
441-
[#time minutes seconds]
442-
x = random/number[seed: seconds]</code>
479+
<code>
480+
generates a random number every second
481+
~~~
482+
search
483+
[#time second]
484+
x = random/number[seed: second]
485+
bind
486+
[#ui/text text: x]
487+
~~~
488+
489+
Start a timer
490+
~~~
491+
commit
492+
[#system/timer #time resolution: 1000]
493+
~~~
494+
</code>
443495
</td>
444496
</tr>
445497
</table>
@@ -462,9 +514,17 @@ bind
462514
</ul>
463515
</td>
464516
<td>
465-
<code> Americanized version of British spelling
517+
<code>
466518
[#website body]
467-
american-version = string/replace[text: body, replace: "flavour", with: "flavor"]</code>
519+
</code>
520+
Americanized version of British spelling
521+
~~~
522+
search
523+
string = "I love the flavour."
524+
american-version = string/replace[text: string, replace: "flavour", with: "flavor"]
525+
bind
526+
[#ui/text text: american-version]
527+
~~~
468528
</td>
469529
</tr>
470530
</table>
@@ -484,17 +544,24 @@ bind
484544
</ul>
485545
</td>
486546
<td>
487-
<code> finds the 17th letter of the alphabet
488-
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
489-
letter = string/get[text: alphabet, at: 17]</code>
547+
<code>
548+
finds the 17th letter of the alphabet
549+
~~~
550+
search
551+
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
552+
letter = string/get[text: alphabet, at: 17]
553+
bind
554+
[#ui/text text: "The 17th letter of the alphabet is {{letter}}"]
555+
~~~
556+
</code>
490557
</td>
491558
</tr>
492559
</table>
493560

494561
<table class="libitem">
495562
<tr>
496563
<td colspan="2">
497-
<b>string/uppercase</b> -Converts a string to uppercase
564+
<b>string/uppercase</b> - Converts a string to uppercase
498565
</td>
499566
</tr>
500567

@@ -505,8 +572,15 @@ bind
505572
</ul>
506573
</td>
507574
<td>
508-
<code>funny = "lol"
509-
really-funny = string/uppercase[text: funny]</code>
575+
<code>
576+
~~~
577+
search
578+
funny = "lol"
579+
really-funny = string/uppercase[text: funny]
580+
bind
581+
[#ui/text text: really-funny]
582+
~~~
583+
</code>
510584
</td>
511585
</tr>
512586
</table>
@@ -525,8 +599,15 @@ bind
525599
</ul>
526600
</td>
527601
<td>
528-
<code>really-funny = "LOL"
529-
down-a-notch = string/uppercase[text: really-funny]</code>
602+
<code>
603+
~~~
604+
search
605+
really-funny = "LOL"
606+
down-a-notch = string/lowercase[text: really-funny]
607+
bind
608+
[#ui/text text: down-a-notch]
609+
~~~
610+
</code>
530611
</td>
531612
</tr>
532613
</table>
@@ -546,8 +627,15 @@ bind
546627
</ul>
547628
</td>
548629
<td>
549-
<code> Eve is in developers, starting at an index of 2
550-
index = string/index-of[text: "developers", substring: "eve"</code>
630+
<code>
631+
"eve" is in "developers" at index 2.
632+
~~~
633+
search
634+
index = string/index-of[text: "developers", substring: "eve"]
635+
bind
636+
[#ui/text: "String found at index {{index}}"]
637+
~~~
638+
</code>
551639
</td>
552640
</tr>
553641
</table>
@@ -566,9 +654,16 @@ bind
566654
</ul>
567655
</td>
568656
<td>
569-
<code> the code point length of the word "unicode"
570-
string = "unicode"
571-
length-in-js = string/codepoint-length[text: string]</code>
657+
<code>
658+
the code point length of the word "unicode"
659+
~~~
660+
search
661+
string = "unicode"
662+
length-in-js = string/codepoint-length[text: string]
663+
bind
664+
[#ui/text text: length-in-js]
665+
~~~
666+
</code>
572667
</td>
573668
</tr>
574669
</table>
@@ -1341,7 +1436,12 @@ commit
13411436
<li>Other attributes - (optional) - other attribute-value pairs will be applied directly to the button for integration with existing JS libraries or debugging</li>
13421437
</ul>
13431438
</td>
1344-
<td><code></code>
1439+
<td><code>
1440+
~~~
1441+
commit
1442+
[#ui/button class: "flat" icon: "search" text: "Search"]
1443+
~~~
1444+
</code>
13451445
</td>
13461446
</tr>
13471447
</table>

0 commit comments

Comments
 (0)