SURVO MM Help System (web edition)

Arithmetics and other internal operations in the tutstack:

Simple arithmetics can be performed with the words W1,W2,... in the
tutstack. Permitted calculations are

  {W3=W1}     W3 is a copy of the word in W1
  {W3=W1+W2}  W3 will be the sum of W1 and W2
  {W3=W1-W2}{W3=W1*W2} similarly for subtraction and multiplication
  {W3=W1/W2}  W3 is the ratio of W1 and W2
  {W3=W1%W2}  W3 is the remainder in the division when W1 and W2 are integers

W1 and W2 above can be replaced by constants. Example: {W1=W1+1}
Also {W1=<any string>} is permitted. The string must not include
characters +-*/%&{}@ . Examples:  {W1=0} {W5=SURVO 84C}

Two words, say W1 and W2,  can be concatenated to W3 by {W3=W1&W2}
Example: {W1=SURVO}{W2= 84C}{W3=W1&W2} gives W3=SURVO 84C .

Example: Sucro PRIMES writes all the primes.

10 *
11 *TUTSAVE PRIMES
12 / def Wnumber=W1 Wfactor=W2 Wremainder=W3 Wsquare=W4
13 *{tempo 1}{R}
14 *SCRATCH {act}{home}2 3{Wnumber=1}
15 + A: {Wnumber=Wnumber+2}{Wfactor=1}
16 + B: {Wfactor=Wfactor+2}{Wremainder=Wnumber%Wfactor}
17 - if Wremainder = 0 then goto A
18 *{Wsquare=Wfactor*Wfactor}
19 - if Wsquare < Wnumber then goto B
20 * {write Wnumber}{goto A}{end}
21 *
22 */PRIMES
23 *2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
24 *101 103 107 109 113 127 131 137 139 149 etc.
25 *

S = More information on sucro codes and statements 


More information on Survo from www.survo.fi
Copyright © Survo Systems 2001-2012.
webmaster'at'survo.fi