Is there a way to destructive append to the end of string?
Similar to 'push?
destructive append to a string
destructive append to a string
WBR, Dmi
Use:
From the help-file:
From the help-file:
Code: Select all
;; fast in-place string appending
(set 'str "")
(dotimes (x 5) (write-buffer str "hello"))
Hans-Peter
... and 'write-line' works too for destructive string append.
About your XML questions/example. I don't see a streight forward way to do it, but you might look into 'implicit indexing' as a short way of writing/accessing elements or sublists from a deeply complex nested list structure like returned from 'xml-parse':
You may also want to look into 'ref' as a means to get the right indices of an element or sublist in the nested list returned:
This combines 'ref' and implicit indexing. Of course you could also use 'nth', 'first', 'last' etc., but it is more to write (and sometimes more readable too).
Lutz
About your XML questions/example. I don't see a streight forward way to do it, but you might look into 'implicit indexing' as a short way of writing/accessing elements or sublists from a deeply complex nested list structure like returned from 'xml-parse':
Code: Select all
(xml-type-tags nil nil nil nil)
(set 'page (xml-parse (read-file "myfile.xml") (+ 1 4 8 16)))
(set 'sheet-type (page 0 2 4 1 0))
Code: Select all
> (set 'L '(foo bar (sheet-name "my Sheet")))
(foo bar (sheet-name "my Sheet"))
> (ref 'sheet-name L)
(2 0)
> (L ((ref 'sheet-name L) 1))
foo
> (L ((ref 'sheet-name L) 0))
(sheet-name "my Sheet")
> ((L ((ref 'sheet-name L) 0)) 1)
"my Sheet"
>
Lutz
.. and her is another trick:
This technique could also be used to generate XML/HTML from a list stucture.
Lutz
Code: Select all
;; you somehow extracted from a complex XML structure:
> sheet-spec
(sheet-name "MySheet")
;; define a procedure for this an other tags
> (define (sheet-name s) (append "the sheet-name is: " s))
;; then evaluate the list structure
> (eval sheet-spec)
"the sheet-name is: MySheet"
Lutz