Code: Select all
newLISP v.9.3.0 on OSX UTF-8, execute 'newlisp -h' for more info.
> (set 's "abc")
"abc"
> (set-nth 0 s "z")
"zbc"
Code: Select all
newLISP v.9.3.0 on OSX UTF-8, execute 'newlisp -h' for more info.
> (set 's "abc")
"abc"
> (set-nth 0 s "z")
"zbc"
Code: Select all
(set 's "abc")
(replace "a" s "z") => "zbc"
Code: Select all
(set 's "abc")
(replace "^." s "z" 0) => "zbc"
Code: Select all
; v 9.9.2 and after only
(set 's "abc")
(pop (replace "a" s "z") -1) => "c"
s => "zb"
Code: Select all
(set 's "abc")
(set 's (string "z" (rest s))) => "zbc"
(set 's (string "z" (1 s))) => "zbc"
Code: Select all
(set 's "abc")
(pop s) (push "z" s)
s => "zbc"
Code: Select all
> (set 's "abc")
"abc"
> (replace (first s) s "z") ; or (replace (s 0) s "z")
"zbc"
But if it goes away and you really find it useful, it's not hard in newLISP to write your own implementation of nth-set.cormullion wrote:But you're saying that you're removing the ability to directly modify strings using indexes to character locations?
(replace (nth i s) s "") is OK but not as good as (nth-set - the repetition of the string...
And I used to like the way that many functions such as nth-set worked on both strings and lists... Made newLISP easy to learn, I thought.
I'm trying hard to like newLISP 10 but I'm not finding it very likeable yet...
it is already there since 9.9.4 and you can find examples in the reference section of the manual http://www.newlisp.org/downloads/develo ... .html#setfdo you think it'll make the v10 release?
'nth' is still there, implicit indexing is purely optional and both explixit and implicit indexing works with 'setf'I think set-nth and nth and company should be kept
Code: Select all
(set 'lst '(a b c))
(setf (nth 1 lst) 'B) ; explicit for better readability
lst => (a B c)
(setf (lst 1) 'Z) ; implicit and higher speed
lst => (a Z c)