Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #20502

Re: structure and interpretation of computer programs exercsie 1.3 in forth

From "WJ" <w_a_x_man@yahoo.com>
Newsgroups comp.lang.forth
Subject Re: structure and interpretation of computer programs exercsie 1.3 in forth
Date 2013-03-09 21:04 +0000
Organization A noiseless patient Spider
Message-ID <khg84v$v56$1@dont-email.me> (permalink)
References <f656a1dc-e406-4993-94a9-e9ff02da6a4d@googlegroups.com> <kgntle02jta@enews6.newsguy.com>

Show all headers | View raw


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

Back to comp.lang.forth | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

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

csiph-web