destructive append to a string
Posted: Sat Dec 17, 2005 2:16 pm
Is there a way to destructive append to the end of string?
Similar to 'push?
Similar to 'push?
Friends and Fans of newLISP
http://www.newlispfanclub.alh.net/forum/
http://www.newlispfanclub.alh.net/forum/viewtopic.php?f=5&t=898
Code: Select all
;; fast in-place string appending
(set 'str "")
(dotimes (x 5) (write-buffer str "hello"))
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"
>
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"