Open-Notes.net - a free, fast, convenient way to store notes online!
Select your style    Blue Style     Black Style    
[CNW:Counter]

DEPRECATED. THIS IS NO LONGER AVAILABLE IN HC 3.0 AND LATER. USE THE if(), while() and for() functions instead.

HC's simple programming language

From version 1.0, HC includes a simple programming language with a syntax similar to C, which can be used for teaching basics of programming or writing simple calculations.

Supported logic operations

As of version 1.0, HC supports the following logic operators:
& / && and, returns 1 if both of its arguments are not false
| / || or, returns 1 if one of its arguments is not false
! logical NOT, returns 1 if its argument is false, 0 otherwise
== equals, returns 1 if its arguments are equal
!=not equals, returns 1 if its arguments are not equal
>larger than
<smaller than
>=larger or equal than
<=smaller or equal than
For and and or, both a single &/| and the C-style doubled &&/|| orthographs are supported.

Supported structures

From HC version 3.0, control structures behave simply like any other function. The available structures are if(), for() and while(). To get more information, simply run help("if"), help("for") or help("while") in the HC prompt, or see below for examples of usage.

Examples

P1

Solving Project Euler's first problem with HC:
s = 0
for(j=0, j<1000, j+=1, if(j%3 == 0 | j%5 == 0, s+=j))
print(s)
(result of this program and the solution of the problem as it was on 5.3.2010 should be 233168 )

P2

Solving Project Euler's second problem with HC:
s = 0
x = 0
j = 1
while(x <= 4000000,
                     x = fibo(j);
                     if(x%2 == 0, s+=x);
                     j+=1;
                     )
print(s)
(result of this program and the solution of the problem as it was on 5.3.2010 should be 4613732 )


Back to documentation index


Creative Commons License
This work by Jan Dlabal is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.