view samples/stringops.tp @ 259:32964a4e7a33

Add ltrim method to string
author Michael Pavone <pavone@retrodev.com>
date Thu, 29 May 2014 18:51:15 -0700
parents 38140b7dbe3d
children a4c2b31acba7
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"
	}
}