]> gitweb.factorcode.org Git - factor.git/commitdiff
websites.factorcode: more examples.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 28 Feb 2020 21:04:46 +0000 (13:04 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 28 Feb 2020 21:04:46 +0000 (13:04 -0800)
extra/websites/factorcode/examples.txt

index fccad60e31e3711ec6ebb0ea6ccbe8e4929fa18b..ff65c2523fec90fd48d787e9eabb020d87b8c42e 100644 (file)
@@ -78,3 +78,29 @@ USING: ascii tools.test ;
 { "HELLO" } [ "HeLlO" >upper ] unit-test
 { "Hello" } [ "HeLlO" >title ] unit-test
 { "hello" } [ "HeLlO" >lower ] unit-test
+----
+USING: io io.encodings.ascii io.files
+random sequences splitting ;
+
+"/usr/share/games/fortune/fortunes"
+ascii file-lines { "%" } split
+random [ print ] each
+----
+USING: morse text-to-speech ;
+
+"Hello, world!" speak-text
+
+"Factor" play-as-morse
+----
+USING: combinators io kernel locals
+math.functions math.parser math.ranges
+sequences ;
+
+100 [1,b] [| i |
+    {
+        { [ i 15 divisor? ] [ "FizzBuzz" ] }
+        { [ i  3 divisor? ] [ "Fizz" ] }
+        { [ i  5 divisor? ] [ "Buzz" ] }
+        [ i number>string ]
+    } cond print
+] each