Three simple programs in STML

All STML programs take their input from standard input and write to standard output (either of these can be redirected, of course). The input must be one integer value to a line. The output is produced as one integer value in decimal to a line.

Note: Doing the assignment does NOT require that you spend ANY time working through these STML programs to figure out how they work. Neither the original and the extended STM interpreter cares what the STML code actually does; they just interpret it. This STML code is only significant as providing test examples.

(1) Digits of a Fraction: fraction.stm

This program computes the digits in a fraction. For example, suppose you want to compute the decimal expansion of the fraction 1/7 in base 10. Since we have
	1/7 = .1428571428...
	
we want the program to output the sequence 1, 4, 2, 8, 5, etc. But you can also ask for the output for a base that is different from 10. E.g., in base 2, we have 1/7=.0010010010...
The input for the program is four numbers: N, the numerator; D, the denominator; B, the base; and K, the number of output digits. The output is the first K digits of N/D in base B. For example,
        % stm.exe fraction.stm
        1 7 10 8
produces the output
        1
        4
        2
        8
        5
        7
        1
        4
	

(2) Insertion Sort: sort.stm

The STM program "sort.stm" sorts a column of numbers using insertion sort. The input is given one number to a line, and terminated with the flag -1 The output echoes the number in sorted order. For example:
        % stm.exe sort.stm
        31 4 15 92 65 35 -1
produces the output
        4
        15
        31
        35
        65
        92 

(3) List of Primes: primes.stm

The STM program "primes.stm" generates a list of the prime numbers that are less than an input integer N. For example:
        % stm.exe primes.stm
        13
produces the output
        2
        3
        5
        7
        11