Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #58743
| From | Alex <alex@rivadpm.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: excercise from Robert L, please comment |
| Date | 2017-05-06 20:26 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <oel7qa$f2n$1@dont-email.me> (permalink) |
| References | <oekb0j$f1b$1@dont-email.me> <oeknb6$ml6$1@dont-email.me> <oel61m$973$1@dont-email.me> |
On 5/6/2017 19:55, Alex wrote:
> : splitem ( addr len -- ) \ given a string, split them
> init-strings
> begin bl-skip dup \ skip blanks
> while \ keep going while something left
> over c@ \ get character
> dup '0' '9' 1+ within if \ select the output string
> num-string
> else
> char-string
> then
> dup target-string @ <> if \ if target changed
> bl add-target \ add a blank
> target-string ! \ switch strings
> else drop then
> add-target \ add the char
> 1 /string \ move up
> repeat 2drop ;
This could be (dropping the possibly expensive BL SKIP)
: splitem ( addr len -- ) \ given a string, split them
init-strings
begin dup
while \ keep going while something left
over c@
dup bl <> if \ if not a blank
dup '0' '9' 1+ within if \ select the output string
num-string
else
char-string
then
dup target-string @ <> if \ if target changed
bl add-target \ add a blank
target-string ! \ switch strings
else drop then
add-target \ add the char
else drop then \ drop the blank
1 /string \ move up
repeat 2drop ;
--
Alex
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
excercise from Robert L, please comment Andreas Klimas <klimas@w3group.de> - 2017-05-06 13:14 +0200
Re: excercise from Robert L, please comment Alex <alex@rivadpm.com> - 2017-05-06 13:14 +0100
Re: excercise from Robert L, please comment Andreas Klimas <klimas@w3group.de> - 2017-05-06 16:44 +0200
Re: excercise from Robert L, please comment Alex <alex@rivadpm.com> - 2017-05-06 19:55 +0100
Re: excercise from Robert L, please comment Alex <alex@rivadpm.com> - 2017-05-06 20:26 +0100
Re: excercise from Robert L, please comment Andreas Klimas <klimas@w3group.de> - 2017-05-07 23:08 +0200
Re: excercise from Robert L, please comment Ron Aaron <rambamist@gmail.com> - 2017-05-07 07:46 +0300
Re: excercise from Robert L, please comment Ron Aaron <rambamist@gmail.com> - 2017-05-07 07:54 +0300
Re: excercise from Robert L, please comment hughaguilar96@gmail.com - 2017-05-07 09:15 -0700
Re: excercise from Robert L, please comment humptydumpty <ouatubi@gmail.com> - 2017-05-08 11:00 -0700
Re: excercise from Robert L, please comment humptydumpty <ouatubi@gmail.com> - 2017-05-08 11:52 -0700
Re: excercise from Robert L, please comment "HAA" <someone@microsoft.com> - 2017-05-09 13:20 +1000
Re: excercise from Robert L, please comment humptydumpty <ouatubi@gmail.com> - 2017-05-10 00:26 -0700
Re: excercise from Robert L, please comment "HAA" <someone@microsoft.com> - 2017-05-11 17:07 +1000
Re: excercise from Robert L, please comment humptydumpty <ouatubi@gmail.com> - 2017-05-11 00:25 -0700
Re: excercise from Robert L, please comment Julian Fondren <julian.fondren@gmail.com> - 2017-05-08 21:40 -0700
Re: excercise from Robert L, please comment Julian Fondren <julian.fondren@gmail.com> - 2017-05-08 21:46 -0700
csiph-web