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


Groups > comp.lang.forth > #47378

Re: How could have I factored this better?

From Darin Murphy <murphy.darin@gmail.com>
Newsgroups comp.lang.forth
Subject Re: How could have I factored this better?
Date 2016-05-20 21:33 -0400
Organization news.aioe.org
Message-ID <nhodt9$1cko$1@gioia.aioe.org> (permalink)
References <5e60dbda-f34b-4be0-bfac-d32ddc67062f@googlegroups.com> <nhnr8n$oqg$1@dont-email.me>

Show all headers | View raw


rickman <gnuarm@gmail.com> Wrote in message:
> On 5/20/2016 4:09 PM, Darin Murphy wrote:
>> Hi everybody. I created the following program and would like to know how I could have factored and documented it better.
>>
>> : star  ( n -- ) 42 emit ;
>> : not-positive-integer   ." ERROR - Value not a positive integer!" ;
>> : positive-integer?  ( n -- error or n ) dup 1 < if not-positive-integer drop then ;
>> : stars  ( n -- ) positive-integer? begin dup 0 > while 1 - star repeat drop ;
>> : solid-box-stars   ( column row -- ) positive-integer? cr begin dup 0 > while >r dup stars r> 1 - cr repeat drop drop ;
>>
>> Examples, suggestions and advice are welcomed as always. Take care now.
> 
> I don't know about factoring, but positive-integer? either returns the 
> value given, or returns nothing.  The latter will cause an error in 
> stars won't it?  You neeed to use abort rather than drop or otherwise 
> change the control flow.
> 
> -- 
> 
> Rick C
> 

Thanks Rick! Sorry I didn't see your message before Mrs. Rather's.
 I'll look into using "abort" again.

Take care now,
-- 
Darin Murphy


----Android NewsGroup Reader----
http://usenet.sinaapp.com/

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


Thread

How could have I factored this better? Darin Murphy <murphy.darin@gmail.com> - 2016-05-20 13:09 -0700
  Re: How could have I factored this better? rickman <gnuarm@gmail.com> - 2016-05-20 16:18 -0400
    Re: How could have I factored this better? "Elizabeth D. Rather" <erather@forth.com> - 2016-05-20 10:25 -1000
      Re: How could have I factored this better? Darin Murphy <murphy.darin@gmail.com> - 2016-05-20 13:39 -0700
    Re: How could have I factored this better? Darin Murphy <murphy.darin@gmail.com> - 2016-05-20 21:33 -0400
  Re: How could have I factored this better? "Elizabeth D. Rather" <erather@forth.com> - 2016-05-20 10:23 -1000
  Re: How could have I factored this better? Paul Rubin <no.email@nospam.invalid> - 2016-05-20 15:44 -0700
    Re: How could have I factored this better? "Elizabeth D. Rather" <erather@forth.com> - 2016-05-20 14:38 -1000
      Re: How could have I factored this better? Paul Rubin <no.email@nospam.invalid> - 2016-05-20 17:49 -0700
        Re: How could have I factored this better? "Elizabeth D. Rather" <erather@forth.com> - 2016-05-20 14:57 -1000
          Re: How could have I factored this better? Paul Rubin <no.email@nospam.invalid> - 2016-05-20 18:34 -0700
            Re: How could have I factored this better? "Elizabeth D. Rather" <erather@forth.com> - 2016-05-20 16:00 -1000
              Re: How could have I factored this better? Paul Rubin <no.email@nospam.invalid> - 2016-05-20 20:08 -0700
                Re: How could have I factored this better? "Elizabeth D. Rather" <erather@forth.com> - 2016-05-20 17:24 -1000
                Re: How could have I factored this better? hughaguilar96@gmail.com - 2016-05-21 18:15 -0700
            Re: How could have I factored this better? Albert van der Horst <albert@cherry.spenarnc.xs4all.nl> - 2016-05-21 10:01 +0000
          Re: How could have I factored this better? Darin Murphy <murphy.darin@gmail.com> - 2016-05-20 22:15 -0400
            Re: How could have I factored this better? "Elizabeth D. Rather" <erather@forth.com> - 2016-05-20 16:46 -1000
            Re: How could have I factored this better? hughaguilar96@gmail.com - 2016-05-21 18:36 -0700
              Re: How could have I factored this better? Darin Murphy <murphy.darin@gmail.com> - 2016-05-21 22:51 -0400
                Re: How could have I factored this better? hughaguilar96@gmail.com - 2016-05-21 22:23 -0700
      Re: How could have I factored this better? Darin Murphy <murphy.darin@gmail.com> - 2016-05-20 22:43 -0400
    Re: How could have I factored this better? Darin Murphy <murphy.darin@gmail.com> - 2016-05-20 22:19 -0400
  Re: How could have I factored this better? "WJ" <w_a_x_man@yahoo.com> - 2016-05-21 22:02 +0000
    Re: How could have I factored this better? Darin Murphy <murphy.darin@gmail.com> - 2016-05-21 22:30 -0400
      Re: How could have I factored this better? humptydumpty <ouatubi@gmail.com> - 2016-05-21 19:40 -0700
  Re: How could have I factored this better? humptydumpty <ouatubi@gmail.com> - 2016-05-21 19:38 -0700
    Re: How could have I factored this better? Darin Murphy <murphy.darin@gmail.com> - 2016-05-21 23:06 -0400
      Re: How could have I factored this better? Paul Rubin <no.email@nospam.invalid> - 2016-05-21 20:59 -0700
        Re: How could have I factored this better? Darin Murphy <murphy.darin@gmail.com> - 2016-05-22 03:30 -0400
          Re: How could have I factored this better? "Elizabeth D. Rather" <erather@forth.com> - 2016-05-21 23:14 -1000
  Re: How could have I factored this better? humptydumpty <ouatubi@gmail.com> - 2016-05-27 03:54 -0700

csiph-web