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


Groups > comp.lang.forth > #45661

Re: Reverse a string (with xchars)

Path csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Paul Rubin <no.email@nospam.invalid>
Newsgroups comp.lang.forth
Subject Re: Reverse a string (with xchars)
Date Sun, 21 Feb 2016 12:56:06 -0800
Organization A noiseless patient Spider
Lines 12
Message-ID <87mvqt4wbd.fsf@jester.gateway.pace.com> (permalink)
References <2016Feb19.100032@mips.complang.tuwien.ac.at> <f9be8844-ca23-49c8-96e1-efb307d6e831@googlegroups.com> <c984e8ae-513a-441b-9897-8cfd40f36499@googlegroups.com> <d1e1967f-6c07-4d04-867f-45133642a540@googlegroups.com> <874md16d46.fsf@jester.gateway.pace.com> <c8ba1573-77ce-49fb-a2f3-eb14a583ddc8@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain
Injection-Info mx02.eternal-september.org; posting-host="3c7a0b0f75f6c95b248ff930d17c36e7"; logging-data="12066"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX188y+weF7tbY3jug+ZvRGG6"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)
Cancel-Lock sha1:uey1Dtj/gztTS8cuaK+k+TDvZ6A= sha1:WmJ+a57NkUZ/8CmS8jUJILPmh/k=
Xref csiph.com comp.lang.forth:45661

Show key headers only | View raw


Chris Curl <ccurl609@gmail.com> writes:
> each "char" on the aux stack would have the number of bytes needed,
> followed by the actual bytes. 'A' would be (65 00 02 <-- TOS). a coded
> char would look like this: (30 03 65 00 04) or whatever.

Actually you don't need that overhead.  You can just build up an array
in forward order, but reverse the encoded bytes for each character.  So
if the encoding is (30 03 64 00) then you'd write (00 64 03 30).  After
doing this with all the chars, you'd scan the array backwards, parsing
the encodings from the reversed stream.  In fact you can do this in
place, with no auxiliary storage other than a few bytes to read a single
encoding and reverse it.

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Reverse a string (with xchars) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-19 09:00 +0000
  Re: Reverse a string (with xchars) mentificium@gmail.com - 2016-02-20 23:44 -0800
  Re: Reverse a string (with xchars) Chris Curl <ccurl609@gmail.com> - 2016-02-21 10:18 -0800
    Re: Reverse a string (with xchars) Chris Curl <ccurl609@gmail.com> - 2016-02-21 10:24 -0800
      Re: Reverse a string (with xchars) Chris Curl <ccurl609@gmail.com> - 2016-02-21 10:35 -0800
        Re: Reverse a string (with xchars) Paul Rubin <no.email@nospam.invalid> - 2016-02-21 12:07 -0800
          Re: Reverse a string (with xchars) Chris Curl <ccurl609@gmail.com> - 2016-02-21 12:40 -0800
            Re: Reverse a string (with xchars) Paul Rubin <no.email@nospam.invalid> - 2016-02-21 12:50 -0800
            Re: Reverse a string (with xchars) Paul Rubin <no.email@nospam.invalid> - 2016-02-21 12:56 -0800
              Re: Reverse a string (with xchars) Chris Curl <ccurl609@gmail.com> - 2016-02-21 14:43 -0800
                Re: Reverse a string (with xchars) Paul Rubin <no.email@nospam.invalid> - 2016-02-21 14:59 -0800
                Re: Reverse a string (with xchars) Chris Curl <ccurl609@gmail.com> - 2016-02-21 16:55 -0800
              Re: Reverse a string (with xchars) Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-02-22 09:37 +0000

csiph-web