newLISP Fan Club

Forum => newLISP in the real world => Topic started by: newdep on October 15, 2004, 01:52:52 AM

Title: 'reverse
Post by: newdep on October 15, 2004, 01:52:52 AM
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.
Title:
Post by: HPW on October 15, 2004, 03:05:48 AM
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?
Title:
Post by: newdep on October 15, 2004, 03:40:04 AM
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.
Title:
Post by: HPW on October 15, 2004, 04:02:23 AM
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?
Title:
Post by: newdep on October 15, 2004, 05:35:39 AM
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...