factor/library/collections/strings.facts

78 lines
3.7 KiB
Plaintext
Raw Normal View History

USING: arrays help kernel kernel-internals sequences strings
vectors ;
2006-08-16 21:55:53 -04:00
HELP: string
{ $description "The class of fixed-length character strings. See " { $link "syntax-strings" } " for syntax and " { $link "strings" } " for general information." } ;
2006-08-16 21:55:53 -04:00
HELP: char-slot ( n string -- ch )
{ $values { "n" "a fixnum" } { "string" "a string" } { "ch" "the character at the " { $snippet "n" } "th index" } }
{ $description "Unsafe string accessor, used to define " { $link nth } " on strings." }
{ $warning "This word is in the " { $vocab-link "kernel-internals" } " vocabulary because it does not perform type or bounds checking. User code should call " { $link nth } " instead." } ;
2006-08-16 21:55:53 -04:00
HELP: set-char-slot ( ch n string -- )
{ $values { "ch" "a character" } { "n" "a fixnum" } { "string" "a string" } }
{ $description "Unsafe string mutator, used to define " { $link set-nth } " on strings." }
{ $warning "This word is in the " { $vocab-link "kernel-internals" } " vocabulary because it does not perform type or bounds checking. User code should call " { $link set-nth } " instead." } ;
2006-01-02 00:51:03 -05:00
2006-08-16 21:55:53 -04:00
HELP: <string> ( n ch -- string )
2006-01-02 00:51:03 -05:00
{ $values { "n" "a positive integer specifying string length" } { "elt" "an initial character" } }
{ $description "Creates a new string with the given length and all characters initially set to " { $snippet "ch" } "." }
{ $see-also <array> <quotation> <sbuf> <vector> } ;
2006-01-02 00:51:03 -05:00
2006-08-16 21:55:53 -04:00
HELP: blank
{ $class-description "Class of integers denoting ASCII whitespace characters." } ;
2006-01-02 00:51:03 -05:00
2006-08-16 21:55:53 -04:00
HELP: letter
{ $class-description "Class of integers denoting lowercase alphabet ASCII characters." } ;
2006-01-02 00:51:03 -05:00
2006-08-16 21:55:53 -04:00
HELP: LETTER
{ $class-description "Class of integers denoting uppercase alphabet ASCII characters." } ;
2006-01-02 00:51:03 -05:00
2006-08-16 21:55:53 -04:00
HELP: digit
{ $class-description "Class of integers denoting ASCII decimal digit characters." } ;
2006-01-02 00:51:03 -05:00
2006-08-16 21:55:53 -04:00
HELP: Letter
{ $class-description "Class of integers denoting ASCII alphabet characters, both upper and lower case." } ;
2006-01-02 00:51:03 -05:00
2006-08-16 21:55:53 -04:00
HELP: alpha
{ $class-description "Class of integers denoting alphanumeric ASCII characters." } ;
2006-01-02 00:51:03 -05:00
2006-08-16 21:55:53 -04:00
HELP: alpha
{ $class-description "Class of integers denoting printable ASCII characters." } ;
HELP: alpha
{ $class-description "Class of integers denoting ASCII control characters." } ;
HELP: alpha
{ $class-description "Class of integers denoting characters which may appear in a Factor string literal without escaping." } ;
HELP: ch>lower
2006-01-02 00:51:03 -05:00
{ $values { "ch" "a character" } { "lower" "a character" } }
{ $description "Converts a character to lowercase." } ;
2006-08-16 21:55:53 -04:00
HELP: ch>upper
2006-01-02 00:51:03 -05:00
{ $values { "ch" "a character" } { "lower" "a character" } }
{ $description "Converts a character to uppercase." } ;
2006-08-16 21:55:53 -04:00
HELP: >lower
2006-01-02 00:51:03 -05:00
{ $values { "str" "a string" } { "lower" "a string" } }
{ $description "Converts a string to lowercase." } ;
2006-08-16 21:55:53 -04:00
HELP: >upper
2006-01-02 00:51:03 -05:00
{ $values { "str" "a string" } { "upper" "a string" } }
{ $description "Converts a string to uppercase." } ;
2006-08-16 21:55:53 -04:00
HELP: ch>string
2006-06-08 18:29:15 -04:00
{ $values { "ch" "a character"} { "str" "a new string" } }
2006-01-02 00:51:03 -05:00
{ $description "Outputs a string of one character." } ;
2006-08-16 21:55:53 -04:00
HELP: >string
2006-01-02 00:51:03 -05:00
{ $values { "seq" "a sequence of characters" } { "str" "a new string" } }
{ $description "Outputs a freshly-allocated string with the same elements as a given sequence." }
{ $errors "Throws an error if the sequence contains elements other than real numbers." }
2006-05-16 16:50:51 -04:00
{ $see-also >array >sbuf >vector >quotation } ;
2006-08-16 21:55:53 -04:00
HELP: resize-string ( n str -- newstr )
{ $values { "n" "a non-negative integer" } { "str" "a string" } { "newstr" "a new string" } }
{ $description "Creates a new string " { $snippet "n" } " characters long The contents of the existing string are copied into the new string; if the new string is shorter, only an initial segment is copied, and if the new string is longer the remaining space is filled with " { $snippet "\u0000" } "." } ;