DGRL Posted February 24, 2018 Share Posted February 24, 2018 Hi all coders Have small issue i cant figure out I have a list (("Titel01" "Titel02" "Titel03" "0000000" "1" "1" "justaword" "A. bC" "03-12-09" )) This is just an example What i need is to add ' to the integers only so the list would look like (("Titel01" "Titel02" "Titel03" "'0000000" "'1" "'1" "justaword" "A. bC" "'03-12-09" )) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 24, 2018 Share Posted February 24, 2018 For integers only: _$ (mapcar '(lambda ( x ) (if (= 'int (type (read x))) (strcat "'" x) x)) '("Titel01" "Titel02" "Titel03" "0000000" "1" "1" "justaword" "A. bC" "03-12-09")) ("Titel01" "Titel02" "Titel03" "'0000000" "'1" "'1" "justaword" "A. bC" "03-12-09") For items starting with numbers: _$ (mapcar '(lambda ( x ) (if (< 47 (ascii x) 58) (strcat "'" x) x)) '("Titel01" "Titel02" "Titel03" "0000000" "1" "1" "justaword" "A. bC" "03-12-09")) ("Titel01" "Titel02" "Titel03" "'0000000" "'1" "'1" "justaword" "A. bC" "'03-12-09") Quote Link to comment Share on other sites More sharing options...
DGRL Posted February 24, 2018 Author Share Posted February 24, 2018 Thanks this is what i need Forget about the error i mentioned I pasted the string twice lol Quote Link to comment Share on other sites More sharing options...
DGRL Posted February 24, 2018 Author Share Posted February 24, 2018 @Lee Mac How would the code be for both situations you gave if i want to remove the int from the string? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.