examples/FactorialI.tea
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sun, 27 Sep 2015 07:07:46 +0100
changeset 19 7597503194b8
permissions -rw-r--r--
First shot of libt and some examples libt serves (well, might serve at some point) as a basic library for Tea language. Added directory with examples demostration Tea (and libt) Both includes makefiles to compile libt and examples to compile them down to machine code. This also demonstrates how to use `teak`, a standalone Tea compiler.

nil subclass: #FactorialI
    category: 't-Examples'
!

!FactorialI class methodsFor:'examples'!
factorialI:v <tSIntegerW> <^ tSIntegerW>
    | result <tSIntegerW> 
      i <tSIntegerW> |

    result := 0.
    i := v.

    [ i > 1 ] whileTrue:[ 
        result := result * i.
        i := i - 1
    ].
    ^ result
! !