Newbie lisp problem: string to list of strings separated by space
- From: Yossarian <yossarian@xxxxxxxxxxx>
- Date: Thu, 30 Mar 2006 11:21:02 +0200
Hi,
I am trying to write a very simple function that accepts a string as input, and that returns a list of strings as output, having a seperate list item for every substring without a space.
Example:
input = "something very odd"
output = ("something" "very" "odd")
I tried to do this with the following function, but I can't understand why it is not working.
(defun parse(a)
(setq pos (or (position #\space a) -1) )
(cond ((= pos -1) (list a))
((> pos -1) (append
(parse (subseq a 0 pos))
(parse (subseq a (+ pos 1) (length a)))))))
Any comment is welcome!
Regards,
Wouter
.
- Follow-Ups:
- Re: Newbie lisp problem: string to list of strings separated by space
- From: Alan Crowe
- Re: Newbie lisp problem: string to list of strings separated by space
- From: Dmitry Gorbatovsky
- Re: Newbie lisp problem: string to list of strings separated by space
- From: John Landahl
- Re: Newbie lisp problem: string to list of strings separated by space
- From: Pascal Bourguignon
- Re: Newbie lisp problem: string to list of strings separated by space
- Prev by Date: Re: Recovering from an exception
- Next by Date: Re: packages, load paths and environment variables
- Previous by thread: (make-pathname :name "/root") - good/bad?
- Next by thread: Re: Newbie lisp problem: string to list of strings separated by space
- Index(es):
Relevant Pages
|
|