Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #18656 > unrolled thread
| Started by | gavino_himself <visploveslisp@gmail.com> |
|---|---|
| First post | 2013-01-11 04:22 -0800 |
| Last post | 2013-03-09 21:04 +0000 |
| Articles | 13 on this page of 113 — 26 participants |
Back to article view | Back to comp.lang.forth
structure and interpretation of computer programs exercsie 1.3 in forth gavino_himself <visploveslisp@gmail.com> - 2013-01-11 04:22 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Alex McDonald <blog@rivadpm.com> - 2013-01-11 05:47 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <forthfreak@gmail.com> - 2013-01-11 06:12 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth gavino_himself <visploveslisp@gmail.com> - 2013-01-11 06:18 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <forthfreak@gmail.com> - 2013-01-11 06:20 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <forthfreak@gmail.com> - 2013-01-11 06:19 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth gavino_himself <visploveslisp@gmail.com> - 2013-01-11 06:38 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <forthfreak@gmail.com> - 2013-01-11 06:51 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth gavino_himself <visploveslisp@gmail.com> - 2013-01-11 07:10 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth gavino_himself <visploveslisp@gmail.com> - 2013-01-11 07:58 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth rickman <gnuarm@gmail.com> - 2013-01-14 10:01 -0500
Re: structure and interpretation of computer programs exercsie 1.3 in forth gavino_himself <visploveslisp@gmail.com> - 2013-01-11 06:25 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth gavino_himself <visploveslisp@gmail.com> - 2013-01-11 06:28 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <forthfreak@gmail.com> - 2013-01-11 06:33 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth gavino_himself <visploveslisp@gmail.com> - 2013-01-11 06:37 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <forthfreak@gmail.com> - 2013-01-11 06:56 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth gavino_himself <visploveslisp@gmail.com> - 2013-01-11 08:03 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth gavino_himself <visploveslisp@gmail.com> - 2013-01-11 08:06 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <forthfreak@gmail.com> - 2013-01-11 12:27 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth gavino_himself <visploveslisp@gmail.com> - 2013-01-13 17:32 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <forthfreak@gmail.com> - 2013-01-13 23:21 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <forthfreak@gmail.com> - 2013-01-13 23:41 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Paul Rubin <no.email@nospam.invalid> - 2013-01-13 23:43 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <forthfreak@gmail.com> - 2013-01-14 00:02 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth "Elizabeth D. Rather" <erather@forth.com> - 2013-01-14 22:43 +1300
Re: structure and interpretation of computer programs exercsie 1.3 in forth Paul Rubin <no.email@nospam.invalid> - 2013-01-14 02:41 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2013-01-14 11:13 +0000
Re: structure and interpretation of computer programs exercsie 1.3 in forth albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-01-14 11:16 +0000
Re: structure and interpretation of computer programs exercsie 1.3 in forth mhx@iae.nl (Marcel Hendrix) - 2013-01-14 21:27 +0200
Re: structure and interpretation of computer programs exercsie 1.3 in forth Howerd <howerdo@yahoo.co.uk> - 2013-01-14 03:34 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-01-14 12:53 +0000
Re: structure and interpretation of computer programs exercsie 1.3 in forth "Elizabeth D. Rather" <erather@forth.com> - 2013-01-17 17:31 +1300
Re: structure and interpretation of computer programs exercsie 1.3 in forth Hugh Aguilar <hughaguilar96@yahoo.com> - 2013-01-21 19:35 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Paul Rubin <no.email@nospam.invalid> - 2013-01-14 02:55 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth rickman <gnuarm@gmail.com> - 2013-01-14 10:14 -0500
Re: structure and interpretation of computer programs exercsie 1.3 in forth Bernd Paysan <bernd.paysan@gmx.de> - 2013-01-14 20:04 +0100
Re: structure and interpretation of computer programs exercsie 1.3 in forth Hugh Aguilar <hughaguilar96@yahoo.com> - 2013-01-21 19:57 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <forthfreak@gmail.com> - 2013-01-21 23:19 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Hugh Aguilar <hughaguilar96@yahoo.com> - 2013-01-24 18:58 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Alex McDonald <blog@rivadpm.com> - 2013-01-25 15:46 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Pablo Hugo Reda <pabloreda@gmail.com> - 2013-01-25 19:09 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Alex McDonald <blog@rivadpm.com> - 2013-01-26 01:12 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth mhx@iae.nl (Marcel Hendrix) - 2013-01-26 12:58 +0200
Re: structure and interpretation of computer programs exercsie 1.3 in forth Alex McDonald <blog@rivadpm.com> - 2013-01-26 04:42 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-01-26 14:35 +0000
Re: structure and interpretation of computer programs exercsie 1.3 in forth "WJ" <w_a_x_man@yahoo.com> - 2013-06-14 15:37 +0000
Re: structure and interpretation of computer programs exercsie 1.3 in forth gavino_himself <visploveslisp@gmail.com> - 2013-01-21 22:38 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <forthfreak@gmail.com> - 2013-01-11 12:36 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth gavino_himself <visploveslisp@gmail.com> - 2013-01-13 17:33 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth "Elizabeth D. Rather" <erather@forth.com> - 2013-01-14 22:46 +1300
Re: structure and interpretation of computer programs exercsie 1.3 in forth rickman <gnuarm@gmail.com> - 2013-01-14 10:20 -0500
Re: structure and interpretation of computer programs exercsie 1.3 in forth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-01-14 10:41 -0600
Re: structure and interpretation of computer programs exercsie 1.3 in forth "Elizabeth D. Rather" <erather@forth.com> - 2013-01-17 17:34 +1300
Re: structure and interpretation of computer programs exercsie 1.3 in forth gavino_himself <visploveslisp@gmail.com> - 2013-01-21 22:48 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth gavino_himself <visploveslisp@gmail.com> - 2013-01-21 22:49 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <forthfreak@gmail.com> - 2013-01-21 23:55 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth "Ed" <invalid@nospam.com> - 2013-01-18 12:50 +1100
Re: structure and interpretation of computer programs exercsie 1.3 in forth Bernd Paysan <bernd.paysan@gmx.de> - 2013-01-18 23:31 +0100
Re: structure and interpretation of computer programs exercsie 1.3 in forth "Ed" <invalid@nospam.com> - 2013-01-20 12:42 +1100
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <markrobertwills@yahoo.co.uk> - 2013-01-20 01:24 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Hugh Aguilar <hughaguilar96@yahoo.com> - 2013-01-20 15:51 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth "Elizabeth D. Rather" <erather@forth.com> - 2013-01-21 22:14 +1300
Re: structure and interpretation of computer programs exercsie 1.3 in forth Hugh Aguilar <hughaguilar96@yahoo.com> - 2013-01-21 19:14 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth "A. K." <akk@nospam.org> - 2013-01-20 11:13 +0100
Re: structure and interpretation of computer programs exercsie 1.3 in forth Paul Rubin <no.email@nospam.invalid> - 2013-01-20 02:45 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-01-21 17:14 +0000
Re: structure and interpretation of computer programs exercsie 1.3 in forth Paul Rubin <no.email@nospam.invalid> - 2013-01-23 01:52 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-01-23 04:25 -0600
Re: structure and interpretation of computer programs exercsie 1.3 in forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-01-23 15:20 +0000
Re: structure and interpretation of computer programs exercsie 1.3 in forth Paul Rubin <no.email@nospam.invalid> - 2013-01-23 09:29 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-01-23 17:40 +0000
Re: structure and interpretation of computer programs exercsie 1.3 in forth Paul Rubin <no.email@nospam.invalid> - 2013-01-23 22:03 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth "Elizabeth D. Rather" <erather@forth.com> - 2013-01-24 22:13 +1300
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <forthfreak@gmail.com> - 2013-01-24 02:57 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Paul Rubin <no.email@nospam.invalid> - 2013-01-26 13:49 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth "Elizabeth D. Rather" <erather@forth.com> - 2013-01-26 12:40 -1000
Re: structure and interpretation of computer programs exercsie 1.3 in forth Paul Rubin <no.email@nospam.invalid> - 2013-01-26 23:20 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth mhx@iae.nl (Marcel Hendrix) - 2013-01-27 09:52 +0200
Re: structure and interpretation of computer programs exercsie 1.3 in forth "Paul E. Bennett" <Paul_E.Bennett@topmail.co.uk> - 2013-01-23 23:05 +0000
Re: structure and interpretation of computer programs exercsie 1.3 in forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-01-21 17:05 +0000
Re: structure and interpretation of computer programs exercsie 1.3 in forth "A. K." <akk@nospam.org> - 2013-01-21 19:28 +0100
Re: structure and interpretation of computer programs exercsie 1.3 in forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-01-22 17:43 +0000
Re: structure and interpretation of computer programs exercsie 1.3 in forth "Paul E. Bennett" <Paul_E.Bennett@topmail.co.uk> - 2013-01-22 19:12 +0000
Re: structure and interpretation of computer programs exercsie 1.3 in forth stephenXXX@mpeforth.com (Stephen Pelc) - 2013-01-21 12:13 +0000
Re: structure and interpretation of computer programs exercsie 1.3 in forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-01-21 17:28 +0000
Re: structure and interpretation of computer programs exercsie 1.3 in forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-01-22 18:06 +0000
Re: structure and interpretation of computer programs exercsie 1.3 in forth Bernd Paysan <bernd.paysan@gmx.de> - 2013-01-22 19:30 +0100
Re: structure and interpretation of computer programs exercsie 1.3 in forth gavino_himself <visploveslisp@gmail.com> - 2013-01-21 23:06 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <forthfreak@gmail.com> - 2013-01-22 02:20 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <forthfreak@gmail.com> - 2013-01-22 03:36 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <forthfreak@gmail.com> - 2013-01-22 06:51 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth marko <marko@marko.marko> - 2013-01-24 22:14 +1100
Re: structure and interpretation of computer programs exercsie 1.3 in forth the_gavino_himself <visphatesjava@gmail.com> - 2013-01-27 20:39 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth marko <marko@marko.marko> - 2013-02-01 22:07 +1100
Re: structure and interpretation of computer programs exercsie 1.3 in forth marko <marko@marko.marko> - 2013-02-01 22:53 +1100
Re: structure and interpretation of computer programs exercsie 1.3 in forth the_gavino_himself <visphatesjava@gmail.com> - 2013-02-08 19:50 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Elizabeth D Rather <erather@forth.com> - 2013-02-08 19:22 -1000
Re: structure and interpretation of computer programs exercsie 1.3 in forth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-01-11 11:44 -0600
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <forthfreak@gmail.com> - 2013-01-11 12:34 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth gavino_himself <visploveslisp@gmail.com> - 2013-01-11 06:18 -0800
Re:structure and interpretation of computer programs exercsie 1.3 in forth Hans Bezemer <the.beez.speaks@gmail.com> - 2013-01-14 00:13 +0100
Re: structure and interpretation of computer programs exercsie 1.3 in forth Doug Hoffman <glidedog@gmail.com> - 2013-01-13 19:12 -0500
Re: structure and interpretation of computer programs exercsie 1.3 in forth gavino_himself <visploveslisp@gmail.com> - 2013-01-13 18:26 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2013-01-14 08:29 +0000
Re: structure and interpretation of computer programs exercsie 1.3 in forth Hans Bezemer <the.beez.speaks@gmail.com> - 2013-01-14 23:52 +0100
Re: structure and interpretation of computer programs exercsie 1.3 in forth gavino_himself <visploveslisp@gmail.com> - 2013-01-13 18:31 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <forthfreak@gmail.com> - 2013-01-13 23:19 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth gavino_himself <visploveslisp@gmail.com> - 2013-01-21 22:46 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth Mark Wills <forthfreak@gmail.com> - 2013-01-21 23:40 -0800
Re: structure and interpretation of computer programs exercsie 1.3 in forth "WJ" <w_a_x_man@yahoo.com> - 2013-02-28 15:38 +0000
Re: structure and interpretation of computer programs exercsie 1.3 in forth "WJ" <w_a_x_man@yahoo.com> - 2013-02-28 16:37 +0000
Re: structure and interpretation of computer programs exercsie 1.3 in forth Doug Hoffman <glidedog@gmail.com> - 2013-03-01 05:24 -0500
Re: structure and interpretation of computer programs exercsie 1.3 in forth "WJ" <w_a_x_man@yahoo.com> - 2013-03-09 21:04 +0000
Page 6 of 6 — ← Prev page 1 2 3 4 5 [6]
| From | Hans Bezemer <the.beez.speaks@gmail.com> |
|---|---|
| Date | 2013-01-14 00:13 +0100 |
| Message-ID | <50f33fae$0$6915$e4fe514c@news2.news.xs4all.nl> |
| In reply to | #18656 |
gavino_himself <visploveslisp@gmail.com> Wrote in message: > Exercise 1.3. Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers. > > Please post a forth solution. > : square+ over max dup * >r max dup * r> + ; I don't like IF's. Hans Bezemer -- ----Android NewsGroup Reader---- http://www.piaohong.tk/newsgroup
[toc] | [prev] | [next] | [standalone]
| From | Doug Hoffman <glidedog@gmail.com> |
|---|---|
| Date | 2013-01-13 19:12 -0500 |
| Message-ID | <50f34d55$0$295$14726298@news.sunsite.dk> |
| In reply to | #18724 |
On 1/13/13 6:13 PM, Hans Bezemer wrote: > : square+ over max dup * >r max dup * r> + ; > > I don't like IF's. This solution appears to be flawed: 1 2 3 square+ . 13 ok 1 3 2 square+ . 18 ok -Doug
[toc] | [prev] | [next] | [standalone]
| From | gavino_himself <visploveslisp@gmail.com> |
|---|---|
| Date | 2013-01-13 18:26 -0800 |
| Message-ID | <5131b255-2cad-40a9-972c-1e5c91be66ae@googlegroups.com> |
| In reply to | #18725 |
On Sunday, January 13, 2013 4:12:03 PM UTC-8, Doug Hoffman wrote: > On 1/13/13 6:13 PM, Hans Bezemer wrote: > > > > > : square+ over max dup * >r max dup * r> + ; > > > > > > I don't like IF's. > > > > This solution appears to be flawed: > > > > 1 2 3 square+ . 13 ok > > 1 3 2 square+ . 18 ok > > > > -Doug same result for me in gforth
[toc] | [prev] | [next] | [standalone]
| From | Gerry Jackson <gerry@jackson9000.fsnet.co.uk> |
|---|---|
| Date | 2013-01-14 08:29 +0000 |
| Message-ID | <kd0fl8$t1p$1@dont-email.me> |
| In reply to | #18725 |
On 14/01/2013 00:12, Doug Hoffman wrote: > On 1/13/13 6:13 PM, Hans Bezemer wrote: > >> : square+ over max dup * >r max dup * r> + ; >> >> I don't like IF's. > > This solution appears to be flawed: > > 1 2 3 square+ . 13 ok > 1 3 2 square+ . 18 ok > > -Doug You beat me to it, I think he means something like: : square+ 2dup max >r min max dup * r> dup * + ; -- Gerry
[toc] | [prev] | [next] | [standalone]
| From | Hans Bezemer <the.beez.speaks@gmail.com> |
|---|---|
| Date | 2013-01-14 23:52 +0100 |
| Message-ID | <50f48c19$0$6924$e4fe514c@news2.news.xs4all.nl> |
| In reply to | #18749 |
Gerry Jackson <gerry@jackson9000.fsnet.co.uk> Wrote in message: > On 14/01/2013 00:12, Doug Hoffman wrote: >> On 1/13/13 6:13 PM, Hans Bezemer wrote: > You beat me to it, I think he means something like: > > : square+ 2dup max >r min max dup * r> dup * + ; > I stand corrected ;-) This one seems to work. Hans Bezemer -- ----Android NewsGroup Reader---- http://www.piaohong.tk/newsgroup
[toc] | [prev] | [next] | [standalone]
| From | gavino_himself <visploveslisp@gmail.com> |
|---|---|
| Date | 2013-01-13 18:31 -0800 |
| Message-ID | <67f09aa3-eb67-451b-be1d-8ae9e3c3b63c@googlegroups.com> |
| In reply to | #18724 |
On Sunday, January 13, 2013 3:13:55 PM UTC-8, The Beez wrote: > gavino_himself <visploveslisp@gmail.com> Wrote in message: > > > Exercise 1.3. Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers. > > > > > > Please post a forth solution. > > > > > > > : square+ over max dup * >r max dup * r> + ; > > > > I don't like IF's. > > > > Hans Bezemer > > -- > > > > > > > > ----Android NewsGroup Reader---- > > http://www.piaohong.tk/newsgroup I heard mr moore does not like conditionals as well... I am interested in ways to get around them.
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <forthfreak@gmail.com> |
|---|---|
| Date | 2013-01-13 23:19 -0800 |
| Message-ID | <5532d149-3af5-4bb7-8033-abad9325c184@x10g2000yqx.googlegroups.com> |
| In reply to | #18724 |
On Jan 13, 11:13 pm, Hans Bezemer <the.beez.spe...@gmail.com> wrote: > gavino_himself <visplovesl...@gmail.com> Wrote in message: > > > Exercise 1.3. Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers. > > > Please post a forth solution. > > : square+ over max dup * >r max dup * r> + ; > > I don't like IF's. > > Hans Bezemer > -- > > ----Android NewsGroup Reader----http://www.piaohong.tk/newsgroup Nope. Try again.
[toc] | [prev] | [next] | [standalone]
| From | gavino_himself <visploveslisp@gmail.com> |
|---|---|
| Date | 2013-01-21 22:46 -0800 |
| Message-ID | <afb5f4c7-ee4b-457e-98de-f3fb6847541a@googlegroups.com> |
| In reply to | #18743 |
On Sunday, January 13, 2013 11:19:56 PM UTC-8, M.R.W Wills wrote: > On Jan 13, 11:13 pm, Hans Bezemer <the.beez.spe...@gmail.com> wrote: > > > gavino_himself <visplovesl...@gmail.com> Wrote in message: > > > > > > > Exercise 1.3. Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers. > > > > > > > Please post a forth solution. > > > > > > : square+ over max dup * >r max dup * r> + ; > > > > > > I don't like IF's. > > > > > > Hans Bezemer > > > -- > > > > > > ----Android NewsGroup Reader----http://www.piaohong.tk/newsgroup > > > > Nope. > > > > Try again. : square+ 2dup max >r min max dup * r> dup * + ; ## this seems to work on gforth :) I noticed the avoiding conditionals thing before in some charles moore stuff I read. How do you learn howto avoid conditionals?
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <forthfreak@gmail.com> |
|---|---|
| Date | 2013-01-21 23:40 -0800 |
| Message-ID | <d6686d32-1ddf-4619-b30f-29a778efc9f2@g8g2000vbf.googlegroups.com> |
| In reply to | #18981 |
On Jan 22, 6:46 am, gavino_himself <visplovesl...@gmail.com> wrote: > On Sunday, January 13, 2013 11:19:56 PM UTC-8, M.R.W Wills wrote: > > On Jan 13, 11:13 pm, Hans Bezemer <the.beez.spe...@gmail.com> wrote: > > > > gavino_himself <visplovesl...@gmail.com> Wrote in message: > > > > > Exercise 1.3. Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers. > > > > > Please post a forth solution. > > > > : square+ over max dup * >r max dup * r> + ; > > > > I don't like IF's. > > > > Hans Bezemer > > > > -- > > > > ----Android NewsGroup Reader----http://www.piaohong.tk/newsgroup > > > Nope. > > > Try again. > > : square+ 2dup max >r min max dup * r> dup * + ; > > ## this seems to work on gforth :) > > I noticed the avoiding conditionals thing before in some charles moore stuff I read. How do you learn howto avoid conditionals?- Hide quoted text - > > - Show quoted text - I'm not convinced that it's something you need to worry about on modern processors which feature branch prediction; though others here are far more qualified to offer an opinion on that than me. Also, don't forget that modern Forth compilers such as VFX include a very sophisticated optimizer that is very effective - they understand your source code and can optimize accordingly. It could be that writing obfuscated/tortured code at the source-code level to include what appears to be optimzations (in the mind of the programmer) could upset the optimizer, which is looking for common patterns or code- phrases in order to apply optimizations. You could end up with code that is significantly less optimal than you think. Again, others here are more qualified than me. I would say if coding on a modern Forth (or C) system, just write straight-ahead obvious code as much as you can, and the let optimizer do its work!
[toc] | [prev] | [next] | [standalone]
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Date | 2013-02-28 15:38 +0000 |
| Message-ID | <kgntle02jta@enews6.newsguy.com> |
| In reply to | #18656 |
gavino_himself wrote:
> Exercise 1.3. Define a procedure that takes three numbers
> as arguments and returns the sum of the squares of the two
> larger numbers.
> Please post a forth solution.
I broke your lines for you. When you post to usenet, you must
limit the length of your lines.
Here's a solution in Racket that accepts any number of inputs
in a sequence.
: g ( seq -- n ) [ <=> ] sort 2 tail* 0 [ sq + ] reduce ;
{ 0 9 1 8 7 6 5 4 3 2 } g .
145
[toc] | [prev] | [next] | [standalone]
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Date | 2013-02-28 16:37 +0000 |
| Message-ID | <kgo14k02lcj@enews6.newsguy.com> |
| In reply to | #20097 |
WJ wrote:
> Here's a solution in Racket
Wrong. Should have been "Factor".
> that accepts any number of inputs
> in a sequence.
>
> : g ( seq -- n ) [ <=> ] sort 2 tail* 0 [ sq + ] reduce ;
>
> { 0 9 1 8 7 6 5 4 3 2 } g .
>
> 145
[toc] | [prev] | [next] | [standalone]
| From | Doug Hoffman <glidedog@gmail.com> |
|---|---|
| Date | 2013-03-01 05:24 -0500 |
| Message-ID | <513081eb$0$287$14726298@news.sunsite.dk> |
| In reply to | #20097 |
On 2/28/13 10:38 AM, WJ wrote:
> gavino_himself wrote:
>
>> Exercise 1.3. Define a procedure that takes three numbers
>> as arguments and returns the sum of the squares of the two
>> larger numbers.
>> Please post a forth solution.
>
> I broke your lines for you. When you post to usenet, you must
> limit the length of your lines.
Not if you use adequate software such as Thunderbird.
> Here's a solution in Racket that accepts any number of inputs
> in a sequence.
>
> : g ( seq -- n ) [ <=> ] sort 2 tail* 0 [ sq + ] reduce ;
>
> { 0 9 1 8 7 6 5 4 3 2 } g .
>
> 145
ANS Forth using some (of my) library functions:
: g { seq -- n }
seq sort:
seq last: dup * seq 2last: dup * + ;
i{ 0 9 1 8 7 6 5 4 3 2 } g .
145 ok
i{ 3 2 1 } g .
13 ok
Just one way, of many possible, to do it in Forth.
-Doug
[toc] | [prev] | [next] | [standalone]
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Date | 2013-03-09 21:04 +0000 |
| Message-ID | <khg84v$v56$1@dont-email.me> |
| In reply to | #20097 |
WJ wrote:
> gavino_himself wrote:
>
> > Exercise 1.3. Define a procedure that takes three numbers
> > as arguments and returns the sum of the squares of the two
> > larger numbers.
> > Please post a forth solution.
>
> I broke your lines for you. When you post to usenet, you must
> limit the length of your lines.
>
> Here's a solution in Racket
Factor
> that accepts any number of inputs
> in a sequence.
>
> : g ( seq -- n ) [ <=> ] sort 2 tail* 0 [ sq + ] reduce ;
>
> { 0 9 1 8 7 6 5 4 3 2 } g .
>
> 145
: g ( seq -- n ) [ >=< ] sort first2 [ sq ] bi@ + ;
{ 0 9 1 8 7 6 5 4 3 2 } g .
145
[toc] | [prev] | [standalone]
Page 6 of 6 — ← Prev page 1 2 3 4 5 [6]
Back to top | Article view | comp.lang.forth
csiph-web