Re: Computer One FORTH
Posted: Fri Sep 16, 2011 9:11 am
Last problem with roman numbers : they (to my knowledge) had no symbols for numbers larger than 1OOO ? so when you ask for roman notation of 32767 for instance, you get :
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMDCCLXVII
I decided thus to add Y for 5000 and Z for 10000 (and also MY for 4000 and MZ for 9000 of course) to the list of basic romans, so that 32767 would be displayed like this :
ZZZMMDCCLXVII
To do this, one just has to add just after word M :
4000 ROMAN MY
5000 ROMAN Y
9000 ROMAN MZ
10000 ROMAN Z
I did it, but (in a hurry) made the mistake not to modify anything else, and got exactly the same answers as before, because words ROMAN and .ROMAN still began the bucket brigade with M
This gave me this other idea : why not use the DEFER...IS construct to switch between PLAIN roman notation and LARGE roman notation ? To do this one only has to creste a DEFERed word, let it be W
DEFER W
and two words to set its execution :
: PLAIN ['] M IS W ;
: LARGE ['] Z IS W ;
and have the (second) definition of ROMAN and the definition of .ROMAN call W instead of M
then asking :
PLAIN 32767 .ROMAN
you get
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMDCCLXVII
but asking :
LARGE 32767 .ROMAN
you get
ZZZMMDCCLXVII
Just for fun, if you ask :
12 .ROMAN
you get indeed
XII
in both case, but if you first type :
' I IS W
you will get instead
IIIIIIIIIIII
because you have set the bucket brigade to begin with word I
BYE Paul
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMDCCLXVII
I decided thus to add Y for 5000 and Z for 10000 (and also MY for 4000 and MZ for 9000 of course) to the list of basic romans, so that 32767 would be displayed like this :
ZZZMMDCCLXVII
To do this, one just has to add just after word M :
4000 ROMAN MY
5000 ROMAN Y
9000 ROMAN MZ
10000 ROMAN Z
I did it, but (in a hurry) made the mistake not to modify anything else, and got exactly the same answers as before, because words ROMAN and .ROMAN still began the bucket brigade with M
This gave me this other idea : why not use the DEFER...IS construct to switch between PLAIN roman notation and LARGE roman notation ? To do this one only has to creste a DEFERed word, let it be W
DEFER W
and two words to set its execution :
: PLAIN ['] M IS W ;
: LARGE ['] Z IS W ;
and have the (second) definition of ROMAN and the definition of .ROMAN call W instead of M
then asking :
PLAIN 32767 .ROMAN
you get
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMDCCLXVII
but asking :
LARGE 32767 .ROMAN
you get
ZZZMMDCCLXVII
Just for fun, if you ask :
12 .ROMAN
you get indeed
XII
in both case, but if you first type :
' I IS W
you will get instead
IIIIIIIIIIII
because you have set the bucket brigade to begin with word I
BYE Paul