Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #58736
| From | Andreas Klimas <klimas@w3group.de> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: excercise from Robert L, please comment |
| Date | 2017-05-06 16:44 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <oeknb6$ml6$1@dont-email.me> (permalink) |
| References | <oekb0j$f1b$1@dont-email.me> |
I forgot to clearify the exercise "I have a string e.g. 'C6 H12 O6' that I wish to split up to give 2 strings 'C H O' and '6 12 6'." I'm not sure if this was von Robert L. so if I'm wrong than sorry. Anyway, I expanded the exercise a bit for not only using one letter per symbol. so the Teststring I have applied is "CX16 HXY12 O6", which is nonsens for an chemist. then, unfortunately there is a typo in the source: > until \ until ( c-addr 0) > 2 drop 2 drop should be 2drop sorry for inconvenience and thank you Alex for pointing out. > Hello, > > I'm a newbie in Forth programming and want to learn to become > better. I took the example from Robert L as a starting point. > Any advices are welcome - thank you. > > BTW, may be this is from any interest, I'm planning to use Forth > for my commercial work. It's in the area of insurance (not embedded). > I want to see how far I can get. > > best wishes > Andreas Klimas > > > here ," CX16 HXY12 O6" constant formular > > align > create l1 128 allot \ Buffer > create l2 128 allot > create >l1 l1 , \ Buffer-Seek-Pointer > create >l2 l2 , > > : ,l1 ( c--) >l1 @ ! 1 >l1 +! ; > : ,l2 ( c--) >l2 @ ! 1 >l2 +! ; > > : digit? ( c--bool) [char] 0 [char] 9 1+ within ; > : $seek ( c-addr u xt) ( xt: c-addr u c--bool) \ subsequent iterate > until bool becomes false > >r > begin > dup while ( c-addr u) > over c@ r@ execute ( c-addr u bool) > 0= if r> drop exit then ( c-addr' u') \ "xt execute" answered false > 1 /string > repeat > r> drop > ; > : get-char ( c--bool) \ called by $seek > dup digit? if drop false else dup ,l1 then ; > : get-number ( c--bool) \ called by $seek > dup digit? if dup ,l2 else drop false then ; > : get-chars ( c-addr u -- c-addr2 u2) ['] get-char $seek ; > : get-numbers ( c-addr u -- c-addr2 u2) ['] get-number $seek ; > > : foo > formular count ( c-addr u) > > begin > bl skip ( c-addr u) \ remove leading white spaces > > get-chars > bl ,l1 \ Seperate output > bl skip \ remove white spaces > get-numbers > bl ,l2 \ Seperate output > > dup 0= ( c-addr u) > until \ until ( c-addr 0) > 2 drop > cr > ." l1:" l1 >l1 @ l1 - type > cr > ." l2:" l2 >l1 @ l1 - type > cr > ;
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