Author Topic: Convert a List to a String ...  (Read 6589 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Convert a List to a String ...
« Reply #15 on: May 26, 2010, 03:11:09 PM »
'del' is an argument for the function.

del = delimiter, as in my explanation  :-)

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Convert a List to a String ...
« Reply #16 on: May 26, 2010, 03:32:13 PM »
'del' is an argument for the function.

del = delimiter, as in my explanation  :-)
:lmao: :lmao:
My mind was clearly somewhere else. I called it deliminator in my explanation. :ugly:
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Convert a List to a String ...
« Reply #17 on: May 26, 2010, 06:20:43 PM »
'del' is an argument for the function.

del = delimiter, as in my explanation  :-)
:lmao: :lmao:
My mind was clearly somewhere else. I called it deliminator in my explanation. :ugly:

That does sound cooler  :lol:

Hangman

  • Swamp Rat
  • Posts: 566
Re: Convert a List to a String ...
« Reply #18 on: May 26, 2010, 06:22:58 PM »
'del' is an argument for the function.

del = delimiter, as in my explanation  :-)
:lmao: :lmao:
My mind was clearly somewhere else. I called it deliminator in my explanation. :ugly:

That's what I interpreted,  'del' for delete or deliminator.   :D
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Convert a List to a String ...
« Reply #19 on: May 26, 2010, 06:26:27 PM »
'del' is an argument for the function.

del = delimiter, as in my explanation  :-)
:lmao: :lmao:
My mind was clearly somewhere else. I called it deliminator in my explanation. :ugly:

That does sound cooler  :lol:

It travels back in time and delimits all John and Sarah Connor's text.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Convert a List to a String ...
« Reply #20 on: May 26, 2010, 11:16:00 PM »
Just something I was considering ... several options are available, but they don't give you the option to add a delimiter, unless of course you use lambda or some other equally useful function ... i.e.
Code: [Select]
(defun list->string (mylist)
  (apply 'strcat mylist)
)

(defun list->string (mylist delim)
  (setq str (car mylist))
  (vl-every '(lambda (x) (setq str (strcat str delim x))) (cdr mylist))
  str


The second bit of code, while not nearly as concise, allows the addition of delimiters.

To further expand the code, one might do a check for numerical values and convert them explicitly to strings ... that will likely require a bit of code to check for various situations, but as long as the type is going to be string, it may not be required.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie