Loop through strings
Posted: Thu Feb 16, 2012 5:54 pm
I need help to find the function which takes two arguments and returns a string with only the characters that are found in exactly one of the strings and with no character repeated. Example: If I give (stringll "goodbye" "oddly"), it shoul return "gbel"
My code works with 3 arguments, I need ur suggestions to do this wih two arguments. Its urgent..
My code works with 3 arguments, I need ur suggestions to do this wih two arguments. Its urgent..
Code: Select all
(defun stringll(str1 str2 str3)
(defparameter *str1* (string str1))
(defparameter *str2* (string str2))
(setf s1 str3)
(delete-duplicates *str1*)
(delete-duplicates s1)
(delete-duplicates *str2*)
(loop for i from 0 to (1-(length s1)) do
(if (find (char s1 i) *str2*)
(progn(defparameter *temp* (string (find (char s1 i) *str2*)))
(delete (char *temp* 0) *str2*)
(delete (char *temp* 0) *str1*))))
(concatenate 'string *str1* *str2*))