I am very lost on this one...
problem:
I need to convert a string to lists of characters, split them based on delimiters, and convert back. I also need locally defined functions
the function call would look like
(split string-here delimiters)
(split "Blah, Blah blah!" " ,!")
the function should return ("Blah" "" "Blah" "blah" "")
Being that I'm having trouble with practically every aspect of this function, I figure I can start from the top and hopefully by the end I will have everything figured out. First, Ill start with trying to iterate through a string, converting each character into a list. I actually have something thats somewhat close here, but youll see why its not right.
[52]> (toList "hello" 0)
(#\h #\e #\l #\l #\o)
how do I get rid of the #\
next, i'll try and make this a locally defined function
problem:
I need to convert a string to lists of characters, split them based on delimiters, and convert back. I also need locally defined functions
the function call would look like
(split string-here delimiters)
(split "Blah, Blah blah!" " ,!")
the function should return ("Blah" "" "Blah" "blah" "")
Being that I'm having trouble with practically every aspect of this function, I figure I can start from the top and hopefully by the end I will have everything figured out. First, Ill start with trying to iterate through a string, converting each character into a list. I actually have something thats somewhat close here, but youll see why its not right.
(defun toList (str number) ;(toList(cons(char str (+ number 1))(char str (+ number 2))))) (if (or (null str) (= number (length str))) nil (cons(char str number)(toList str (+ 1 number)) )) );end
[52]> (toList "hello" 0)
(#\h #\e #\l #\l #\o)
how do I get rid of the #\
next, i'll try and make this a locally defined function
(defun split (str delim) (labels toList (str number) (if (or (null str) (= number (length str))) nil (cons(char str number)(toList str (+ 1 number)) )) );end );end