'reverse

Q&A's, tips, howto's
Locked
newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

'reverse

Post 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.
-- (define? (Cornflakes))

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post 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?
Hans-Peter

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post 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.
-- (define? (Cornflakes))

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post 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?
Hans-Peter

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post 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...
-- (define? (Cornflakes))

Locked