The Hyper Programming Language |
home | language reference | compiler | hyper on launchpad |
This program prints a circle in text form on standard output.
Disclaimer: I haven't been able to actually compile and run this code yet, so if you find an error please let me know.
The program should print the following:
---------------------------------------- ---------------------------------------- ---------------------------------------- ------------------xxxxxx---------------- --------------xxxxxxxxxxxxxx------------ ----------xxxxxxxxxxxxxxxxxxxxxx-------- ----------xxxxxx----------xxxxxx-------- --------xxxxxx--------------xxxxxx------ --------xxxx------------------xxxx------ ------xxxxxx------------------xxxxxx---- ------xxxxxx------------------xxxxxx---- ------xxxxxx------------------xxxxxx---- --------xxxx------------------xxxx------ --------xxxxxx--------------xxxxxx------ ----------xxxxxx----------xxxxxx-------- ----------xxxxxxxxxxxxxxxxxxxxxx-------- --------------xxxxxxxxxxxxxx------------ ------------------xxxxxx---------------- ---------------------------------------- ----------------------------------------
import system.stdio static class C procedure main() # constants for the size of the output const rectSize : byte = 20 const r1Square : byte = 25 const r2Square : byte = 50 const halfRect : byte = rectSize / 2 iterate y : nat from 0 to --rectSize iterate x : nat from 0 to --rectSize var dstSquare : nat = _ (halfRect - x) * (halfRect - x) + (halfRect - y) * (halfRect - y) if (r1Square <= dstSquare <= r2Square) then system.Out.print("xx") else system.Out.print("--") end if end system.Out.line # print newline end system.Out.line # print newline end end
For information about the language, go to the language reference. The following links provide information about some things used in the example above: