Documentation for package rsm.string


Author : R. Scott McIntire

Version: 1.1

Overview:

This package provides string manipulation functions.

Export Summary:

contains: Returns all strings in a list that contain any strings in a list of 
          string fragments. 
does-not-contain: Returns all strings in a list that DO NOT contain 
                  any strings in a list of string fragments.
file->string:   Reads a file returning a string of its contents.
file->number-list: Returns a list of numbers read from a text file.
file->number-table: Returns a list of a list of numbers after reading a file.
file->string-list: Returns a list of strings read from a text file.
file->string-table: Returns a list of a list of strings after reading a file.
fluff-string: Return a new string that wraps a character
              around every character in the supplied string.
join: Concatenate the strings in a list returning a new string.
list->file: Write a list out to a file.
number-list->file: Write a list of numbers (one per line) to a file.
split: Split a string into a list of strings.
string->file: Writes a string to a file.
string->number: Convert a string representing a number to a number.

contains   (str-list elem-list &key (contain-meaning #'some))

Returns all strings in <str-list> that contain strings in <elem-list>; where
the meaning of contains is provided in the function <contain-meaning>.
<contain-meaning> must take a function and a list as an argument.
Example: (rsm.string:contains '("abc" "def" "ghi") '("bc" "gh"))
("abc" "ghi")

does-not-contain   (str-list str-elems &key (unique nil))

Return a list of strings from the string list, <str-list>, that do not
contain any of the strings from the list of strings <str-elems.> If unique is
non nil, then the resulting list will remove duplicates. In any event, the
order of the list may change.
Example: (rsm.string:does-not-contain '("abc" "def" "ghi") '("ab" "gh"))
("def")

file->number-list   (file-name &key (delims " ") (missing-value-marker nil))

Takes a file name and a key word of delimiters and returns a list of
strings that are delimited by any character in <delims>. If 
<missing-value-marker> is non nil, then <missing-value-marker> will be used
for missing values.

file->number-table   (file-name &key (delims " ") (missing-value-marker nil) (header nil))

Takes a file name and a a key word of delimiters and returns a table - 
a list of lists of numbers. The rows are the lines of the file; within 
each row, the nth column element is the nth (non-null) number. If 
<missing-value-marker> is non nil, then <missing-value-marker> will be used
for missing values. If <header> is non-nil and a number, the first <header>
lines will be discarded. Otherwise, if <header> is non-nil, then the first
line will be discarded.

file->string   (file-name)

Reads file <file-name> returning a string of its contents.

file->string-list   (file-name &key (delims " ") (missing-value-marker nil))

Takes a file name and a key word of delimiters and returns a list of
strings that are delimited by any character in <delims>. If 
<missing-value-marker> is non nil, then <missing-value-marker> 
will be used for missing values.

file->string-table   (file-name &key (delims " ") (missing-value-marker nil) (header nil))

Takes a file name and a key word of delimiters and returns a table - 
a list of lists of strings. The rows are the lines of the file; within 
each row, the nth column element is the the nth (non-null) delimited string. 
If <missing-value-marker> is non nil, then <missing-value-marker> will be used
for missing values. If <header> is non-nil and a number, the first <header>
lines will be discarded. Otherwise, if <header> is non-nil, then the first
line will be discarded.

fluff-string   (str about-string &key (fluff-char #\Space))

Return a new string that wraps the character <fluff-char> around every
character in the string <about-string>.
Example: (rsm.string:fluff-string "123+345+567" "+" :fluff-string #Space )
"123 + 345 + 567"

join   (str-list &key (join-string nil))

Returns a new string formed by joining all the strings in <str-list>. 
If <join-string> is non-nil, it is used as a joining string between 
elements of the list.
Example: (rsm.string:join '("abc" "def" "ghi") :join-string "_")
"abc_def_ghi"

list->file   (list file-name)

Write out a list to a file. As the list structure is intact, the list can be
read back in with a single call to the reader.

number-list->file   (num-list file-name)

Writes a list of numbers out to a file with one line for each number.

split   (str &key (delims " ") (reverse nil) (missing-value-marker nil))

Returns a list of strings formed by splitting <str> at any character
contained in <delims>. If <missing-value-marker> is non-nil, then
<missing-value-marker> is used when no text is found between delimiters.
Example: (rsm.string:split "abc def ghi" :delims " ")
("abc" "def" "ghi")

string->file   (string file-name)

Writes the string, <string>, out to the file, <file-name>. If the 
file exists it will be replaced.

string->number   (str)

Convert a string <str> representing a number to a number. A second value is
returned indicating the success of the conversion.
Example: (rsm.string:string->number "123")
123 t