Implicit move

Started by newdep, September 13, 2007, 02:19:41 PM

Previous topic - Next topic

newdep

Hi Lutz,



I like implicit indexing a lot, it easy to use and compact...



But what i actualy miss inside implicit indexing is a simple way

to "move" variables inside lists...



Normaly I use a pop and a push to move an list/variable inside a list around, but actualy using pop en push is a little clumpsy together with implicit indexing or actualy overall for moving...



I would like to see something like i.e. this ->





> (set 'a '("one" "two" "three"))

("one" "two" "three")

> (nth-move (a 0) (a -1))

("two" "three" "one")



No its not a rotate, because then the function is getting too long again,

perhpas and extra parameter inside nth-set for moving inside lists?



Moving (like in 'pop then push) a nested list inside another nested list...or anything else..



Or perhpasd just a simple 'move function that moves inside lists

and strings...



Would be a nice to have...





Regards,

Norman.
-- (define? (Cornflakes))

cormullion

#1
Hmm, cool ideas!



Perhaps this is not elegant enough...?


(set 'a '("one" "two" "three"))
(swap  1 0 (swap -1 0 a))
;-> ("two" "three" "one")

newdep

#2
heheh... yes your right... i all forgot about 'swap



'swap is indeed useful for simple list swapping, would be nice if it could

be extended with nested-list swapping too ;-)



Thanks for the tip..



Norman..
-- (define? (Cornflakes))