Re: splicing with subst



Andy Chambers <achambers.home@xxxxxxxxxxxxxx> writes:

On Apr 27, 5:59 pm, Pascal Bourguignon <p...@xxxxxxxxxxxxxxxxx> wrote:
Andy Chambers <achambers.h...@xxxxxxxxxxxxxx> writes:
Hi,

I'd like to transform a tree such that a marker sexp is replaced by an
inline list of sexp's. For example....

'(list
(string)
(marker))

should be replaced with....

'(list
(string)
(one) (two) (three))

Why do you have this form: (quote (list (string) (marker)))

The question was some nitpicking on my part about why did you write
'(list (string) (marker))
instead of: (list (string) (marker))
when you spoke of data.

If you say that you have a list '(a b c)
it means you have a list of two elements, quote and (a b c),
since '(a b c) is equivalent to (quote (a b c))
^ ^ ^
| | |
| | +--- second element
| +--------first element
+-----------a list

Try:

C/USER[57]> (length (read)) ; you enter this program
'(a b c) ; then you enter this data

2 ; and you get this result.


To put a list '(a b c) in a program, to avoid it being evaluated you
have to quote once more:



C/USER[59]> (let ((x ''(a b c)))
(print (length x))
(print (first x))
(print (second x))
x)

2 ; printed
QUOTE ; printed
(A B C) ; printed
'(A B C) ; result, printed by the REPL;
; this is a list of 2 elements:

C/USER[60]> (length *)
2


(a b c) would be equal to the list returned as result of the
evaluation of the form '(a b c) or (quote (a b c)).

So you could say that you have the list resulting from '(a b c),
and this would be understood as being (a b c).

But '(a b c) itself is a list (data), as any non atomic form, and it
_is_ the list containing only quote and (a b c). On the other hand,
'(a b c) is a form (program), which can be _evaluated_ and which would
return the list (a b c). Note that if a was the name of a function,
and b and c the names of variables, (a b c) would also be a form, that
could also be evaluated...


--
__Pascal Bourguignon__ http://www.informatimago.com/

"This statement is false." In Lisp: (defun Q () (eq nil (Q)))
.



Relevant Pages

  • Re: Difference between and : symbols
    ... lisp> ... You can inhibit evaluation with the special operator QUOTE. ... The specific thing that confused you is why ASDF functions ... But what ASDF really wants is a string. ...
    (comp.lang.lisp)
  • Re: fastest way to change case of string
    ... string rather than concatenating a new string is indeed much faster. ... Dim quoted As Collection ... Const QUOTE = "'" ... ChangeCaseX = StrConv ...
    (microsoft.public.vb.general.discussion)
  • MD5 Hash with single quote = grief in dao.findfirst
    ... I know when you need to create a query string and the data contains a single ... quote, you must double the quote as an escape sequence. ... Hundreds of assumption cells combined into one 16 character Hash. ... I build the criteria SQL string. ...
    (microsoft.public.access.modulesdaovba)
  • RE: VBA, and SaveAs Function
    ... The type mismatch comes about in the Str functions in your SaveAs line; ... you're passing a string to a function that expects a number. ... > I have been creating a quote module for the project managers at my lab, ... > save to a unique file, and I am up against a wall. ...
    (microsoft.public.excel.programming)
  • Re: getting a form field to default to the value entered in the last record
    ... >Access will know the value is a string. ... the evaluation of "Date" is just the string Date. ... that the DefaultValue property has your characters inside ... The rule for using a quote inside quotes is to double up the ...
    (microsoft.public.access.formscoding)