MIFFS Is Fun For Sums

by rich

The Basics

The normal operators are supported ( ^ % * / + - ). If you simply type in an expression MIFFS should evaluate it as you would expect:

3+(2*9)
val ans = 21 : int
ans + 1
val ans = 22 : int

To save a value for later use, write val followed by a name, then = and an expression. There are some pre-defined constants (such as pi), but if you define a variable with the same name you will just hide them.

val three = 4-1
val three = 3 : int
three
ans = 3 : int

If you want to use a function, type its name followed by the thing you want to apply it to. MIFFS has several built-in functions. Brackets are optional (except for negative arguments like sin(-2)):

cos pi
ans = -1.0 : real
cos (2*pi)
ans = 1.0 : real

If you want to define a function, write fun then a name and an argument list, then = and finally an expression that may contain the arguments you listed or the name of the function:

fun times(a,b) = a*b
val times = fn : α -> α
times(6,7)
ans = 42 : int
fun add a b = a + b
val add = fn : α -> α
val plusthree = add 3
val plusthree = fn : α -> α
(plusthree 4, plusthree 5)
ans = (7, 8) : int * int

As you can see, functions are values too. (note: this means they have the same namespace: If you define a value sin, you will not be able to access the built-in function sin.)

You can compare values with =, >, >=, <, <=. Some types cannot be compared, for example functions cannot be compared for equality (even with themselves) and lists cannot be compared for order (but may be tested for equality). You can use if - then - else, andalso or orelse statements to set up conditional expression:

if sin pi = 0 then 9 else 4
ans = 4 : int
if rint(random()) = 0 then true else false
ans = true : bool

This is the end of the basic introduction; you should be able to use MIFFS for anything MS Calc can do, and I hope you find this nicer to use. Have fun with sums!