code: 9ferno

ref: 670f4e90ee6028ffee399e5a96fb5e4cd72fc7bc
dir: /module/string.m/

View raw version
String: module
{
	PATH:		con	"/dis/lib/string.dis";

	# the second arg of the following is a character class
	#    e.g., "a-zA-Z", or "^ \t\n"
	# (ranges indicated by - except in first position;
	#  ^ is first position means "not in" the following class)
	# splitl splits just before first char in class;  (s, "") if no split
	# splitr splits just after last char in class; ("", s) if no split
	# drop removes maximal prefix in class
	# take returns maximal prefix in class

	splitl:		fn(s, cl: string): (string, string);
	splitr:		fn(s, cl: string): (string, string);
	drop:		fn(s, cl: string): string;
	take:		fn(s, cl: string): string;
	in:			fn(c: int, cl: string): int;
	containscl:	fn(s, cl: string): int;
	countcl:	fn(s: string, cl: string): int;

	# in these, the second string is a string to match, not a class
	splitstrl:	fn(s, t: string): (string, string);
	splitstrr:	fn(s, t: string): (string, string);
	replace:	fn(in, s, with: string, max: int): string;
	contains:	fn(in, s: string): int;

	# is first arg a prefix of second?
	prefix:		fn(pre, s: string): int;

	tolower:	fn(s: string): string;
	toupper:	fn(s: string): string;
	hasws:		fn(s: string): int;

	# string to int returning value, remainder
	toint:		fn(s: string, base: int): (int, string);
	tobig:		fn(s: string, base: int): (big, string);
	toreal:		fn(s: string, base: int): (real, string);

	# append s to end of l
	append:		fn(s: string, l: list of string): list of string;
	quoted:		fn(argv: list of string): string;
	quotedc:		fn(argv: list of string, cl: string): string;
	unquoted:		fn(args: string): list of string;
	fields:		fn(s: string): list of string;
	qtokenize:	fn(s: string): (list of string, string);
};