annotate samples/stringops.tp @ 285:bb1539decd62

Fix const warning in sdl module
author Michael Pavone <pavone@retrodev.com>
date Tue, 22 Jul 2014 08:35:30 -0700
parents 32964a4e7a33
children a4c2b31acba7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
43
27a2167663dd Improve compiler error reporting. Fix operator associativity. Add some more string operations and a string ops sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #{
27a2167663dd Improve compiler error reporting. Fix operator associativity. Add some more string operations and a string ops sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
2 main <- {
27a2167663dd Improve compiler error reporting. Fix operator associativity. Add some more string operations and a string ops sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
3 print: "foo: " . 42 . "\n"
27a2167663dd Improve compiler error reporting. Fix operator associativity. Add some more string operations and a string ops sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
4 print: (string: (length: "foo" . "bar")) . "\n"
150
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
5 print: (string: ("foobarbaz" find: "foo" else: { "not found" })) . "\n"
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
6 print: (string: ("foobarbaz" find: "bar" else: { "not found" })) . "\n"
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
7 print: (string: ("foobarbaz" find: "baz" else: { "not found" })) . "\n"
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
8 print: (string: ("foobarbaz" find: "qux" else: { "not found" })) . "\n"
151
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
9
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
10 print: ("foobarbaz" from: 3) . "\n"
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
11 print: ("foobarbaz" from: 3 withLength: 3) . "\n"
152
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
12
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
13 foreach: ("foo,bar,baz,qux" splitOn: ",") :idx val {
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
14 print: val . "\n"
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
15 }
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
16
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
17 res <- "foobarbaz" partitionOn: "bar"
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
18 print: "Before: " . (res before) . "\n"
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
19 print: "After: " . (res after) . "\n"
158
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 152
diff changeset
20
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 152
diff changeset
21 print: (string: ("12abcDEF" parseHex32)) . "\n"
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 152
diff changeset
22 print: (string: ("FFFFFFFFFF" parseHex64)) . "\n"
259
32964a4e7a33 Add ltrim method to string
Michael Pavone <pavone@retrodev.com>
parents: 158
diff changeset
23 print: "'" . (" \nfoobar baz " ltrim) . "'\n"
43
27a2167663dd Improve compiler error reporting. Fix operator associativity. Add some more string operations and a string ops sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
24 }
27a2167663dd Improve compiler error reporting. Fix operator associativity. Add some more string operations and a string ops sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
25 }