Just a note: the split-words implementation appears to miss the last
word of the line.
I also have an alternative implementation I previously wrote, which you
can license and use as needed if you happen to prefer it, but in my
case I made it return an array rather than a list (attached).
Thanks,
--
Matt
(defun white-space-p (c)
"Returns T if character C consists of a space, tabulator or newline,
NIL otherwise."
(member c '(#\Space #\Tab #\Newline)))
(defun split-string-words (string &key (start 0) (end nil) (max nil)
(separator #'white-space-p))
"Returns an array containing the words from STRING as well as the number
of words returned. Begins looking for words at offset START (default 0),
stops before END (default NIL for end of string) and will return a maximum
of MAX words (default NIL for no limit). The SEPARATOR function should
return T for chars matching the wanted separators, or NIL (defaults to
WHITE-SPACE-P)."
(declare (type fixnum start)
(type (or null fixnum) end max))
(let ((array (make-array 0
:fill-pointer t
:adjustable t))
(array-len 0)
(s start))
(declare (type fixnum array-len)
(type (or null fixnum s)))
(unless end
(setf end (length string)))
(when max
(decf max))
(loop
for i of-type fixnum from s below end
until (and max (< max array-len))
while (setf s (position-if-not separator string :start i))
do
(setf i (or (position-if separator string :start s)
end))
(vector-push-extend (subseq string s i) array 1)
(incf array-len))
(values array array-len)))
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Ecls-list mailing list
Ecls-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ecls-list