Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #3693

Re: in-place reverse?

Newsgroups comp.lang.postscript
Date 2021-10-24 17:59 -0700
References <d9c46408-0992-4b61-a35e-85be12aa3b70n@googlegroups.com> <sl3b3v$50o$1@dont-email.me>
Message-ID <35dc8897-5893-495e-96ad-aaa5fc9d189dn@googlegroups.com> (permalink)
Subject Re: in-place reverse?
From luser droog <luser.droog@gmail.com>

Show all headers | View raw


On Sunday, October 24, 2021 at 5:04:49 AM UTC-5, James wrote:
> On 22/10/2021 07:24, luser droog wrote: 
> > I was reading through some old code and found this function to 
> > reverse an array.
> > And I wondered if it were possible to do it in-place, without creating 
> > a new array.
> /reverse { 
> aload dup length 1 sub 
> 0 exch 1 exch 
> { exch dup 4 2 roll exch put } for 
> } def 
> 
> [ 1 2 3 4 5 ] 
> dup 
> reverse 
> pstack

Yes. You have to dump the values or copy them somewhere. That last
one I posted doesn't work. It would produce [1 2 3 2 1] for this example.

Back to comp.lang.postscript | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

in-place reverse? luser droog <luser.droog@gmail.com> - 2021-10-21 23:24 -0700
  Re: in-place reverse? luser droog <luser.droog@gmail.com> - 2021-10-22 17:13 -0700
    Re: in-place reverse? luser droog <luser.droog@gmail.com> - 2021-10-22 17:42 -0700
    Re: in-place reverse? luser droog <luser.droog@gmail.com> - 2021-10-23 16:54 -0700
  Re: in-place reverse? luser droog <luser.droog@gmail.com> - 2021-10-22 17:16 -0700
  Re: in-place reverse? James <news@oxdrove.co.uk> - 2021-10-24 11:04 +0100
    Re: in-place reverse? luser droog <luser.droog@gmail.com> - 2021-10-24 17:59 -0700
    Re: in-place reverse? luser droog <luser.droog@gmail.com> - 2021-11-08 10:08 -0800
  Re: in-place reverse? David Newall <davidn@davidnewall.com> - 2022-01-21 21:10 +1100
    Re: in-place reverse? luser droog <luser.droog@gmail.com> - 2022-01-21 21:22 -0800
      Re: in-place reverse? jdaw1 <jdawiseman@gmail.com> - 2022-08-10 13:11 -0700

csiph-web