[M3devel] some quake proposals for more string functions?

Jay K jay.krell at cornell.edu
Sun Jun 5 09:46:56 CEST 2016


A new abstract type that represents a set of characters:

  It might actually be a string underneath with 0 or 1 at each position, to aid ease of implementation.
  or a 2-array of 64-bit integers (implied that only characters 0-127 can be in a set)


And then functions that indicate how many characters from a set a string contains, or starts with, or ends with?

a = CharSet("a")
fo = CharSet("fo")
foo = CharSet("foo") % redundant but ok
fo == foo


StringCountSet("foo", a) :0 % how many characters in set a are in string "foo"
StringStartsSet("foo", fo) : 3 % how many characters in set fo does string "foo" start with
StringEndSet("food", fo) : 0 % how many characters in set fo does string "food" end with
FindFirstCharInSet("foo", fo): 0
FindFirstCharInSet("foo", CharSet("d"): -1 or length("foo") ?
FindNextCharInSet("foo", fo, 0): 1 ?
Might want to combine first/next functions, and require initialOffset and maximumOffset parameters?


StringOnlyContainsCharsInSet(str, set):
  return StringStartsSet(str, set) = length(str)


StringContainsNoCharsInSet(str, set):
  return StringCountSet(str, set) = 0

StringRemoveCharsInSetFromStart(str, set):
  return sub(str, StringStartsSet(str, set), length(str))

StringRemoveCharsInSetFromEnd(str, set):
  return sub(str, lenth(str) - StringStartsSet(str, set), length(str))


and then, really, we might add regexps find and find+replace, another day/year?


There is some overlap here with the stuff Olaf put in, granted.


Thank you,
 - Jay 		 	   		  


More information about the M3devel mailing list