# # split(s, delimiters, keepall) splits the string s into consecutive substrings # that do/do not consist of characters in the cset delimiters, producing a # list of strings. If keepall is null, strings consisting of delimiters are not # included in the result list. # # If not specified, delimeters defaults to blank and tab, which essentially # "tokenizes" non-whitespace: # # words := split(read()) # # Author: William H. Mitchell (whm@mse.com) c. 1996 # procedure split(s, dlms, keepall) local w, ws, addproc, nullproc ws := [] /dlms := " \t" addproc := put if \keepall then otherproc := put else otherproc := 1 if dlms := (any(dlms, s[1]) & ~dlms) then otherproc :=: addproc s ? while w := tab(many(dlms := ~dlms)) do { addproc(ws, w) otherproc :=: addproc } return ws end