morilib Logo


  • Back


    Fundermental

    The morilib LOGO is an implementation of LOGO interpreter runs on JavaScript.
    The types of morilib logo are numbers and words.(Lists and arrays are not supported.)


    Commands

    if expr [command...]
    executes the commands if expr is true, otherwise do nothing.

    repeat expr [command...]
    repeats the commands expr times.

    "word
    quotes the text string.

    :symbol
    refers the value which is bounded by symbol.

    forword distance
    fd distance
    forword the turtle distance pixels.

    backword distance
    back distance
    bk distance
    backword the turtle distance pixels.

    left angle
    lt angle
    rotate angle degrees counterclockwise.

    right angle
    rt angle
    rotate angle degrees clockwise.

    left angle
    lt angle
    rotate angle degrees counterclockwise.

    clearscreen
    cs
    clear the screen and the turtle is set to home position.

    penup
    pu
    The turtle do not draw a line when the turtle moves.

    pendown
    pd
    The turtle draw a line when the turtle moves.

    hideturtle
    ht
    hides the turtle.

    showturtle
    st
    shows the turtle.

    home
    moves the turtle to home position.

    label thing
    draws the thing to position of the turtle.

    make word thing
    binds thing to word

    sum val1 val2
    Compute val1 + val2.

    difference val1 val2
    Compute val1 - val2.

    product val1 val2
    Compute val1 * val2.

    quotient val1 val2
    Compute val1 / val2.

    modulo val1 val2
    Compute val1 % val2.

    power val1 val2
    Compute val1 to the val2.

    and val1 val2
    returns 1 if both of val1 and val2 is not 0, otherwise 0.

    or val1 val2
    returns 1 if one of val1 and val2 is not 0, otherwise 0.

    not val1
    returns 1 if val1 is 0, otherwise 0.

    word? thing
    returns 1 if thing is a word, otherwise 0.

    number? thing
    returns 1 if thing is a number, otherwise 0.

    equal? thing1 thing2
    returns 1 if thing1 is equal to thing2, otherwise 0.

    notequal? thing1 thing2
    returns 1 if thing1 is not equal to thing2, otherwise 0.

    greater? thing1 thing2
    greaterequal? thing1 thing2
    less? thing1 thing2
    lessequal? thing1 thing2
    returns 1 if thing1 and thing2 satisfies the relation, otherwise 0.

    window
    fence
    do nothing, these commands are reserved.

    to procname :argument... command... end
    defines the procedure named procname.
    The body of the procedure is given by command..., and the arguments are given :argument. The arguments are optional.

    procname argument...
    calls the procedure procname


    Expressions

    Infix operators are available in the morilib LOGO. The expressions shown as follows.
    - High priority -
    operatoe association description
    ^ right to left power
    (unary)- left to right negate the sign
    * / left to right multipication, division
    + - left to right addition, subtraction
    = <> < <= > >= left to right 1 if the relation is true, otherwise 0