Jump to content

Recommended Posts

Posted

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" ))

Posted

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")

Posted

Thanks this is what i need

 

Forget about the error i mentioned

I pasted the string twice lol

Posted

@Lee Mac

 

How would the code be for both situations you gave if i want to remove the int from the string?

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...