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


Groups > comp.lang.forth > #24649

Re: Fifteen puzzle

From Bernd Paysan <bernd.paysan@gmx.de>
Newsgroups comp.lang.forth
Subject Re: Fifteen puzzle
Date 2013-07-21 22:31 +0200
Organization 1&1 Internet AG
Message-ID <kshgfg$lvj$1@online.de> (permalink)
References <7xfvv84qjg.fsf@ruckus.brouhaha.com> <7xbo5wxxy5.fsf@ruckus.brouhaha.com> <0_Gdnb8MabyZDnbMnZ2dnUVZ8kSdnZ2d@supernews.com>

Show all headers | View raw


Andrew Haley wrote:

> Paul Rubin <no.email@nospam.invalid> wrote:
>> 
>> \ read hex digit from keyboard
>> : decimal? ( ch -- f ) '0 '9 1+ within ; \ check for decimal digit
>> : dconvert ( ch -- n ) dup decimal? if '0 - else drop -1 then ;
>> : hexletter? ( ch -- f ) 'a 'g within ; \ check for hex letter
>> : hconvert ( ch -- n ) dup hexletter? if 'a - 10 + else drop -1 then ;
>> : conv-digit ( ch -- n ) dup dconvert swap hconvert and ;
>> : keydigit ( -- n ) begin key conv-digit dup -1 = while repeat ;
> 
> Y'know, I don't think that I have ever said on c.l.f that a program is
> *over*factored.  But there is always a first time for everything.
> And this might just be it...

This is not just overfactored, this is not reusing the digit? code in the 
system!  DIGIT? is non-standard, though, but for what's it's worth, it is 
not factored.

: keydigit ( -- n )  hex  BEGIN  key digit?  UNTIL ;

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/

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


Thread

Fifteen puzzle Paul Rubin <no.email@nospam.invalid> - 2013-07-20 19:04 -0700
  Re: Fifteen puzzle Paul Rubin <no.email@nospam.invalid> - 2013-07-20 22:51 -0700
    Re: Fifteen puzzle Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-07-21 02:51 -0500
      Re: Fifteen puzzle Bernd Paysan <bernd.paysan@gmx.de> - 2013-07-21 22:31 +0200
        Re: Fifteen puzzle Paul Rubin <no.email@nospam.invalid> - 2013-07-21 15:46 -0700
        Re: Fifteen puzzle Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2013-07-22 11:01 +0100
          Re: Fifteen puzzle Paul Rubin <no.email@nospam.invalid> - 2013-07-22 10:31 -0700
            Re: Fifteen puzzle Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2013-07-22 21:02 +0100
      Re: Fifteen puzzle Paul Rubin <no.email@nospam.invalid> - 2013-07-21 23:59 -0700
        Re: Fifteen puzzle Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-07-22 03:51 -0500
    Re: Fifteen puzzle "WJ" <w_a_x_man@yahoo.com> - 2013-07-21 22:02 +0000
    Re: Fifteen puzzle m.a.m.hendrix@tue.nl - 2013-07-22 02:40 -0700
      Re: Fifteen puzzle anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-07-22 15:50 +0000
      Re: Fifteen puzzle Paul Rubin <no.email@nospam.invalid> - 2013-07-22 10:25 -0700
    Re: Fifteen puzzle albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-07-22 20:14 +0000
      Re: Fifteen puzzle Paul Rubin <no.email@nospam.invalid> - 2013-07-22 20:12 -0700

csiph-web