|Jef Raskin's Programming Challenge
Can you create two words that can be executed on Windows (98 and up), Linux,
and Mac systems using whatever version of Forth that's handy for all three.
A word "PIXPUTTER": With X, Y, R, G, and B on the stack, put a
pixel at pixel location (X,Y) on the display using R,G, and B as eight-bit red,
green, and blue intensity values. Use upper left or lower left origin,
whichever is easier.
A word "KEYSDOWN" that when run puts a number (or set of
numbers) on the stack. When the result is thought of as a binary number, the 1s
show what keyboard keys were down and the 0s show what keys were up at the time
of execution. Assume that the keyboard has 127 or fewer keys. If the precision
of the system was, for example, 16 bits, then 7 numbers would be put on the
stack. If the precision was 128 bits, then one number would be put on the
stack. Each bit in the result corresponds to a particular keyboard key. Any
mapping from keys to position in the result is fine so long as it doesn't
change from run to run!
Sounds easy, no? Can anybody write them? If someone can, I will be happy to
give them kudos and put the code up on
my web site for the
world to read (and an explanation of why they are a very good thing).