Page 1 of 1

'reverse

Posted: Fri Oct 15, 2004 8:52 am
by 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.

Posted: Fri Oct 15, 2004 10:05 am
by HPW
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?

Posted: Fri Oct 15, 2004 10:40 am
by newdep
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.

Posted: Fri Oct 15, 2004 11:02 am
by HPW
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?

Posted: Fri Oct 15, 2004 12:35 pm
by newdep
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...