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 6 of 9 — ← Prev page 1 2 3 4 5 [6] 7 8 9 Next page →
| From | Hugh Aguilar <hughaguilar96@yahoo.com> |
|---|---|
| Date | 2012-10-31 16:15 -0700 |
| Message-ID | <26b3fff6-766e-4c06-92ca-54f76c64876d@6g2000pbh.googlegroups.com> |
| In reply to | #16902 |
On Oct 31, 2:32 pm, Paul Rubin <no.em...@nospam.invalid> wrote: > Mark Wills <forthfr...@gmail.com> writes: > > Why can't COMPARE just push a flag for God's sake! > > It's an ordered comparison function, e.g. you might want to sort a list > of strings lexicographically. Hey Mark, does this mean that binary trees are godless?
[toc] | [prev] | [next] | [standalone]
| From | Coos Haak <chforth@hccnet.nl> |
|---|---|
| Date | 2012-10-31 22:49 +0100 |
| Message-ID | <122o949y4qgay.1c1cluyt9hk95.dlg@40tude.net> |
| In reply to | #16901 |
Op Wed, 31 Oct 2012 14:27:10 -0700 (PDT) schreef Mark Wills: > On Oct 31, 4:47 pm, Andrew Haley <andre...@littlepinkcloud.invalid> > wrote: >> Mark Wills <forthfr...@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. >> >> Andrew. > > 17.6.1.0935 COMPARE > STRING > > ( c-addr1 u1 c-addr2 u2 -- n ) > > Compare the string specified by c-addr1 u1 to the string specified by > c-addr2 u2. The strings are compared, beginning at the given > addresses, character by character, up to the length of the shorter > string or until a difference is found. If the two strings are > identical, n is zero. If the two strings are identical up to the > length of the shorter string, n is minus-one (-1) if u1 is less than > u2 and one (1) otherwise. If the two strings are not identical up to > the length of the shorter string, n is minus-one (-1) if the first non- > matching character in the string specified by c-addr1 u1 has a lesser > numeric value than the corresponding character in the string specified > by c-addr2 u2 and one (1) otherwise. > > WTF?????????????????????????????? > > Why can't COMPARE just push a flag for God's sake! Oh my goodness me! > I think I need to go for a lie down! > > Just bonkers!! It does a subtraction, and can return three states: first string is less than the second, both are equal and the first string is greater than the second. Why is that bonkers? : less compare 0< ; : equal compare 0= ; : greater compare 0> ; -- Coos CHForth, 16 bit DOS applications http://home.hccnet.nl/j.j.haak/forth.html
[toc] | [prev] | [next] | [standalone]
| From | Andrew Haley <andrew29@littlepinkcloud.invalid> |
|---|---|
| Date | 2012-10-31 17:13 -0500 |
| Message-ID | <o7CdnTPA3_IdPwzNnZ2dnUVZ7oednZ2d@supernews.com> |
| In reply to | #16901 |
Mark Wills <forthfreak@gmail.com> wrote: > On Oct 31, 4:47?pm, Andrew Haley <andre...@littlepinkcloud.invalid> > wrote: >> Well, yes, but the *correct* answer to your problem is therefore >> "Write COMPARE, then use it". COMPARE is not hard to write. >> >> Andrew. > > 17.6.1.0935 COMPARE > STRING > > ( c-addr1 u1 c-addr2 u2 -- n ) > > Compare the string specified by c-addr1 u1 to the string specified > by c-addr2 u2. The strings are compared, beginning at the given > addresses, character by character, up to the length of the shorter > string or until a difference is found. If the two strings are > identical, n is zero. If the two strings are identical up to the > length of the shorter string, n is minus-one (-1) if u1 is less than > u2 and one (1) otherwise. If the two strings are not identical up to > the length of the shorter string, n is minus-one (-1) if the first > non- matching character in the string specified by c-addr1 u1 has a > lesser numeric value than the corresponding character in the string > specified by c-addr2 u2 and one (1) otherwise. > > WTF?????????????????????????????? > > Why can't COMPARE just push a flag for God's sake! Oh my goodness me! > I think I need to go for a lie down! > > Just bonkers!! Please try to act like a grownup. It's just a matter of subtracting one string from the other, character-by-character. until you get a nonzero result or the end of the string is reached. Andrew.
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <forthfreak@gmail.com> |
|---|---|
| Date | 2012-10-31 23:39 -0700 |
| Message-ID | <a97101f4-bc3b-4032-971a-9e682250535d@r6g2000yqd.googlegroups.com> |
| In reply to | #16911 |
On Oct 31, 10:13 pm, Andrew Haley <andre...@littlepinkcloud.invalid> wrote: > Mark Wills <forthfr...@gmail.com> wrote: > > On Oct 31, 4:47?pm, Andrew Haley <andre...@littlepinkcloud.invalid> > > wrote: > >> Well, yes, but the *correct* answer to your problem is therefore > >> "Write COMPARE, then use it". COMPARE is not hard to write. > > >> Andrew. > > > 17.6.1.0935 COMPARE > > STRING > > > ( c-addr1 u1 c-addr2 u2 -- n ) > > > Compare the string specified by c-addr1 u1 to the string specified > > by c-addr2 u2. The strings are compared, beginning at the given > > addresses, character by character, up to the length of the shorter > > string or until a difference is found. If the two strings are > > identical, n is zero. If the two strings are identical up to the > > length of the shorter string, n is minus-one (-1) if u1 is less than > > u2 and one (1) otherwise. If the two strings are not identical up to > > the length of the shorter string, n is minus-one (-1) if the first > > non- matching character in the string specified by c-addr1 u1 has a > > lesser numeric value than the corresponding character in the string > > specified by c-addr2 u2 and one (1) otherwise. > > > WTF?????????????????????????????? > > > Why can't COMPARE just push a flag for God's sake! Oh my goodness me! > > I think I need to go for a lie down! > > > Just bonkers!! > > Please try to act like a grownup. It's just a matter of subtracting > one string from the other, character-by-character. until you get a > nonzero result or the end of the string is reached. > > Andrew. Well here's the thing... They way you described it is clear and simple. The way the ANS doc describes is somewhat torturous! It is useful that it can return < = or > though.
[toc] | [prev] | [next] | [standalone]
| From | "Elizabeth D. Rather" <erather@forth.com> |
|---|---|
| Date | 2012-10-31 20:58 -1000 |
| Message-ID | <SeudnSb9-pwagA_NnZ2dnUVZ_sudnZ2d@supernews.com> |
| In reply to | #16929 |
On 10/31/12 8:39 PM, Mark Wills wrote:
> On Oct 31, 10:13 pm, Andrew Haley <andre...@littlepinkcloud.invalid>
> wrote:
>> Mark Wills <forthfr...@gmail.com> wrote:
>>> On Oct 31, 4:47?pm, Andrew Haley <andre...@littlepinkcloud.invalid>
>>> wrote:
>>>> Well, yes, but the *correct* answer to your problem is therefore
>>>> "Write COMPARE, then use it". COMPARE is not hard to write.
>>
>>>> Andrew.
>>
>>> 17.6.1.0935 COMPARE
>>> STRING
>>
>>> ( c-addr1 u1 c-addr2 u2 -- n )
>>
>>> Compare the string specified by c-addr1 u1 to the string specified
>>> by c-addr2 u2. The strings are compared, beginning at the given
>>> addresses, character by character, up to the length of the shorter
>>> string or until a difference is found. If the two strings are
>>> identical, n is zero. If the two strings are identical up to the
>>> length of the shorter string, n is minus-one (-1) if u1 is less than
>>> u2 and one (1) otherwise. If the two strings are not identical up to
>>> the length of the shorter string, n is minus-one (-1) if the first
>>> non- matching character in the string specified by c-addr1 u1 has a
>>> lesser numeric value than the corresponding character in the string
>>> specified by c-addr2 u2 and one (1) otherwise.
>>
>>> WTF??????????????????????????????
>>
>>> Why can't COMPARE just push a flag for God's sake! Oh my goodness me!
>>> I think I need to go for a lie down!
>>
>>> Just bonkers!!
>>
>> Please try to act like a grownup. It's just a matter of subtracting
>> one string from the other, character-by-character. until you get a
>> nonzero result or the end of the string is reached.
>>
>> Andrew.
>
> Well here's the thing... They way you described it is clear and
> simple. The way the ANS doc describes is somewhat torturous! It is
> useful that it can return < = or > though.
A standard is not a tutorial. It has to be precise and define
specifically things that the casual reader would think are common sense
(but another casual reader would think common sense to interpret
slightly differently). My Forth Programmer's Handbook (of which a pdf is
included with the free download of evaluation versions of SwiftForth)
describes it in words, with examples:
3.5 COMPARING CHARACTER STRINGS
Character-string comparisons operate on two separate character
strings. This allows the two to be compared by use of the ASCII
collating sequence.
The words in the following glossary are provided. Both of them compare
strings, but they are intended for entirely different situations.
COMPARE is intended for finding a match in a list or table, or in a sort
or binary search operation when the collating order of non-matching
strings is relevant. SEARCH is intended for finding a short string in a
longer string, as in an editor’s search function.
As an example of their use, you could compare a string whose address is
returned by NAME with one temporarily stored at PAD, testing as follows:
PAD <length> DUP NAME SWAP COMPARE
For a more detailed example, consider the two strings in Figure 12.
addr1 addr1+56
v v
This is the forest primeval, the murmuring pines and them
addr2 addr2+56
v v
This is the forest primeval, the murmuring pines and that
Table 6: String comparison examples
Phrase Result Remarks
<addr1> 55 <addr2> 55 COMPARE 0 Strings are equal
<addr1> 56 <addr2> 56 COMPARE 1 String at addr1 is later
in collating sequence
<addr1> 55 <addr2> 56 COMPARE -1 String at addr1 is
shorter, hence earlier in
collating sequence
(Hard to reproduce in text form, check out the actual book!)
Cheers,
Elizabeth
--
==================================================
Elizabeth D. Rather (US & Canada) 800-55-FORTH
FORTH Inc. +1 310.999.6784
5959 West Century Blvd. Suite 700
Los Angeles, CA 90045
http://www.forth.com
"Forth-based products and Services for real-time
applications since 1973."
==================================================
[toc] | [prev] | [next] | [standalone]
| From | Hugh Aguilar <hughaguilar96@yahoo.com> |
|---|---|
| Date | 2012-11-01 02:04 -0700 |
| Message-ID | <b209b901-d474-426c-ae35-47041d34a386@b4g2000pby.googlegroups.com> |
| In reply to | #16929 |
On Oct 31, 11:39 pm, Mark Wills <forthfr...@gmail.com> wrote:
> On Oct 31, 10:13 pm, Andrew Haley <andre...@littlepinkcloud.invalid>
> wrote:
> > Please try to act like a grownup. It's just a matter of subtracting
> > one string from the other, character-by-character. until you get a
> > nonzero result or the end of the string is reached.
>
> > Andrew.
>
> Well here's the thing... They way you described it is clear and
> simple. The way the ANS doc describes is somewhat torturous! It is
> useful that it can return < = or > though.
In Straight Forth I will have COMPARE, but I will also have a word
that checks strings for equality. If all you want is to check for
equality, that is faster because you can return FALSE when the strings
are different lengths without doing the char-by-char comparison at all
--- and it will save everybody from the non-intuitive return of 0 for
equal (0 usually means false, which would intuitively be not-equal).
Mark is right that most of the time the user only wants to check for
equality.
A lot of people already have this for clarity:
macro: str= ( adr1 cnt1 adr2 cnt2 -- equal? )
compare 0= ;
This might as well be in the standard so it can be written in assembly-
language and so it will be the same for everybody.
[toc] | [prev] | [next] | [standalone]
| From | "Rod Pemberton" <do_not_have@notemailnotz.cnm> |
|---|---|
| Date | 2012-10-31 19:13 -0400 |
| Message-ID | <k6sb2e$9de$1@speranza.aioe.org> |
| In reply to | #16901 |
"Mark Wills" <forthfreak@gmail.com> wrote in message news:53c1b304-a287-4580-b783-c78f000ab08a@h16g2000vby.googlegroups.com... ... > 17.6.1.0935 COMPARE > STRING > > ( c-addr1 u1 c-addr2 u2 -- n ) > > Compare the string specified by c-addr1 u1 to the string specified by > c-addr2 u2. The strings are compared, beginning at the given > addresses, character by character, up to the length of the shorter > string or until a difference is found. If the two strings are > identical, n is zero. If the two strings are identical up to the > length of the shorter string, n is minus-one (-1) if u1 is less than > u2 and one (1) otherwise. If the two strings are not identical up to > the length of the shorter string, n is minus-one (-1) if the first non- > matching character in the string specified by c-addr1 u1 has a lesser > numeric value than the corresponding character in the string specified > by c-addr2 u2 and one (1) otherwise. > > WTF?????????????????????????????? > > Why can't COMPARE just push a flag for God's sake! Oh my goodness me! > I think I need to go for a lie down! > > Just bonkers!! Well, Forth has _counted_ strings ... ;-) Or, pre-empting Hugh Aguilar's response: The ANS Forth committee is attempting to turn Forth into C. ANS Forth's COMPARE is now just C's strcmp() ... lol! RP
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2012-11-02 17:31 +0000 |
| Message-ID | <2012Nov2.183108@mips.complang.tuwien.ac.at> |
| In reply to | #16901 |
Mark Wills <forthfreak@gmail.com> writes:
>Why can't COMPARE just push a flag for God's sake! Oh my goodness me!
Word-savers at work! Instead of specifying STR= and STR<, they
specified COMPARE with a more complicated interface, and saved one
word.
- 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 | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Date | 2012-11-02 10:37 -0700 |
| Message-ID | <7xehkb7vnx.fsf@ruckus.brouhaha.com> |
| In reply to | #16983 |
anton@mips.complang.tuwien.ac.at (Anton Ertl) writes: > Word-savers at work! Instead of specifying STR= and STR<, they > specified COMPARE with a more complicated interface, and saved one > word. Would the other way be to write separate implementations of STR=, STR<, STR>, STR<=, and STR>= ? Seems easiest to write COMPARE and then define the rest using it.
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2012-11-02 18:12 +0000 |
| Message-ID | <2012Nov2.191217@mips.complang.tuwien.ac.at> |
| In reply to | #16984 |
Paul Rubin <no.email@nospam.invalid> writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>> Word-savers at work! Instead of specifying STR= and STR<, they
>> specified COMPARE with a more complicated interface, and saved one
>> word.
>
>Would the other way be to write separate implementations of STR=,
>STR<, STR>, STR<=, and STR>= ?
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.
Sure, if we had generic COMP UCOMP DCOMP FCOMP words with a
COMPARE-like interfaces, we could combine them with 0= 0< 0> and save
some words compared to the traditional Forth approach (and some might
argue that the resulting inefficiency can be optimized away by modern
Forth compilers, like they did in discussions about sub-cell access).
But given that Forth-94 did not go that way for cell, double-cell, and
FP comparisons, it should not have gone that way for string
comparison, either.
- 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 | "Elizabeth D. Rather" <erather@forth.com> |
|---|---|
| Date | 2012-11-02 08:29 -1000 |
| Message-ID | <Z6adnfJ-05SEjAnNnZ2dnUVZ_rOdnZ2d@supernews.com> |
| In reply to | #16987 |
On 11/2/12 8:12 AM, Anton Ertl wrote: > Paul Rubin <no.email@nospam.invalid> writes: >> anton@mips.complang.tuwien.ac.at (Anton Ertl) writes: >>> Word-savers at work! Instead of specifying STR= and STR<, they >>> specified COMPARE with a more complicated interface, and saved one >>> word. >> >> Would the other way be to write separate implementations of STR=, >> STR<, STR>, STR<=, and STR>= ? > > 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. > > Sure, if we had generic COMP UCOMP DCOMP FCOMP words with a > COMPARE-like interfaces, we could combine them with 0= 0< 0> and save > some words compared to the traditional Forth approach (and some might > argue that the resulting inefficiency can be optimized away by modern > Forth compilers, like they did in discussions about sub-cell access). > But given that Forth-94 did not go that way for cell, double-cell, and > FP comparisons, it should not have gone that way for string > comparison, either. If you're doing a sort, it's far more useful to have a single comparison word that gives you the answer. FORTH, Inc. had a word -TEXT which was similar (simpler) and used in out database package. COMPARE is more general. String comparisons are not used in applications in ways that are directly analogous to numeric comparisons. The needs are a little different. STR= and STR< would be far less useful than COMPARE, I think. Cheers, Elizabeth -- ================================================== Elizabeth D. Rather (US & Canada) 800-55-FORTH FORTH Inc. +1 310.999.6784 5959 West Century Blvd. Suite 700 Los Angeles, CA 90045 http://www.forth.com "Forth-based products and Services for real-time applications since 1973." ==================================================
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2012-11-05 14:53 +0000 |
| Message-ID | <2012Nov5.155319@mips.complang.tuwien.ac.at> |
| In reply to | #16989 |
"Elizabeth D. Rather" <erather@forth.com> writes:
>On 11/2/12 8:12 AM, Anton Ertl wrote:
>> Paul Rubin <no.email@nospam.invalid> writes:
>>> anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>>>> Word-savers at work! Instead of specifying STR= and STR<, they
>>>> specified COMPARE with a more complicated interface, and saved one
>>>> word.
>>>
>>> Would the other way be to write separate implementations of STR=,
>>> STR<, STR>, STR<=, and STR>= ?
>>
>> 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.
>>
>> Sure, if we had generic COMP UCOMP DCOMP FCOMP words with a
>> COMPARE-like interfaces, we could combine them with 0= 0< 0> and save
>> some words compared to the traditional Forth approach (and some might
>> argue that the resulting inefficiency can be optimized away by modern
>> Forth compilers, like they did in discussions about sub-cell access).
>> But given that Forth-94 did not go that way for cell, double-cell, and
>> FP comparisons, it should not have gone that way for string
>> comparison, either.
>
>If you're doing a sort, it's far more useful to have a single comparison
>word that gives you the answer.
As Bernd explained, STR<= is good for sorting, and I am sure STR<
would not be any worse than COMPARE.
>String comparisons are not used in applications in ways that are
>directly analogous to numeric comparisons. The needs are a little
>different. STR= and STR< would be far less useful than COMPARE, I think.
Well, I used COMPARE for quite some time, because it was the standard
string comparison word, but after a while I noticed that it was
usually not quite what I needed, eventually I found a few patterns and
factored them into words (plus a word that covers the rest):
str= c-addr1 u1 c-addr2 u2 -- f
str< c-addr1 u1 c-addr2 u2 -- f
string-prefix? c-addr1 u1 c-addr2 u2 -- f
Is c-addr2 u2 a prefix of c-addr1 u1?
Let's see how often they occur in the Gforth sources:
[c8:/tmp/gforth:31919] grep -i 'compare' *.fs kernel/*.fs|wc -l
23
[c8:/tmp/gforth:31920] grep -i 'str=' *.fs kernel/*.fs|wc -l
57
[c8:/tmp/gforth:31921] grep -i 'str<' *.fs kernel/*.fs|wc -l
0
[c8:/tmp/gforth:31922] grep -i 'string-prefix?' *.fs kernel/*.fs|wc -l
26
And of the 23 lines where COMPARE occurs, 6 are in comments, 2 are in
listings of Forth-94 names, 5 refer to words that contain "compare" in
their name (but are not COMPARE), and the rest is:
glosgen.fs: DUP @ 2 CELLS + COUNT CHARPTR @ 2 CELLS + COUNT COMPARE 0<=
Could be replaced with STR<= (or, written a bit differently, with STR<).
glosgen.fs: SCAN-WORD S" (" COMPARE 0= IF
glosgen.fs: HERE C@ 1 > HERE CHAR+ 2 S" \G" COMPARE 0= AND
prims2x.fs: name-filename 2@ last-name-filename 2@ compare if
prims2x.fs: s" #line " r@ over compare if
prims2x0.6.2.fs: name-filename 2@ last-name-filename 2@ compare if
prims2x0.6.2.fs: s" #line " r@ over compare if
regexp.fs: dup >r 2>r rest$ r@ umin 2r> compare IF rdrop true ELSE r> + false THEN ;
regexp.fs:: ,=" ( addr u -- ) tuck dup ]] rest$ Literal umin SLiteral compare ?LEAVE Literal + [[ ;
All these occurences could obviously be replaced with STR= or STR<>.
wf.fs: '# scan 1 /string toc-name $@ compare >r
which is later followed by
r@ 0= IF s" *]|-@/circle.jpg"
...
3 OF r@ 0= IF s" circle" ELSE s" down" THEN class= ENDOF
...
rdrop
So this COMPARE could also be replaced by STR=.
It's true, though, that there is a difference between string
comparisons and numeric comparisons: Strings are more rarely compared
for the <, <=, >, >= relations (given that COMPARE does not compare
according to the collating order, it would not be a good word for that
in most cases anyway). While comparison for equality is most frequent
in numerical comparisons, too, the proportion of < comparisons is
still quite a bit higher:
[c8:/tmp/gforth:31934] grep ' = ' *.fs kernel/*.fs|grep -v 'd<>'|wc -l
374
[c8:/tmp/gforth:31935] grep ' u< ' *.fs kernel/*.fs|grep -v 'd<>'|wc -l
36
[c8:/tmp/gforth:31936] grep ' < ' *.fs kernel/*.fs|grep -v 'd<>'|wc -l
29
- 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 | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Date | 2012-11-02 11:30 -0700 |
| Message-ID | <7xobjf97sp.fsf@ruckus.brouhaha.com> |
| In reply to | #16987 |
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? F<= doesn't face that issue to the same extent, since floats are fixed-size.
[toc] | [prev] | [next] | [standalone]
| From | Bernd Paysan <bernd.paysan@gmx.de> |
|---|---|
| Date | 2012-11-03 00:15 +0100 |
| Message-ID | <1484723.8tIG7fdbSn@sunwukong.fritz.box> |
| In reply to | #16990 |
Paul Rubin wrote:
> 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? F<= doesn't face that issue to the same
> extent, since floats are fixed-size.
: str> ( addr1 u1 addr2 u2 -- flag ) 2swap str< ;
: str<= ( addr1 u1 addr2 u2 -- flag ) str> 0= ;
: str>= ( addr1 u1 addr2 u2 -- flag ) str< 0= ;
Should be obvious. You declare F<= the same way: FSWAP F< 0=.
I would go for str= and str<= as implemented primitives, because for
sorting, you want str<= ("already sorted"). Creating two-primitve
composites for the other three cases is not such a big problem, and the
two most performance critical parts have an easy interface.
--
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/
[toc] | [prev] | [next] | [standalone]
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2012-11-02 19:21 -0400 |
| Message-ID | <k71kht$1to$1@dont-email.me> |
| In reply to | #17000 |
On 11/2/2012 7:15 PM, Bernd Paysan wrote:
> Paul Rubin wrote:
>
>> 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? F<= doesn't face that issue to the same
>> extent, since floats are fixed-size.
>
> : str> ( addr1 u1 addr2 u2 -- flag ) 2swap str< ;
> : str<= ( addr1 u1 addr2 u2 -- flag ) str> 0= ;
> : str>= ( addr1 u1 addr2 u2 -- flag ) str< 0= ;
>
> Should be obvious. You declare F<= the same way: FSWAP F< 0=.
>
> I would go for str= and str<= as implemented primitives, because for
> sorting, you want str<= ("already sorted"). Creating two-primitve
> composites for the other three cases is not such a big problem, and the
> two most performance critical parts have an easy interface.
I think you are missing his point. COMPARE gives you all this info. If
you want to do sorting you need to run more than one of these words.
His point about floats is that they are not expensive to scan more than
one. Strings can be much longer and more wasteful to scan a couple of
times.
Rick
[toc] | [prev] | [next] | [standalone]
| From | Bernd Paysan <bernd.paysan@gmx.de> |
|---|---|
| Date | 2012-11-03 00:42 +0100 |
| Message-ID | <1659118.lGSJc3r8GA@sunwukong.fritz.box> |
| In reply to | #17001 |
rickman wrote: > I think you are missing his point. COMPARE gives you all this info. > If you want to do sorting you need to run more than one of these > words. I think you are missing my point. When you are sorting, you are fine with just STR<=. Yes, indeed, it is completely sufficient to have exactly one word which tells you that the two elements in the sorted array are "in order", for whatever order that is. > His point about floats is that they are not expensive to scan more > than one. His point is that he can't imagine how you can make STR<= out of STR< and STR= without resorting to scanning the string twice, i.e. he thinks : str<= ( addr1 u1 addr2 u2 -- flag ) 2over 2over str= >r str< r> or ; > Strings can be much longer and more wasteful to scan a couple of > times. Yes, but that's not needed. All you need is to swap inputs and invert the flag; both true for floating point an for strings. One less (or less-or-equal) operator is enough; the others can be derived through input swap and output flag inversion. COMPARE can be useful in a tree algorithm: You have three choices: left, right, or leaf. You probably want a Fortran-style three-way IF, too :-). Something like compare IFLEAF ." found" LEFT >left @ recurse RIGHT >right @ recurse THEN -- Bernd Paysan "If you want it done right, you have to do it yourself" http://bernd-paysan.de/
[toc] | [prev] | [next] | [standalone]
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2012-11-02 20:21 -0400 |
| Message-ID | <k71o2b$o4j$1@dont-email.me> |
| In reply to | #17002 |
On 11/2/2012 7:42 PM, Bernd Paysan wrote: > rickman wrote: >> I think you are missing his point. COMPARE gives you all this info. >> If you want to do sorting you need to run more than one of these >> words. > > I think you are missing my point. When you are sorting, you are fine > with just STR<=. Yes, indeed, it is completely sufficient to have > exactly one word which tells you that the two elements in the sorted > array are "in order", for whatever order that is. But that does not distinguish if they are equal in which case you may need to toss one. It depends on what you are doing. >> His point about floats is that they are not expensive to scan more >> than one. > > His point is that he can't imagine how you can make STR<= out of STR< > and STR= without resorting to scanning the string twice, i.e. he thinks > > : str<= ( addr1 u1 addr2 u2 -- flag ) 2over 2over str=>r str< r> or ; That's not what he said. >> Strings can be much longer and more wasteful to scan a couple of >> times. > > Yes, but that's not needed. All you need is to swap inputs and invert > the flag; both true for floating point an for strings. One less (or > less-or-equal) operator is enough; the others can be derived through > input swap and output flag inversion. > > COMPARE can be useful in a tree algorithm: And in other cases where you need to know the three cases, < > AND =. Rick
[toc] | [prev] | [next] | [standalone]
| From | Bernd Paysan <bernd.paysan@gmx.de> |
|---|---|
| Date | 2012-11-03 01:44 +0100 |
| Message-ID | <2543549.1dnNXJNjEV@sunwukong.fritz.box> |
| In reply to | #17003 |
rickman wrote: >> His point is that he can't imagine how you can make STR<= out of STR< >> and STR= without resorting to scanning the string twice, i.e. he >> thinks >> >> : str<= ( addr1 u1 addr2 u2 -- flag ) 2over 2over str=>r str< r> >> : or ; > > That's not what he said. 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). If you want an unique sort (where you drop dupes), you can sort first, and then drop the non-unique strings, which is just a scan with the same STR<=, this time with string[index+1]<=string[index], which holds only true if it's a dupe. However, with mergesort, you probably want a three-way compare, as you can remove dupes as you merge together sorted arrays. The three-way compare has its place, but where it doesn't, it's overgeneralized, and therefore complicated the program. -- Bernd Paysan "If you want it done right, you have to do it yourself" http://bernd-paysan.de/
[toc] | [prev] | [next] | [standalone]
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2012-11-03 12:12 -0400 |
| Message-ID | <k73fpm$5ro$1@dont-email.me> |
| In reply to | #17004 |
On 11/2/2012 8:44 PM, Bernd Paysan wrote: > rickman wrote: >>> His point is that he can't imagine how you can make STR<= out of STR< >>> and STR= without resorting to scanning the string twice, i.e. he >>> thinks >>> >>> : str<= ( addr1 u1 addr2 u2 -- flag ) 2over 2over str=>r str< r> >>> : or ; >> >> That's not what he said. > > 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. Rick
[toc] | [prev] | [next] | [standalone]
| From | Bernd Paysan <bernd.paysan@gmx.de> |
|---|---|
| Date | 2012-11-03 18:24 +0100 |
| Message-ID | <1518027.r8V2Xobblv@sunwukong.fritz.box> |
| In reply to | #17009 |
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. -- Bernd Paysan "If you want it done right, you have to do it yourself" http://bernd-paysan.de/
[toc] | [prev] | [next] | [standalone]
Page 6 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