William James
11/28/2015 6:41:00 AM
WJ wrote:
> M. Pitman wrote:
>
> > Erik Naggum <erik@naggum.net> writes:
> >
> > > (defun get-elements (sequence)
> > > (loop
> > > for start = 0 then (1+ end)
> > > for end = (position #\Space sequence :start start)
> > > collect (subseq sequence start end)
> > > until (not end)))
> >
> > Or
> >
> > (defun get-elements (sequence)
> > (loop with len = (length sequence)
> > for start = 0 then (1+ end)
> > for end = (position #\Space sequence :start start)
> > unless (eql start (or end len))
> > collect (subseq sequence start end)
> > until (not end)))
> >
> > which is more tolerant of strings like " foo bar baz ".
Ocaml:
#load "str.cma";;
Str.split (Str.regexp " +") " foo bar baz ";;
===>
["foo"; "bar"; "baz"]
--
The struggle of our time is to concentrate, not to dissipate: to renew our
association with traditional wisdom: to re-establish a vital connection between
the individual and the race. It is, in a word, a struggle against Liberalism.
--- T. S. Elliot