PreviousUpNext

5.2.5  Arithmetic

Mythryl arithmetic operations are written much as in C.

The most notable difference is that Mythryl is more sensitive to the presence or absence of white space. For example a-b and a -b are the same in C, but in Mythryl the former dash designates subtraction and the latter dash unary negation:

    #!/usr/bin/mythryl
    a = 10;
    b = 3;
    printf "%d\n" (a-b);
    printf "%d %d\n" a -b;
    printf "*  %d\n" (a*b);
    printf "/  %d\n" (a/b);
    printf "+  %d\n" (a+b);
    printf "|  %d\n" (a|b);
    printf "^  %d\n" (a^b);

When run this produces

    linux$ ./my-script
    7
    10 -3
    *  30
    /  3
    +  13
    |  11
    ^  9
    linux$

(The last two are respectively inclusive-or and exclusive-or, taken from C; if you are not familiar with them, don’t worry about them.)


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext