[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
newlispfanclub.alh.net • View topic - replace parentheses of a list with quotation marks

replace parentheses of a list with quotation marks

Q&A's, tips, howto's

replace parentheses of a list with quotation marks

Postby lyl » Wed Sep 25, 2019 2:28 am

(setq a "time")
(setq b '(set xlabel a))

My question is:
how to design a function to transfer a list("b" in this example) into a string. That is to say, replace the parentheses of b with quotation marks to get "set xlabel "time"".
lyl
 
Posts: 37
Joined: Sun Mar 25, 2018 5:00 am

Re: replace parentheses of a list with quotation marks

Postby cameyo » Wed Sep 25, 2019 3:37 pm

cameyo
 
Posts: 97
Joined: Sun Mar 27, 2011 3:07 pm

Re: replace parentheses of a list with quotation marks

Postby lyl » Thu Sep 26, 2019 6:42 am

Thank you, cameyo.
In my example, the expression that is to be evaled is the last element in the list which make it possible to use (setf (last lst)...) evaluating the expression. I wonder if there is an universal method to evluating any expression at any position in a list. Here I'd like give another example:

(setq lst '(set "outcome" (+ 1 2) dollars)

in which such a string: "set "outcome" 3 dollars" is wanted.

PS:
I think (list ...) may be a method, but thinking of those elements that can not be evaluated, it's a bit complicated.
lyl
 
Posts: 37
Joined: Sun Mar 25, 2018 5:00 am


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 1 guest

cron