Author Topic: Taking the spaces out of a list.  (Read 1857 times)

0 Members and 1 Guest are viewing this topic.

crowellsr

  • Guest
Taking the spaces out of a list.
« on: July 29, 2007, 08:03:25 PM »
I have a list of numbers that I want tot take the spaces out of and make it into a string.

Example list :(83 84 69 86 69) wanted result: 8384698669

I think there is a function that does this but I can't remember so I am counting on you experts to refresh my memory. The list is stored in a variable not user inputted.

Steve

Jeff_M

  • King Gator
  • Posts: 4097
  • C3D user & customizer
Re: Taking the spaces out of a list.
« Reply #1 on: July 29, 2007, 08:20:21 PM »
Code: [Select]
(setq testlist '(83 84 69 86 69))
(apply 'strcat (mapcar 'itoa testlist))

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Taking the spaces out of a list.
« Reply #2 on: July 29, 2007, 08:30:39 PM »
Good one Jeff.

If the list is never nested but may contain multiple data types substituting vl-princ-to-string
for itoa might be a touch more flexible. If the list is nested then one has to determine how the
nesting should be represented ... parenthesis retained etc (or not), but probably miles from the
intent of the original poster, so not going there.

:)
« Last Edit: July 29, 2007, 08:33:35 PM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

crowellsr

  • Guest
Re: Taking the spaces out of a list.
« Reply #3 on: July 29, 2007, 08:47:46 PM »
Thanks for the quick response guys.

It is working perfectly now.

Steve