Changeset 34317 in project


Ignore:
Timestamp:
08/21/17 19:14:03 (3 months ago)
Author:
sjamaan
Message:

man/5: Create chapter Module (chicken string)

Location:
wiki/man/5
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • wiki/man/5/Included modules

    r34261 r34317  
    4242* [[Module (chicken read-syntax)]] : Creating syntactic extensions to the reader
    4343* [[Module (chicken repl)]] : Creating a Read-Eval-Print Loop
     44* [[Module (chicken sort)]] : Sorting lists and vectors
     45* [[Module (chicken string)]] : String operations
    4446* [[Module (chicken syntax)]] : Creating syntactic extensions (macros)
    4547* [[Module (chicken tcp)]] : Connecting over the network via TCP
  • wiki/man/5/Module (chicken sort)

    r34294 r34317  
    7070Previous: [[Module (chicken repl)]]
    7171
    72 Next: [[Module (chicken syntax)]]
     72Next: [[Module (chicken string)]]
  • wiki/man/5/Module (chicken syntax)

    r34294 r34317  
    77
    88---
    9 Previous: [[Module (chicken sort)]]
     9Previous: [[Module (chicken string)]]
    1010
    1111Next: [[Module (chicken tcp)]]
  • wiki/man/5/TODO/Unit data-structures

    r34294 r34317  
    124124
    125125
    126 === Strings
    127 
    128 
    129 ==== conc
    130 
    131 <procedure>(conc X ...)</procedure>
    132 
    133 Returns a string with the string-represenation of all arguments concatenated
    134 together. {{conc}} could be implemented as
    135 
    136 <enscript highlight=scheme>
    137 (define (conc . args)
    138   (apply string-append (map ->string args)) )
    139 </enscript>
    140 
    141 
    142 
    143 ==== ->string
    144 
    145 <procedure>(->string X)</procedure>
    146 
    147 Returns a string-representation of {{X}}.
    148 
    149 
    150 ==== string-chop
    151 
    152 <procedure>(string-chop STRING LENGTH)</procedure>
    153 
    154 Returns a list of substrings taken by ''chopping'' {{STRING}} every {{LENGTH}}
    155 characters:
    156 
    157 <enscript highlight=scheme>
    158 (string-chop "one two three" 4)  ==>  ("one " "two " "thre" "e")
    159 </enscript>
    160 
    161 
    162 
    163 ==== string-chomp
    164 
    165 <procedure>(string-chomp STRING [SUFFIX])</procedure>
    166 
    167 If {{STRING}} ends with {{SUFFIX}}, then this procedure returns a copy of its first argument with the suffix
    168 removed, otherwise returns {{STRING}} unchanged. {{SUFFIX}} defaults to {{"\n"}}.
    169 
    170 
    171 ==== string-compare3
    172 
    173 <procedure>(string-compare3 STRING1 STRING2)</procedure><br>
    174 <procedure>(string-compare3-ci STRING1 STRING2)</procedure>
    175 
    176 Perform a three-way comparison between the {{STRING1}} and {{STRING2}},
    177 returning either {{-1}} if {{STRING1}} is lexicographically less
    178 than {{STRING2}}, {{0}} if it is equal, or {{1}} if it s greater.
    179 {{string-compare3-ci}} performs a case-insensitive comparison.
    180 
    181 
    182 ==== string-intersperse
    183 
    184 <procedure>(string-intersperse LIST [STRING])</procedure>
    185 
    186 Returns a string that contains all strings in {{LIST}} concatenated
    187 together.  {{STRING}} is placed between each concatenated string and
    188 defaults to {{" "}}.
    189 
    190 <enscript highlight=scheme>
    191 (string-intersperse '("one" "two") "three")
    192 </enscript>
    193 
    194 is equivalent to
    195 
    196 <enscript highlight=scheme>
    197 (apply string-append (intersperse '("one" "two") "three"))
    198 </enscript>
    199 
    200 
    201 ==== string-split
    202 
    203 <procedure>(string-split STRING [DELIMITER-STRING [KEEPEMPTY]])</procedure>
    204 
    205 Split string into substrings delimited by any of the characters given in the delimiter string. If
    206 no delimiters are specified, a string comprising the tab, newline and space characters
    207 is assumed. If the
    208 parameter {{KEEPEMPTY}} is given and not {{#f}}, then empty
    209 substrings are retained:
    210 
    211 <enscript highlight=scheme>
    212 (string-split "one  two  three") ==> ("one" "two" "three")
    213 (string-split "foo:bar::baz:" ":" #t) ==> ("foo" "bar" "" "baz" "")
    214 (string-split "foo:bar:baz,quux,zot" ":," ) ==> ("foo" "bar" "baz" "quux" "zot")
    215 </enscript>
    216 
    217 
    218 ==== string-translate
    219 
    220 <procedure>(string-translate STRING FROM [TO])</procedure>
    221 
    222 Returns a fresh copy of {{STRING}} with characters matching
    223 {{FROM}} translated to {{TO}}.  If {{TO}} is omitted, then
    224 matching characters are removed. {{FROM}} and {{TO}} may be
    225 a character, a string or a list. If both {{FROM}} and {{TO}}
    226 are strings, then the character at the same position in {{TO}}
    227 as the matching character in {{FROM}} is substituted.
    228 
    229 
    230 ==== string-translate*
    231 
    232 <procedure>(string-translate* STRING SMAP)</procedure>
    233 
    234 Substitutes elements of {{STRING}} according to {{SMAP}}.
    235 {{SMAP}} should be an association-list where each element of the list
    236 is a pair of the form {{(MATCH . REPLACEMENT)}}. Every occurrence of
    237 the string {{MATCH}} in {{STRING}} will be replaced by the string
    238 {{REPLACEMENT}}:
    239 
    240 <enscript highlight=scheme>
    241 (string-translate*
    242   "<h1>this is a \"string\"</h1>"
    243   '(("<" . "&lt;") (">" . "&gt;") ("\"" . "&quot;")) )
    244 =>  "&lt;h1&gt;this is a &quot;string&quot;&lt;/h1&gt;"
    245 </enscript>
    246 
    247 
    248 ==== substring=?
    249 
    250 <procedure>(substring=? STRING1 STRING2 [START1 [START2 [LENGTH]]])</procedure><br>
    251 <procedure>(substring-ci=? STRING1 STRING2 [START1 [START2 [LENGTH]]])</procedure>
    252 
    253 Returns {{#t}} if the strings {{STRING1}} and {{STRING2}} are equal, or
    254 {{#f}} otherwise.
    255 The comparison starts at the positions {{START1}} and {{START2}} (which default
    256 to 0), comparing {{LENGTH}} characters (which defaults to the minimum of the remaining
    257 length of both strings).
    258 
    259 
    260 ==== substring-index
    261 
    262 <procedure>(substring-index WHICH WHERE [START])</procedure><br>
    263 <procedure>(substring-index-ci WHICH WHERE [START])</procedure>
    264 
    265 Searches for first index in string {{WHERE}} where string
    266 {{WHICH}} occurs.  If the optional argument {{START}} is given,
    267 then the search starts at that index.  {{substring-index-ci}}
    268 is a case-insensitive version of {{substring-index}}.
    269 
    270 
    271 ==== reverse-string-append
    272 
    273 <procedure>(reverse-string-append LIST)</procedure>
    274 
    275 {{(apply string-append (reverse LIST))}}
    276 
    277 
    278126=== Combinators
    279127
  • wiki/man/5/TODO/Unit library

    r34288 r34317  
    327327using the {{=}} operator, so {{equal=?}} allows structural comparison
    328328in combination with comparison of numerical data by value.
    329 
    330 
    331 
    332 === String utilities
    333 
    334 
    335 ==== reverse-list->string
    336 
    337 <procedure>(reverse-list->string LIST)</procedure>
    338 
    339 Returns a string with the characters in {{LIST}} in reverse order. This is
    340 equivalent to {{(list->string (reverse LIST))}}, but much more efficient.
    341329
    342330
  • wiki/man/5/TODO/new-manual.org

    r34294 r34317  
    4545** Module (chicken repl) : Creating a Read-Eval-Print Loop
    4646** Module (chicken sort) : Sorting lists and vectors
     47** Module (chicken string) : String operations
    4748** Module (chicken syntax) : Creating syntactic extensions (macros)
    4849** Module (chicken tcp) : Connecting over the network via TCP
Note: See TracChangeset for help on using the changeset viewer.