view samples/stringops.tp @ 377:93c28eee141e tip

Merge
author Michael Pavone <pavone@retrodev.com>
date Sat, 15 Aug 2015 22:45:33 -0700
parents 056b8ad76559
children
line wrap: on
line source
#{
	main <- {
		print: "foo: " . 42 . "\n"
		print: (string: (length: "foo" . "bar")) . "\n"
		print: (string: ("foobarbaz" find: "foo" else: { "not found" })) . "\n"
		print: (string: ("foobarbaz" find: "bar" else: { "not found" })) . "\n"
		print: (string: ("foobarbaz" find: "baz" else: { "not found" })) . "\n"
		print: (string: ("foobarbaz" find: "qux" else: { "not found" })) . "\n"

		print: ("foobarbaz" from: 3) . "\n"
		print: ("foobarbaz" from: 3 withLength: 3) . "\n"

		foreach: ("foo,bar,baz,qux" splitOn: ",") :idx val {
			print: val . "\n"
		}

		res <- "foobarbaz" partitionOn: "bar"
		print: "Before: " . (res before) . "\n"
		print: "After: " . (res after) . "\n"

		print: (string: ("12abcDEF" parseHex32)) . "\n"
		print: (string: ("FFFFFFFFFF" parseHex64)) . "\n"
		print: "'" . (" 	\nfoobar baz  " ltrim) . "'\n"
		print: "'" . (" 	\nfoobar baz  " trim) . "'\n"
		print: "'" . (" 	\n\t\r" trim) . "'\n"
		print: (72 utf8) . (101 utf8) . (108 utf8) . (108 utf8) . (111 utf8) . (0x1F604 utf8) . "\n"
	}
}