blob: 38c0459837ccd1fd3c1513a7123c77b79ba24fb8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
.TH SYS-TOKENIZE 2
.SH NAME
tokenize \- split string into words
.SH SYNOPSIS
.EX
include "sys.m";
sys := load Sys Sys->PATH;
tokenize: fn(s, delim: string): (int, list of string);
.EE
.SH DESCRIPTION
.B Tokenize
breaks
.I s
into words separated by characters in
.IR delim .
The returned tuple holds the number of words
and an ordered list of those words (whose
.B hd
gives the leftmost word from
.IR s ).
.PP
Words are delimited by the maximal sequences of any
character from the
.I delim
string.
.B Tokenize
skips delimiter characters at the beginning and end of
.IR s ,
so each element in the returned list has non-zero length.
.PP
If
.I s
is
.B nil
or contains no words,
.B tokenize
returns a count of zero and a
.B nil
list.
.PP
.I Delim
may be
.B nil
or the empty string, specifying no delimiter characters.
The resulting word list will be
.B nil
(if
.I s
is
.B nil
or the empty string)
or a single-item list with a copy of
.IR s .
.SH SEE ALSO
.IR sys-intro (2)
|