1 USING: io math sequences ;
4 10 [ "Hello, Factor" print ] times
5 "Hello, " "Factor" append print
7 USING: io kernel sequences
8 http.client xml xml.data xml.traversal ;
10 "http://factorcode.org" http-get nip string>xml
15 USING: accessors kernel math math.constants
16 math.functions prettyprint ;
18 TUPLE: circle radius ;
19 TUPLE: rectangle width height ;
21 GENERIC: area ( shape -- area )
22 M: circle area radius>> sq pi * ;
23 M: rectangle area [ width>> ] [ height>> ] bi * ;
25 rectangle new 10 >>width 20 >>height area .
27 USING: accessors smtp ;
30 "john@foobar.com" >>from
31 { "jane@foobar.com" } >>to
32 "Up for lunch?" >>subject
36 USING: io.files io.encodings.utf8 kernel
41 [ "|" split ] map flip [ "|" join ] map
45 USING: sequences xml.syntax xml.writer ;
47 { "three" "blind" "mice" }
48 [ [XML <li><-></li> XML] ] map
49 [XML <ul><-></ul> XML]
52 USING: inspector io.files.info
53 io.pathnames system tools.files ;
56 home file-system-info free-space>> .
57 image-path file-info describe
59 USING: io kernel sequences ;
62 "Happy Birthday " write
63 2 = "dear NAME" "to You" ? print
66 USING: dice formatting ;
69 "You do %s points of damage!" printf
74 "Uryyb, jbeyq!" assert=
76 USING: ascii tools.test ;
78 { "HELLO" } [ "HeLlO" >upper ] unit-test
79 { "Hello" } [ "HeLlO" >title ] unit-test
80 { "hello" } [ "HeLlO" >lower ] unit-test
82 USING: io io.encodings.ascii io.files
83 random sequences splitting ;
85 "/usr/share/games/fortune/fortunes"
86 ascii file-lines { "%" } split random
89 USING: combinators io kernel locals
90 math.functions math.parser ranges
95 { [ i 15 divisor? ] [ "FizzBuzz" ] }
96 { [ i 3 divisor? ] [ "Fizz" ] }
97 { [ i 5 divisor? ] [ "Buzz" ] }
102 USING: kernel math sequences text-to-speech ;
106 dup [ "aeiou" member? ] find drop [
108 [ cut swap "ay" 3append ] if-zero
113 USING: math.text.english morse sequences ;
115 { 4 8 15 16 23 42 } [
116 number>text play-as-morse