'reverse

Started by newdep, October 15, 2004, 01:52:52 AM

Previous topic - Next topic

newdep

Hello Lutz,



Dubbing...Thisone is on my mind a long time ;-)



Is it possible put more Curry on 'Reverse ?



Currently (reverse X) reverses X and adjusts X..



But (reverse (reverse X)) does only print X and

does adjust X only onces...



If 'reverse is able to count the amount of 'reverse (self) actions

inside a function then it saves and extra ('set X (reverse.....)..

and (reverse (reverse X)) will work more smoothly...



Regards,

Norman.
-- (define? (Cornflakes))

HPW

#1
I think I miss the point.



>But (reverse (reverse X)) does only print X and

>does adjust X only onces...



It does not only print x, it does a double reverse where

the result is the same as the start value.

reverse is destructive!



So what's the point?
Hans-Peter

newdep

#2
Hi HPW,



Yes reverse is destructive.. on its First reverse only.



This means you always have do do a second reverse to get

back to the original, that is ok... so this works ->



(set 'X "123")

(reverse X)

> 321

> X

> "321"



But this is what 'reverse would make Spicy !! ->



(set 'X "/../../../../wwww./123/(get-this)")

(reverse (function ( function (reverse X)))

> "(get-this)"



But thats not possible the function will always look like ->



(set 'X (function ( function (reverse X)))

(reverse X)



Thats an extra separate 'reverse step...!



So actualy the point is that 'reverse should be able to be destructive

in nested functions also without redefining the variable again...



Hope its more clear ;-)



Norman.
-- (define? (Cornflakes))

HPW

#3
Still not get the point.



> (set 'X "/../../../../wwww./123/(get-this)")

"/../../../../wwww./123/(get-this)"

> (reverse (function ( function (reverse X))))

invalid function in function reverse : (function (function (reverse X)))

>



What is 'function' here?
Hans-Peter

newdep

#4
Oke here a reallive exmaple i runinto again when i as baking

the nput.lsp example... ->



(set 'outfile "/12/3/4/5/6/7/this-file")

(set 'outfile (reverse (slice outfile 0 (find "/" (reverse outfile)))))



could be written (if reverse did nested destructive!) as >



(reverse (slice outfile 0 (find "/" (reverse outfile))))



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