]> gitweb.factorcode.org Git - factor.git/blob - core/collections/strings.facts
more sql changes
[factor.git] / core / collections / strings.facts
1 USING: arrays help kernel kernel-internals sequences strings
2 vectors ;
3
4 HELP: string
5 { $description "The class of fixed-length character strings. See " { $link "syntax-strings" } " for syntax and " { $link "strings" } " for general information." } ;
6
7 HELP: char-slot ( n string -- ch )
8 { $values { "n" "a fixnum" } { "string" "a string" } { "ch" "the character at the " { $snippet "n" } "th index" } }
9 { $description "Unsafe string accessor, used to define " { $link nth } " on strings." }
10 { $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." } ;
11
12 HELP: set-char-slot ( ch n string -- )
13 { $values { "ch" "a character" } { "n" "a fixnum" } { "string" "a string" }  }
14 { $description "Unsafe string mutator, used to define " { $link set-nth } " on strings." }
15 { $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." } ;
16
17 HELP: <string> ( n ch -- string )
18 { $values { "n" "a positive integer specifying string length" } { "elt" "an initial character" } }
19 { $description "Creates a new string with the given length and all characters initially set to " { $snippet "ch" } "." }
20 { $see-also <array> <quotation> <sbuf> <vector> } ;
21
22 HELP: blank
23 { $class-description "Class of integers denoting ASCII whitespace characters." } ;
24
25 HELP: letter
26 { $class-description "Class of integers denoting lowercase alphabet ASCII characters." } ;
27
28 HELP: LETTER
29 { $class-description "Class of integers denoting uppercase alphabet ASCII characters." } ;
30
31 HELP: digit
32 { $class-description "Class of integers denoting ASCII decimal digit characters." } ;
33
34 HELP: Letter
35 { $class-description "Class of integers denoting ASCII alphabet characters, both upper and lower case." } ;
36
37 HELP: alpha
38 { $class-description "Class of integers denoting alphanumeric ASCII characters." } ;
39
40 HELP: alpha
41 { $class-description "Class of integers denoting printable ASCII characters." } ;
42
43 HELP: alpha
44 { $class-description "Class of integers denoting ASCII control characters." } ;
45
46 HELP: alpha
47 { $class-description "Class of integers denoting characters which may appear in a Factor string literal without escaping." } ;
48
49 HELP: ch>lower
50 { $values { "ch" "a character" } { "lower" "a character" } }
51 { $description "Converts a character to lowercase." } ;
52
53 HELP: ch>upper
54 { $values { "ch" "a character" } { "lower" "a character" } }
55 { $description "Converts a character to uppercase." } ;
56
57 HELP: >lower
58 { $values { "str" "a string" } { "lower" "a string" } }
59 { $description "Converts a string to lowercase." } ;
60
61 HELP: >upper
62 { $values { "str" "a string" } { "upper" "a string" } }
63 { $description "Converts a string to uppercase." } ;
64
65 HELP: ch>string
66 { $values { "ch" "a character"} { "str" "a new string" } }
67 { $description "Outputs a string of one character." } ;
68
69 HELP: >string
70 { $values { "seq" "a sequence of characters" } { "str" "a new string" } }
71 { $description "Outputs a freshly-allocated string with the same elements as a given sequence." }
72 { $errors "Throws an error if the sequence contains elements other than real numbers." }
73 { $see-also >array >sbuf >vector >quotation } ;
74
75 HELP: resize-string ( n str -- newstr )
76 { $values { "n" "a non-negative integer" } { "str" "a string" } { "newstr" "a new string" } }
77 { $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" } "." } ;