Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #16855 > unrolled thread
| Started by | Mark Wills <forthfreak@gmail.com> |
|---|---|
| First post | 2012-10-31 04:58 -0700 |
| Last post | 2012-11-02 13:13 -0400 |
| Articles | 20 on this page of 169 — 25 participants |
Back to article view | Back to comp.lang.forth
Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 04:58 -0700
Re: Is there a better way? Paul Rubin <no.email@nospam.invalid> - 2012-10-31 05:22 -0700
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 05:44 -0700
Re: Is there a better way? "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-10-31 11:29 -0400
Re: Is there a better way? "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-10-31 11:40 -0400
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 08:45 -0700
Re: Is there a better way? "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-02 04:48 -0400
Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-10-31 21:42 -0400
Re: Is there a better way? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-11-01 19:19 -0700
Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-02 13:06 -0400
Re: Is there a better way? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-02 12:18 -0500
Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-02 14:34 -0400
Re: Is there a better way? Paul Rubin <no.email@nospam.invalid> - 2012-11-02 11:39 -0700
Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-02 14:43 -0400
Re: Is there a better way? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-04 02:36 -0600
Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-04 14:18 -0500
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-02 14:38 -0700
Re: Is there a better way? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-04 03:01 -0600
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-04 03:54 -0800
Re: Is there a better way? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-04 07:59 -0600
Re: Is there a better way? Elizabeth D Rather <erather@forth.com> - 2012-11-04 08:34 -1000
Re: Is there a better way? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-11-04 15:22 -0800
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-05 02:39 -0800
Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-05 14:01 -0500
Re: Words consuming arguments, was [Re: Is there a better way?] "Elizabeth D. Rather" <erather@forth.com> - 2012-11-05 10:39 -1000
Re: Words consuming arguments, was [Re: Is there a better way?] Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-11-05 21:07 -0800
Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-06 20:57 -0500
Re: Words consuming arguments, was [Re: Is there a better way?] Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-11-06 21:43 -0800
Re: Words consuming arguments, was [Re: Is there a better way?] Mark Wills <forthfreak@gmail.com> - 2012-11-07 03:52 -0800
Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-07 19:55 -0500
Re: Words consuming arguments, was [Re: Is there a better way?] "Elizabeth D. Rather" <erather@forth.com> - 2012-11-07 20:46 -1000
Re: Words consuming arguments, was [Re: Is there a better way?] stephenXXX@mpeforth.com (Stephen Pelc) - 2012-11-08 10:39 +0000
Re: Words consuming arguments, was [Re: Is there a better way?] Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-12 03:48 -0600
Re: Words consuming arguments, was [Re: Is there a better way?] "Elizabeth D. Rather" <erather@forth.com> - 2012-11-12 07:57 -1000
Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-12 19:50 -0500
Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-12 19:49 -0500
Re: Words consuming arguments, was [Re: Is there a better way?] "Elizabeth D. Rather" <erather@forth.com> - 2012-11-12 15:00 -1000
Re: Words consuming arguments, was [Re: Is there a better way?] Mark Wills <forthfreak@gmail.com> - 2012-11-13 00:50 -0800
Re: Words consuming arguments, was [Re: Is there a better way?] Mark Wills <forthfreak@gmail.com> - 2012-11-13 00:58 -0800
Re: Words consuming arguments, was [Re: Is there a better way?] "Elizabeth D. Rather" <erather@forth.com> - 2012-11-12 23:17 -1000
Re: Words consuming arguments, was [Re: Is there a better way?] albert@spenarnc.xs4all.nl (Albert van der Horst) - 2012-11-13 13:44 +0000
Re: Words consuming arguments, was [Re: Is there a better way?] anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-13 13:53 +0000
Re: Words consuming arguments, was [Re: Is there a better way?] Alex McDonald <blog@rivadpm.com> - 2012-11-13 06:39 -0800
Re: Words consuming arguments, was [Re: Is there a better way?] anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-13 18:02 +0000
Re: Words consuming arguments, was [Re: Is there a better way?] Alex McDonald <blog@rivadpm.com> - 2012-11-13 12:10 -0800
Re: Words consuming arguments, was [Re: Is there a better way?] anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-15 16:59 +0000
Re: Words consuming arguments, was [Re: Is there a better way?] Mark Wills <forthfreak@gmail.com> - 2012-11-13 07:55 -0800
Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-14 06:34 -0500
Re: Words consuming arguments, was [Re: Is there a better way?] Mark Wills <forthfreak@gmail.com> - 2012-11-14 05:01 -0800
Re: Words consuming arguments, was [Re: Is there a better way?] albert@spenarnc.xs4all.nl (Albert van der Horst) - 2012-11-14 16:11 +0000
Re: Words consuming arguments, was [Re: Is there a better way?] "Elizabeth D. Rather" <erather@forth.com> - 2012-11-14 09:36 -1000
Re: Words consuming arguments, was [Re: Is there a better way?] humptydumpty <ouatubi@gmail.com> - 2012-11-14 12:19 -0800
Re: Words consuming arguments, was [Re: Is there a better way?] Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-13 10:20 -0600
Re: Words consuming arguments, was [Re: Is there a better way?] Brad Eckert <hwfwguy@gmail.com> - 2012-11-13 08:50 -0800
Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-14 06:42 -0500
Re: Words consuming arguments, was [Re: Is there a better way?] stephenXXX@mpeforth.com (Stephen Pelc) - 2012-11-14 14:14 +0000
Re: Words consuming arguments, was [Re: Is there a better way?] anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-14 15:28 +0000
Re: Words consuming arguments, was [Re: Is there a better way?] Bernd Paysan <bernd.paysan@gmx.de> - 2012-11-14 17:54 +0100
Re: Words consuming arguments, was [Re: Is there a better way?] Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-11-14 15:01 -0800
Re: Words consuming arguments, was [Re: Is there a better way?] Mark Wills <forthfreak@gmail.com> - 2012-11-15 00:08 -0800
Strings (was: Words consuming arguments) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-15 15:18 +0000
Re: Strings (was: Words consuming arguments) albert@spenarnc.xs4all.nl (Albert van der Horst) - 2012-11-15 16:36 +0000
Re: Strings (was: Words consuming arguments) "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-15 18:35 -0500
Re: Strings (was: Words consuming arguments) stephenXXX@mpeforth.com (Stephen Pelc) - 2012-11-16 00:36 +0000
Re: Strings (was: Words consuming arguments) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-16 17:42 +0000
Re: Strings (was: Words consuming arguments) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-16 17:55 +0000
Re: Words consuming arguments, was [Re: Is there a better way?] Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-11-17 04:18 -0800
Re: Words consuming arguments, was [Re: Is there a better way?] Alex McDonald <blog@rivadpm.com> - 2012-11-17 04:56 -0800
Re: Words consuming arguments, was [Re: Is there a better way?] "Elizabeth D. Rather" <erather@forth.com> - 2012-11-17 07:24 -1000
Re: Words consuming arguments, was [Re: Is there a better way?] Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-11-19 15:58 -0800
Re: Words consuming arguments, was [Re: Is there a better way?] Brad Eckert <hwfwguy@gmail.com> - 2012-11-20 08:17 -0800
Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-14 06:30 -0500
Re: Words consuming arguments, was [Re: Is there a better way?] "Elizabeth D. Rather" <erather@forth.com> - 2012-11-14 09:06 -1000
Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-15 06:18 -0500
Re: Words consuming arguments, was [Re: Is there a better way?] Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-13 04:26 -0600
Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-14 06:29 -0500
Re: Words consuming arguments, was [Re: Is there a better way?] Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-14 06:03 -0600
Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-15 07:15 -0500
Re: Words consuming arguments, was [Re: Is there a better way?] Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-15 11:51 -0600
Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-15 18:44 -0500
Re: Words consuming arguments, was [Re: Is there a better way?] Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-16 03:50 -0600
Re: Words consuming arguments, was [Re: Is there a better way?] "Elizabeth D. Rather" <erather@forth.com> - 2012-11-15 08:09 -1000
Re: Words consuming arguments, was [Re: Is there a better way?] "Elizabeth D. Rather" <erather@forth.com> - 2012-11-06 21:19 -1000
Re: Words consuming arguments, was [Re: Is there a better way?] "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-11-07 20:00 -0500
Re: Words consuming arguments, was [Re: Is there a better way?] stephenXXX@mpeforth.com (Stephen Pelc) - 2012-11-08 10:49 +0000
Re: Words consuming arguments, was [Re: Is there a better way?] albert@spenarnc.xs4all.nl (Albert van der Horst) - 2012-11-07 14:01 +0000
Re: Is there a better way? awegel@arcor.de (Alex Wegel) - 2012-11-04 11:07 +0100
Re: Is there a better way? awegel@arcor.de (Alex Wegel) - 2012-11-04 11:36 +0100
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-04 03:48 -0800
Re: Is there a better way? awegel@arcor.de (Alex Wegel) - 2012-11-04 13:31 +0100
Re: Is there a better way? Coos Haak <chforth@hccnet.nl> - 2012-11-04 13:29 +0100
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-04 04:42 -0800
Re: Is there a better way? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-04 02:38 -0600
Re: Is there a better way? Doug Hoffman <glidedog@gmail.com> - 2012-10-31 10:20 -0400
Re: Is there a better way? humptydumpty <ouatubi@gmail.com> - 2012-10-31 05:53 -0700
Re: Is there a better way? Doug Hoffman <glidedog@gmail.com> - 2012-10-31 09:23 -0400
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 06:41 -0700
Re: Is there a better way? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-10-31 11:46 -0500
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 14:27 -0700
Re: Is there a better way? Paul Rubin <no.email@nospam.invalid> - 2012-10-31 14:32 -0700
Re: Is there a better way? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-10-31 16:15 -0700
Re: Is there a better way? Coos Haak <chforth@hccnet.nl> - 2012-10-31 22:49 +0100
Re: Is there a better way? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-10-31 17:13 -0500
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 23:39 -0700
Re: Is there a better way? "Elizabeth D. Rather" <erather@forth.com> - 2012-10-31 20:58 -1000
Re: Is there a better way? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-11-01 02:04 -0700
Re: Is there a better way? "Rod Pemberton" <do_not_have@notemailnotz.cnm> - 2012-10-31 19:13 -0400
Re: Is there a better way? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-02 17:31 +0000
Re: Is there a better way? Paul Rubin <no.email@nospam.invalid> - 2012-11-02 10:37 -0700
Re: Is there a better way? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-02 18:12 +0000
Re: Is there a better way? "Elizabeth D. Rather" <erather@forth.com> - 2012-11-02 08:29 -1000
Re: Is there a better way? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-05 14:53 +0000
Re: Is there a better way? Paul Rubin <no.email@nospam.invalid> - 2012-11-02 11:30 -0700
Re: Is there a better way? Bernd Paysan <bernd.paysan@gmx.de> - 2012-11-03 00:15 +0100
Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-02 19:21 -0400
Re: Is there a better way? Bernd Paysan <bernd.paysan@gmx.de> - 2012-11-03 00:42 +0100
Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-02 20:21 -0400
Re: Is there a better way? Bernd Paysan <bernd.paysan@gmx.de> - 2012-11-03 01:44 +0100
Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-03 12:12 -0400
Re: Is there a better way? Bernd Paysan <bernd.paysan@gmx.de> - 2012-11-03 18:24 +0100
Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-03 14:00 -0400
Re: Is there a better way? Paul Rubin <no.email@nospam.invalid> - 2012-11-03 10:29 -0700
Re: Is there a better way? Paul Rubin <no.email@nospam.invalid> - 2012-11-02 18:42 -0700
Re: Is there a better way? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-11-05 11:45 +0000
Re: Is there a better way? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2012-11-01 21:00 +0000
Re: Is there a better way? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2012-10-31 15:26 +0000
Re: Is there a better way? Doug Hoffman <glidedog@gmail.com> - 2012-10-31 12:22 -0400
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 15:07 -0700
Re: Is there a better way? Doug Hoffman <glidedog@gmail.com> - 2012-10-31 19:16 -0400
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-01 06:31 -0700
Re: Is there a better way? Doug Hoffman <glidedog@gmail.com> - 2012-11-01 10:34 -0400
Re: Is there a better way? Doug Hoffman <glidedog@gmail.com> - 2012-11-01 10:48 -0400
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-01 08:55 -0700
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-01 08:49 -0700
Re: Is there a better way? Doug Hoffman <glidedog@gmail.com> - 2012-11-01 12:46 -0400
Re: Is there a better way? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-01 09:37 -0500
Re: Is there a better way? Paul Rubin <no.email@nospam.invalid> - 2012-11-01 07:41 -0700
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-01 08:52 -0700
Re: Is there a better way? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-01 12:18 -0500
Re: Is there a better way? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-11-01 19:38 -0700
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-02 02:29 -0700
Re: Is there a better way? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-11-04 21:48 -0800
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-05 02:44 -0800
Re: Is there a better way? Graham NEWS <gray@forthman.plus.com> - 2012-11-01 15:52 +0000
Re: Is there a better way? Josh Grams <josh@qualdan.com> - 2012-11-03 16:38 +0000
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 14:26 -0700
Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-01 13:42 -0400
Re: Is there a better way? Graham <""gray\"@forthman@plus.com"> - 2012-10-31 17:05 +0000
Re: Is there a better way? Peter Fälth <peter.falth@tin.it> - 2012-10-31 12:07 -0700
Re: Is there a better way? Paul Rubin <no.email@nospam.invalid> - 2012-10-31 12:12 -0700
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 14:17 -0700
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 14:21 -0700
Re: Is there a better way? Pablo Hugo Reda <pabloreda@gmail.com> - 2012-10-31 14:50 -0700
Re: Is there a better way? Pablo Hugo Reda <pabloreda@gmail.com> - 2012-10-31 14:51 -0700
Re: Is there a better way? Paul Rubin <no.email@nospam.invalid> - 2012-10-31 14:57 -0700
Re: Is there a better way? Coos Haak <chforth@hccnet.nl> - 2012-10-31 23:47 +0100
Re: Is there a better way? mhx@iae.nl (Marcel Hendrix) - 2012-11-01 21:28 +0200
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-10-31 15:11 -0700
Re: Is there a better way? Pablo Hugo Reda <pabloreda@gmail.com> - 2012-10-31 15:44 -0700
Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-01 13:55 -0400
Re: Is there a better way? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-10-31 16:10 -0700
Re: Is there a better way? Charles Mélice <charles.melice@gmail.com> - 2012-11-02 01:10 -0700
Re: Is there a better way? Charles Mélice <charles.melice@gmail.com> - 2012-11-02 01:18 -0700
Re: Is there a better way? Mark Wills <forthfreak@gmail.com> - 2012-11-02 01:58 -0700
Re: Is there a better way? Charles Mélice <charles.melice@gmail.com> - 2012-11-02 02:14 -0700
Re: Is there a better way? Charles Mélice <charles.melice@gmail.com> - 2012-11-02 02:16 -0700
Re: Is there a better way? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-11-02 06:16 -0500
Re: Is there a better way? Charles Mélice <charles.melice@gmail.com> - 2012-11-02 06:04 -0700
Re: Is there a better way? rickman <gnuarm@gmail.com> - 2012-11-02 13:13 -0400
Page 7 of 9 — ← Prev page 1 2 3 4 5 6 [7] 8 9 Next page →
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2012-11-03 14:00 -0400 |
| Message-ID | <k73m4h$dn1$2@dont-email.me> |
| In reply to | #17013 |
On 11/3/2012 1:24 PM, Bernd Paysan wrote: > rickman wrote: >>> His argument was that scanning the string several times was expensive >>> (true), and then asked how to make STR<= from STR< and STR= without >>> that problem (for which I provided an answer). >> >> Please reread his post with an open mind and consider the context. >> You are reading content that isn't there. > > Given that Paul also replied to my post, and his reply was "Aha, good > point ;-)", maybe you are reading something between the lines he hasn't > written. > I stand corrected. Rick
[toc] | [prev] | [next] | [standalone]
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Date | 2012-11-03 10:29 -0700 |
| Message-ID | <7xa9uytx0p.fsf@ruckus.brouhaha.com> |
| In reply to | #17009 |
rickman <gnuarm@gmail.com> writes: >> His argument was that scanning the string several times was expensive >> (true), and then asked how to make STR<= from STR< and STR= without that >> problem (for which I provided an answer). > > Please reread his post with an open mind and consider the context. > You are reading content that isn't there. Bernd is right, I had a brain fart, forgetting that x <= y is just !(y < x). There are still situations where you want the 3-way compare and can't easily synthesize it, so it still seems like the best choice if you are going to have just one primitive.
[toc] | [prev] | [next] | [standalone]
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Date | 2012-11-02 18:42 -0700 |
| Message-ID | <7x4nl731jl.fsf@ruckus.brouhaha.com> |
| In reply to | #17000 |
Bernd Paysan <bernd.paysan@gmx.de> writes: >> How would you defined STR<= in terms of STR= and STR< without having >> to scan the string twice? > : str> ( addr1 u1 addr2 u2 -- flag ) 2swap str< ; > : str<= ( addr1 u1 addr2 u2 -- flag ) str> 0= ; Aha, good point ;-).
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2012-11-05 11:45 +0000 |
| Message-ID | <2012Nov5.124524@mips.complang.tuwien.ac.at> |
| In reply to | #16990 |
Paul Rubin <no.email@nospam.invalid> writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>> The other way would be to write STR= and STR<, just like there is D=
>> and D< (and likewise, there is no F> F<= F>=, U<=, U>=, and U> is Core
>> Ext). Forthers know how to use this kind of comparison.
>
>How would you defined STR<= in terms of STR= and STR< without having
>to scan the string twice?
: str<= 2swap str< 0= ;
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2012: http://www.euroforth.org/ef12/
[toc] | [prev] | [next] | [standalone]
| From | albert@spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2012-11-01 21:00 +0000 |
| Message-ID | <5092e304$0$3182$e4fe514c@dreader35.news.xs4all.nl> |
| In reply to | #16882 |
In article <RrudnRYWh7RTyAzNnZ2dnUVZ8iydnZ2d@supernews.com>, Andrew Haley <andrew29@littlepinkcloud.invalid> wrote: >Mark Wills <forthfreak@gmail.com> wrote: >> On Oct 31, 1:23?pm, Doug Hoffman <glide...@gmail.com> wrote: >>> On 10/31/12 7:58 AM, Mark Wills wrote: >>> >>> > The following routine is checking to see if a string is "}}" i.e. >>> > consists of two consequtive right curly braces. >>> >>> > : }}? ( addr len -- addr len flag) >>> > ?dup 2= if >>> > over dup c@ swap 1+ c@ 125 = swap 125 = and >>> > else >>> > false >>> > then ; >>> >>> > As can be seen, the first check is the length; if the length is not >>> > exactly 2 then we just return false. If the length is 2 then we check >>> > to see if both characters are ASCII 125. That's the bit I am looking >>> > at and saying "Meh... seems a bit convoluted/lengthy. >>> >>> > Is there a better way? >>> >>> > I was thinking maybe: >>> >>> > ... c@ 125 OR swap 1+ c@ 125 OR 125 XOR 0= >>> >>> > Which is perhaps "cleverer" but not as clear as to the intention of >>> > the code and no shorter... >>> >>> : }}? ( addr len -- addr len flag) >>> 2dup s" }}" compare 0= ; >> >> >> That's cheating ;-) COMPARE is in the ANS optional string word-set. >> I'm still stuck in the 80's I'm afraid, using Forth 83 on a 30 year >> old computer! Everyone should have a hobby! > >Well, yes, but the *correct* answer to your problem is therefore >"Write COMPARE, then use it". COMPARE is not hard to write. + one > >Andrew. -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
[toc] | [prev] | [next] | [standalone]
| From | albert@spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2012-10-31 15:26 +0000 |
| Message-ID | <5091433c$0$3185$e4fe514c@dreader36.news.xs4all.nl> |
| In reply to | #16855 |
In article <70a117c1-ba9f-474b-97f3-6440be3d4573@k20g2000vbj.googlegroups.com>, Mark Wills <forthfreak@gmail.com> wrote: >The following routine is checking to see if a string is "}}" i.e. >consists of two consequtive right curly braces. > >: }}? ( addr len -- addr len flag) > dup 2= if > over dup c@ swap 1+ c@ 125 = swap 125 = and > else > false > then ; > >As can be seen, the first check is the length; if the length is not >exactly 2 then we just return false. If the length is 2 then we check >to see if both characters are ASCII 125. That's the bit I am looking >at and saying "Meh... seems a bit convoluted/lengthy. > >Is there a better way? > >I was thinking maybe: > >... c@ 125 OR swap 1+ c@ 125 OR 125 XOR 0= > >Which is perhaps "cleverer" but not as clear as to the intention of >the code and no shorter... I can't help it. WANT $= : }}? 2DUP "}}" $= ; As a general point, unless you want to go the c-abomination of zero-ended strings, it can't be helped that you have to consider the length as well as the content of the string. Groetjes Albert
[toc] | [prev] | [next] | [standalone]
| From | Doug Hoffman <glidedog@gmail.com> |
|---|---|
| Date | 2012-10-31 12:22 -0400 |
| Message-ID | <5091502d$0$294$14726298@news.sunsite.dk> |
| In reply to | #16867 |
On 10/31/12 11:26 AM, Albert van der Horst wrote: > WANT $= > : }}? 2DUP "}}" $= ; With an ANS Forth I can't compile this. I get three undefined words error messages: WANT $= "}}" -Doug
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <forthfreak@gmail.com> |
|---|---|
| Date | 2012-10-31 15:07 -0700 |
| Message-ID | <13d7d909-2592-4bdf-b7eb-0c965a1fd0dc@c20g2000vbz.googlegroups.com> |
| In reply to | #16877 |
On Oct 31, 4:22 pm, Doug Hoffman <glide...@gmail.com> wrote: > On 10/31/12 11:26 AM, Albert van der Horst wrote: > > > WANT $= > > : }}? 2DUP "}}" $= ; > > With an ANS Forth I can't compile this. I get three undefined words > error messages: > > WANT > $= > "}}" > > -Doug I think WANT is the equivalent of a #include in C. Is this ciForth? So WANT conditionally includes $= if it's not already in memory. Presumably.
[toc] | [prev] | [next] | [standalone]
| From | Doug Hoffman <glidedog@gmail.com> |
|---|---|
| Date | 2012-10-31 19:16 -0400 |
| Message-ID | <5091b13f$0$282$14726298@news.sunsite.dk> |
| In reply to | #16908 |
On 10/31/12 6:07 PM, Mark Wills wrote: > On Oct 31, 4:22 pm, Doug Hoffman <glide...@gmail.com> wrote: >> >>> WANT $= >>> : }}? 2DUP "}}" $= ; >> >> With an ANS Forth I can't compile this. I get three undefined words >> error messages: >> >> WANT >> $= >> "}}" > I think WANT is the equivalent of a #include in C. Is this ciForth? So > WANT conditionally includes $= if it's not already in memory. > Presumably. Maybe someday there will some kind of standardization effort for this kind of stuff. Might prove useful. -Doug
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <forthfreak@gmail.com> |
|---|---|
| Date | 2012-11-01 06:31 -0700 |
| Message-ID | <5669d326-99c8-4b4f-8c99-df4cd37a854a@d3g2000vbj.googlegroups.com> |
| In reply to | #16917 |
On Oct 31, 11:16 pm, Doug Hoffman <glide...@gmail.com> wrote:
> On 10/31/12 6:07 PM, Mark Wills wrote:
>
> > On Oct 31, 4:22 pm, Doug Hoffman <glide...@gmail.com> wrote:
>
> >>> WANT $=
> >>> : }}? 2DUP "}}" $= ;
>
> >> With an ANS Forth I can't compile this. I get three undefined words
> >> error messages:
>
> >> WANT
> >> $=
> >> "}}"
> > I think WANT is the equivalent of a #include in C. Is this ciForth? So
> > WANT conditionally includes $= if it's not already in memory.
> > Presumably.
>
> Maybe someday there will some kind of standardization effort for this
> kind of stuff. Might prove useful.
>
> -Doug
I also thought $= was quite useful, so I set about writing a version.
I found it quite torturous to write! I'd be interested to see other
versions.
: $= ( addr1 len1 addr2 len2 -- flag)
2 pick <> if drop 2drop false else rot begin
dup c@ >r 1+ -rot dup c@ >r 1+ -rot
r> r> = if 1- else drop -1 then dup >r -rot
r> 0<= until then ;
Quite a lot of return stack bashing required. It works by via a
BEGIN...UNTIL loop, checking each character. The length is decremented
each time a character is checked. If two characters are different, it
sets the length to -1. The UNTIL loop terminates with a 0<= so the
loop exits early if a difference is found. If the string is exactly
equal, then the length will have been decremented to 0 (duh!) since
every character will have been checked. If the length is found to be
-1 then the strings were not equal. This is taken care of with the
final 0= at the end.
Here it is showing the stack:
(a=address l=length)
rot \ l1 a2 a1
begin
dup c@ >r 1+ \ l1 a2 a1 r: c1
-rot \ a1 l1 a2 r: c1
dup c@ >r 1+ \ a1 l1 a2 r: c1 c2
-rot \ a2 a1 l1 r: c1 c2
r> r> = \ a2 a1 l1 flag r: --
if 1- else drop -1 then \ a2 a1 l1/0 r: --
dup >r \ a2 a1 l1/0 r: l1/0
-rot \ l1/0 a2 a1 r: l1/0
r> 0<= until \ l1/0 a2 a1 r: --
2drop \ l1/0
0= \ flag
then
Is there an easier way (that is, showing the *implementation* not just
some high level word). I was surprised at how difficult it was. It's
much easier in C!
In fairness, I think this type of routine is a good candidate for
locals or variables. With locals the difficulty would evaporate I
think. C, of course, has locals/variables. I was trying to see if I
could do it without variables, however. What would seasoned Forth
programmers do here? Reach for locals/variables or is there something
much more obvious that I'm missing?
[toc] | [prev] | [next] | [standalone]
| From | Doug Hoffman <glidedog@gmail.com> |
|---|---|
| Date | 2012-11-01 10:34 -0400 |
| Message-ID | <50928872$0$291$14726298@news.sunsite.dk> |
| In reply to | #16933 |
On 11/1/12 9:31 AM, Mark Wills wrote:
> I also thought $= was quite useful,
COMPARE is fine by me, I already have it so $= is redundant.
Nonetheless...
> so I set about writing a version.
> I found it quite torturous to write! I'd be interested to see other
> versions.
>
> : $= ( addr1 len1 addr2 len2 -- flag)
> 2 pick <> if drop 2drop false else rot begin
> dup c@ >r 1+ -rot dup c@ >r 1+ -rot
> r> r> = if 1- else drop -1 then dup >r -rot
> r> 0<= until then ;
This crashes for me. Here's a dump:
s" }}" s" }}" $= .
( 4 ) \ -1073750320 \ 2 \ -1073750318 \ 2
2 ( 5 ) \ -1073750320 \ 2 \ -1073750318 \ 2 \ 2
pick ( 5 ) \ -1073750320 \ 2 \ -1073750318 \ 2 \ 2
<> ( 4 ) \ -1073750320 \ 2 \ -1073750318 \ 0
if ( 3 ) \ -1073750320 \ 2 \ -1073750318
rot ( 3 ) \ 2 \ -1073750318 \ -1073750320
begin ( 3 ) \ 2 \ -1073750318 \ -1073750320
dup ( 4 ) \ 2 \ -1073750318 \ -1073750320 \ -1073750320
c@ ( 4 ) \ 2 \ -1073750318 \ -1073750320 \ 125
>r ( 3 ) \ 2 \ -1073750318 \ -1073750320
1+ ( 3 ) \ 2 \ -1073750318 \ -1073750319
-rot ( 3 ) \ -1073750319 \ 2 \ -1073750318
dup ( 4 ) \ -1073750319 \ 2 \ -1073750318 \ -1073750318
c@ ( 4 ) \ -1073750319 \ 2 \ -1073750318 \ 125
>r ( 3 ) \ -1073750319 \ 2 \ -1073750318
1+ ( 3 ) \ -1073750319 \ 2 \ -1073750317
-rot ( 3 ) \ -1073750317 \ -1073750319 \ 2
r> ( 4 ) \ -1073750317 \ -1073750319 \ 2 \ 125
r> ( 5 ) \ -1073750317 \ -1073750319 \ 2 \ 125 \ 125
= ( 4 ) \ -1073750317 \ -1073750319 \ 2 \ -1
if ( 3 ) \ -1073750317 \ -1073750319 \ 2
1- ( 3 ) \ -1073750317 \ -1073750319 \ 1
else ( 3 ) \ -1073750317 \ -1073750319 \ 1
dup ( 4 ) \ -1073750317 \ -1073750319 \ 1 \ 1
>r ( 3 ) \ -1073750317 \ -1073750319 \ 1
-rot ( 3 ) \ 1 \ -1073750317 \ -1073750319
r> ( 4 ) \ 1 \ -1073750317 \ -1073750319 \ 1
0< ( 4 ) \ 1 \ -1073750317 \ -1073750319 \ 0
= ( 3 ) \ 1 \ -1073750317 \ 0
until ( 2 ) \ 1 \ -1073750317
dup ( 3 ) \ 1 \ -1073750317 \ -1073750317
c@ ( 3 ) \ 1 \ -1073750317 \ 125
>r ( 2 ) \ 1 \ -1073750317
1+ ( 2 ) \ 1 \ -1073750316
-rot ( 2 ) \ -1073750320 \ 1
dup ( 3 ) \ -1073750320 \ 1 \ 1
c@
Largely untested:
: $= ( addr1 len1 addr2 len2 -- flag)
rot \ addr1 addr2 len2 len1
over \ addr1 addr2 len2 len1 len2
<> if 2drop drop 0 exit then \ out if len1<>len2
\ addr1 addr2 len2
over + swap \ addr1 addr2+len2 addr2
?do dup c@ i c@ <> if drop 0 unloop exit then loop
drop true ;
Some define "over + swap" as bounds.
-Doug
[toc] | [prev] | [next] | [standalone]
| From | Doug Hoffman <glidedog@gmail.com> |
|---|---|
| Date | 2012-11-01 10:48 -0400 |
| Message-ID | <50928baa$0$292$14726298@news.sunsite.dk> |
| In reply to | #16934 |
On 11/1/12 10:34 AM, Doug Hoffman wrote:
oops
Should be:
: $= ( addr1 len1 addr2 len2 -- flag)
rot \ addr1 addr2 len2 len1
over \ addr1 addr2 len2 len1 len2
<> if 2drop drop 0 exit then \ out if len1<>len2
\ addr1 addr2 len2
over + swap \ addr1 addr2+len2 addr2
?do dup c@ i c@ <> if drop 0 unloop exit then 1+ loop \ added 1+
drop true ;
-Doug
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <forthfreak@gmail.com> |
|---|---|
| Date | 2012-11-01 08:55 -0700 |
| Message-ID | <fbcd1eb4-1d2f-4e6a-89d2-2ca3e1e55259@j12g2000vbm.googlegroups.com> |
| In reply to | #16937 |
On Nov 1, 2:48 pm, Doug Hoffman <glide...@gmail.com> wrote: > On 11/1/12 10:34 AM, Doug Hoffman wrote: > > oops > > Should be: > > : $= ( addr1 len1 addr2 len2 -- flag) > rot \ addr1 addr2 len2 len1 > over \ addr1 addr2 len2 len1 len2 > <> if 2drop drop 0 exit then \ out if len1<>len2 > \ addr1 addr2 len2 > over + swap \ addr1 addr2+len2 addr2 > ?do dup c@ i c@ <> if drop 0 unloop exit then 1+ loop \ added 1+ > drop true ; > > -Doug Thank you Doug. That's very nice. I had to add unloop, which was trivial.
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <forthfreak@gmail.com> |
|---|---|
| Date | 2012-11-01 08:49 -0700 |
| Message-ID | <f411e3bd-7f76-440a-bf72-e9df449a978d@k6g2000vbr.googlegroups.com> |
| In reply to | #16934 |
On Nov 1, 2:34 pm, Doug Hoffman <glide...@gmail.com> wrote: > On 11/1/12 9:31 AM, Mark Wills wrote: > > > I also thought $= was quite useful, > > COMPARE is fine by me, I already have it so $= is redundant. > > Nonetheless... > > > so I set about writing a version. > > I found it quite torturous to write! I'd be interested to see other > > versions. > > > : $= ( addr1 len1 addr2 len2 -- flag) > > 2 pick <> if drop 2drop false else rot begin > > dup c@ >r 1+ -rot dup c@ >r 1+ -rot > > r> r> = if 1- else drop -1 then dup >r -rot > > r> 0<= until then ; > > This crashes for me. Here's a dump: > > s" }}" s" }}" $= . > ( 4 ) \ -1073750320 \ 2 \ -1073750318 \ 2 > 2 ( 5 ) \ -1073750320 \ 2 \ -1073750318 \ 2 \ 2 > pick ( 5 ) \ -1073750320 \ 2 \ -1073750318 \ 2 \ 2 > <> ( 4 ) \ -1073750320 \ 2 \ -1073750318 \ 0 > if ( 3 ) \ -1073750320 \ 2 \ -1073750318 > rot ( 3 ) \ 2 \ -1073750318 \ -1073750320 > begin ( 3 ) \ 2 \ -1073750318 \ -1073750320 > dup ( 4 ) \ 2 \ -1073750318 \ -1073750320 \ -1073750320 > c@ ( 4 ) \ 2 \ -1073750318 \ -1073750320 \ 125 > >r ( 3 ) \ 2 \ -1073750318 \ -1073750320 > 1+ ( 3 ) \ 2 \ -1073750318 \ -1073750319 > -rot ( 3 ) \ -1073750319 \ 2 \ -1073750318 > dup ( 4 ) \ -1073750319 \ 2 \ -1073750318 \ -1073750318 > c@ ( 4 ) \ -1073750319 \ 2 \ -1073750318 \ 125 > >r ( 3 ) \ -1073750319 \ 2 \ -1073750318 > 1+ ( 3 ) \ -1073750319 \ 2 \ -1073750317 > -rot ( 3 ) \ -1073750317 \ -1073750319 \ 2 > r> ( 4 ) \ -1073750317 \ -1073750319 \ 2 \ 125 > r> ( 5 ) \ -1073750317 \ -1073750319 \ 2 \ 125 \ 125 > = ( 4 ) \ -1073750317 \ -1073750319 \ 2 \ -1 > if ( 3 ) \ -1073750317 \ -1073750319 \ 2 > 1- ( 3 ) \ -1073750317 \ -1073750319 \ 1 > else ( 3 ) \ -1073750317 \ -1073750319 \ 1 > dup ( 4 ) \ -1073750317 \ -1073750319 \ 1 \ 1 > >r ( 3 ) \ -1073750317 \ -1073750319 \ 1 > -rot ( 3 ) \ 1 \ -1073750317 \ -1073750319 > r> ( 4 ) \ 1 \ -1073750317 \ -1073750319 \ 1 > 0< ( 4 ) \ 1 \ -1073750317 \ -1073750319 \ 0 > = ( 3 ) \ 1 \ -1073750317 \ 0 > until ( 2 ) \ 1 \ -1073750317 > dup ( 3 ) \ 1 \ -1073750317 \ -1073750317 > c@ ( 3 ) \ 1 \ -1073750317 \ 125 > >r ( 2 ) \ 1 \ -1073750317 > 1+ ( 2 ) \ 1 \ -1073750316 > -rot ( 2 ) \ -1073750320 \ 1 > dup ( 3 ) \ -1073750320 \ 1 \ 1 > c@ > > Largely untested: > > : $= ( addr1 len1 addr2 len2 -- flag) > rot \ addr1 addr2 len2 len1 > over \ addr1 addr2 len2 len1 len2 > <> if 2drop drop 0 exit then \ out if len1<>len2 > \ addr1 addr2 len2 > over + swap \ addr1 addr2+len2 addr2 > ?do dup c@ i c@ <> if drop 0 unloop exit then loop > drop true ; > > Some define "over + swap" as bounds. > > -Doug Hi Doug. Strange that it crashes for you. Runs fine on my system. Odd.
[toc] | [prev] | [next] | [standalone]
| From | Doug Hoffman <glidedog@gmail.com> |
|---|---|
| Date | 2012-11-01 12:46 -0400 |
| Message-ID | <5092a74c$0$282$14726298@news.sunsite.dk> |
| In reply to | #16940 |
On 11/1/12 11:49 AM, Mark Wills wrote: > On Nov 1, 2:34 pm, Doug Hoffman <glide...@gmail.com> wrote: >> On 11/1/12 9:31 AM, Mark Wills wrote: >> >>> I also thought $= was quite useful, >> >> COMPARE is fine by me, I already have it so $= is redundant. >> >> Nonetheless... >> >>> so I set about writing a version. >>> I found it quite torturous to write! I'd be interested to see other >>> versions. >> >>> : $= ( addr1 len1 addr2 len2 -- flag) >>> 2 pick <> if drop 2drop false else rot begin >>> dup c@ >r 1+ -rot dup c@ >r 1+ -rot >>> r> r> = if 1- else drop -1 then dup >r -rot >>> r> 0<= until then ; >> >> This crashes for me. Here's a dump: >> >> s" }}" s" }}" $= . >> ( 4 ) \ -1073750320 \ 2 \ -1073750318 \ 2 >> 2 ( 5 ) \ -1073750320 \ 2 \ -1073750318 \ 2 \ 2 >> pick ( 5 ) \ -1073750320 \ 2 \ -1073750318 \ 2 \ 2 >> <> ( 4 ) \ -1073750320 \ 2 \ -1073750318 \ 0 >> if ( 3 ) \ -1073750320 \ 2 \ -1073750318 >> rot ( 3 ) \ 2 \ -1073750318 \ -1073750320 >> begin ( 3 ) \ 2 \ -1073750318 \ -1073750320 >> dup ( 4 ) \ 2 \ -1073750318 \ -1073750320 \ -1073750320 >> c@ ( 4 ) \ 2 \ -1073750318 \ -1073750320 \ 125 >> >r ( 3 ) \ 2 \ -1073750318 \ -1073750320 >> 1+ ( 3 ) \ 2 \ -1073750318 \ -1073750319 >> -rot ( 3 ) \ -1073750319 \ 2 \ -1073750318 >> dup ( 4 ) \ -1073750319 \ 2 \ -1073750318 \ -1073750318 >> c@ ( 4 ) \ -1073750319 \ 2 \ -1073750318 \ 125 >> >r ( 3 ) \ -1073750319 \ 2 \ -1073750318 >> 1+ ( 3 ) \ -1073750319 \ 2 \ -1073750317 >> -rot ( 3 ) \ -1073750317 \ -1073750319 \ 2 >> r> ( 4 ) \ -1073750317 \ -1073750319 \ 2 \ 125 >> r> ( 5 ) \ -1073750317 \ -1073750319 \ 2 \ 125 \ 125 >> = ( 4 ) \ -1073750317 \ -1073750319 \ 2 \ -1 >> if ( 3 ) \ -1073750317 \ -1073750319 \ 2 >> 1- ( 3 ) \ -1073750317 \ -1073750319 \ 1 >> else ( 3 ) \ -1073750317 \ -1073750319 \ 1 >> dup ( 4 ) \ -1073750317 \ -1073750319 \ 1 \ 1 >> >r ( 3 ) \ -1073750317 \ -1073750319 \ 1 >> -rot ( 3 ) \ 1 \ -1073750317 \ -1073750319 >> r> ( 4 ) \ 1 \ -1073750317 \ -1073750319 \ 1 >> 0< ( 4 ) \ 1 \ -1073750317 \ -1073750319 \ 0 >> = ( 3 ) \ 1 \ -1073750317 \ 0 >> until ( 2 ) \ 1 \ -1073750317 >> dup ( 3 ) \ 1 \ -1073750317 \ -1073750317 >> c@ ( 3 ) \ 1 \ -1073750317 \ 125 >> >r ( 2 ) \ 1 \ -1073750317 >> 1+ ( 2 ) \ 1 \ -1073750316 >> -rot ( 2 ) \ -1073750320 \ 1 >> dup ( 3 ) \ -1073750320 \ 1 \ 1 >> c@ >> >> Largely untested: >> >> : $= ( addr1 len1 addr2 len2 -- flag) >> rot \ addr1 addr2 len2 len1 >> over \ addr1 addr2 len2 len1 len2 >> <> if 2drop drop 0 exit then \ out if len1<>len2 >> \ addr1 addr2 len2 >> over + swap \ addr1 addr2+len2 addr2 >> ?do dup c@ i c@ <> if drop 0 unloop exit then loop >> drop true ; >> >> Some define "over + swap" as bounds. >> >> -Doug > > Hi Doug. Strange that it crashes for you. Runs fine on my system. Odd. > It's OK. ANS doesn't have 0<=. It somehow got munged when I ran it into "0< =" which caused the crash. My error. -Doug
[toc] | [prev] | [next] | [standalone]
| From | Andrew Haley <andrew29@littlepinkcloud.invalid> |
|---|---|
| Date | 2012-11-01 09:37 -0500 |
| Message-ID | <_YCdnRk0_YWJFA_NnZ2dnUVZ8oydnZ2d@supernews.com> |
| In reply to | #16933 |
Mark Wills <forthfreak@gmail.com> wrote:
> On Oct 31, 11:16?pm, Doug Hoffman <glide...@gmail.com> wrote:
>> On 10/31/12 6:07 PM, Mark Wills wrote:
>>
>> > On Oct 31, 4:22 pm, Doug Hoffman <glide...@gmail.com> wrote:
>>
>> >>> WANT $=
>> >>> : }}? 2DUP "}}" $= ;
>>
>> >> With an ANS Forth I can't compile this. ?I get three undefined words
>> >> error messages:
>>
>> >> WANT
>> >> $=
>> >> "}}"
>> > I think WANT is the equivalent of a #include in C. Is this ciForth? So
>> > WANT conditionally includes $= if it's not already in memory.
>> > Presumably.
>>
>> Maybe someday there will some kind of standardization effort for this
>> kind of stuff. ?Might prove useful.
>
> I also thought $= was quite useful, so I set about writing a version.
> I found it quite torturous to write! I'd be interested to see other
> versions.
>
> : $= ( addr1 len1 addr2 len2 -- flag)
> 2 pick <> if drop 2drop false else rot begin
> dup c@ >r 1+ -rot dup c@ >r 1+ -rot
> r> r> = if 1- else drop -1 then dup >r -rot
> r> 0<= until then ;
>
> Quite a lot of return stack bashing required.
You need to factor:
Return 1 if +ve, -1 if -ve
: flagify ( n -- n' )
0< if -1 exit then
1 ;
\ Bump a pair of c-addrs
: bump ( c-addr1 c-addr2 -- c-addr1 c-addr2 )
1+ swap 1+ swap ;
: compare ( c-addr1 u1 c-addr2 u2 -- n )
rot min 0 do
over c@ over c@ -
?dup if >r 2drop r> flagify unloop exit then
bump
loop 2drop 0 ;
Andrew.
[toc] | [prev] | [next] | [standalone]
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Date | 2012-11-01 07:41 -0700 |
| Message-ID | <7xa9v1gzco.fsf@ruckus.brouhaha.com> |
| In reply to | #16933 |
Mark Wills <forthfreak@gmail.com> writes: > could do it without variables, however. What would seasoned Forth > programmers do here? Reach for locals/variables or is there something > much more obvious that I'm missing? I'm no seasoned Forther by any means, but I think if the first thing in your word uses PICK, you are already out of the purity zone, so you should use variables or locals. The version you wrote is (while impressive) sort of an anti-advertisement for Forth. In Colorforth, I guesss you'd use the A and B registers to hold the two pointers. That might actually work out ok.
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <forthfreak@gmail.com> |
|---|---|
| Date | 2012-11-01 08:52 -0700 |
| Message-ID | <faae232e-e820-44d4-a7b2-5ad343a0f323@h16g2000vby.googlegroups.com> |
| In reply to | #16936 |
On Nov 1, 2:41 pm, Paul Rubin <no.em...@nospam.invalid> wrote: > I'm no seasoned Forther by any means, but I think if the first thing in > your word uses PICK, you are already out of the purity zone, so you > should use variables or locals. The version you wrote is (while > impressive) sort of an anti-advertisement for Forth. > Well... If it's such a bad word, then it shouldn't be available ;-) But I know what you mean. There didn't seem to be any better alternative though at the time (though Doug's code is better than mine and avoids PICK). > The version you wrote is (while impressive) sort of an anti-advertisement for Forth. I agree. I had multiple attempts, and this was the best I could come up with. Andrew notes that I should factor more. I did consider that, but it seems excessive for a single function, and adds a performance penalty on ITC systems such as mine.
[toc] | [prev] | [next] | [standalone]
| From | Andrew Haley <andrew29@littlepinkcloud.invalid> |
|---|---|
| Date | 2012-11-01 12:18 -0500 |
| Message-ID | <mdmdnSlvaOFmMw_NnZ2dnUVZ8mednZ2d@supernews.com> |
| In reply to | #16941 |
Mark Wills <forthfreak@gmail.com> wrote: > Andrew notes that I should factor more. I did consider that, but it > seems excessive for a single function, and adds a performance > penalty on ITC systems such as mine. That is a huge, huge, mistake. In fact, it's the biggest mistake you can make in Forth programming. It's also one of the most common. An ideal forth word is a line or two, and your compare word is much longer than that. Andrew.
[toc] | [prev] | [next] | [standalone]
| From | Hugh Aguilar <hughaguilar96@yahoo.com> |
|---|---|
| Date | 2012-11-01 19:38 -0700 |
| Message-ID | <07884d5b-18f3-4696-9390-b858d76c1c51@nl3g2000pbc.googlegroups.com> |
| In reply to | #16945 |
On Nov 1, 10:18 am, Andrew Haley <andre...@littlepinkcloud.invalid> wrote: > Mark Wills <forthfr...@gmail.com> wrote: > > Andrew notes that I should factor more. I did consider that, but it > > seems excessive for a single function, and adds a performance > > penalty on ITC systems such as mine. > > That is a huge, huge, mistake. In fact, it's the biggest mistake you > can make in Forth programming. It's also one of the most common. An > ideal forth word is a line or two, and your compare word is much > longer than that. > > Andrew. Andrew is right about this. Mark, I told you that "factoring is strong magic." You put my quote in your system's manual, so you can read it there if you have forgotten. That was some really ugly Forth! For something like that, locals will help a lot. In my novice package I have +TO that is useful for stepping the pointers. You can also do without locals (I did for many many years), but in this case factoring is going to help a lot (the use of locals and the use of factoring are mutually exclusive, as functions with locals can't really be factored). You should write something clean first, without concern for speed. There is no point in writing convulated code like you did. It takes too long to get that kind of code working, and the result is just ugly. After you have a clean version working, you can rewrite it as necessary to make it faster. You will notice in my novice package I often have two versions of a function, with the readable one being commented out. It is okay to leave a history of the evolution of your words in your source-code like this. Look at my word EXCHANGE in the novice package (it exchanges records in an array during sorting), which is somewhat similar.
[toc] | [prev] | [next] | [standalone]
Page 7 of 9 — ← Prev page 1 2 3 4 5 6 [7] 8 9 Next page →
Back to top | Article view | comp.lang.forth
csiph-web