Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #45665
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Reverse a string (with xchars) |
| Date | 2016-02-21 14:59 -0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <87d1rp4qlo.fsf@jester.gateway.pace.com> (permalink) |
| References | (3 earlier) <d1e1967f-6c07-4d04-867f-45133642a540@googlegroups.com> <874md16d46.fsf@jester.gateway.pace.com> <c8ba1573-77ce-49fb-a2f3-eb14a583ddc8@googlegroups.com> <87mvqt4wbd.fsf@jester.gateway.pace.com> <2a2f536b-cba7-4360-97e7-2d78e425aafb@googlegroups.com> |
Chris Curl <ccurl609@gmail.com> writes:
> The thing is ... a character may have more than one modifier, so for
> chars that have >1, don't you need a way to keep the char and its
> modifiers in the proper order? Perhaps what you are saying does that,
> I may just not be seeing it yet.
I don't think there can be unlimited numbers of modifiers, in fact
I thought there was at most 1. It doesn't matter, you can do all
the reversals in place. Algorithm:
let p = start of buffer
Until you reach the end of the buffer:
scan forward from p til you reach the end of the end of
the char including any modifiers
let q = current position
reverse the bytes in the range from p to q
let p = q
( p now points to the end of the buffer )
reverse bytes from start of buffer to p
So you've done the whole thing in place with no auxiliary buffers,
just a few temp variables for the loops and swaps.
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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