I Current work in Baha'i philosophy.
II Software in Icon to help calculate the astrologic readings.
III Software in Icon to help in the translation to and from Glosa.
IV This is the source code for Lile, a Linux Icon list evaluator ( see below for the Windows version ). It evaluates Icon expressions that are entered in an Icon list, and you can use curly brackets and parenthesis in the usual fashion, or declare your own procedures. The user declared procedures can be used in subsequent expressions and procedures, and can be saved to a file. Enter 'ile ?' or 'ile help' for help.
V This is the source code and executable program for Wile, a Windows Icon list evaluator.
INTRODUCTION TO THE ICON COMPUTER LANGUAGE
A procedure in Icon is made from other procedures that are already built into the compiler, or in other words from procedures that constitute the Icon language. In order to distinguish them we will call the latter functions, not procedures, and besides these, Icon programs contain values by which values that are passed to the program are processed. Functions and procedures can either succeed or fail, and they can succeed on account of two types of values: the null value and the non-null values. Procedures always have the form x(), where x is the name of the procedure, and the parenthesis is where the values that are passed to the procedure go. As it is, x() calls the procedure without any values, but if the procedure as created by the programmer is expecting values, it will assign the null value to them. For example addthree( x ) could be a procedure that adds three to x. We could write it in Icon like this:
procedure addthree( x )
return x + 3
end
In another part of the program, we could call this procedure like this:
addthree( 7 )
and the result of it would be 10, and could be used directly where the value was returned, like this:
if addthree( 7 ) = 10 then write( "succeeded" ) else write( "failed" )
The '=' function succeeded, and so the then part of the if function was interpreted, causing the word 'succeeded' to appear on the screen. But if we called addthree( x ) like this:
if addthree() = 10 then write( "succeeded" ) else write( "failed" )
then the program would end with an error notice, because the function in the addthree( x ) procedure tries to add 3 to the null value. If we omitted the 'return' function, addthree( x ) would fail, because a value, be it null or otherwise, must be returned in order for the procedure to succeed. Then the else part of the if function would be interpreted, because failure of addthree( x ) causes the failure of the '=' function. But it is important to remember that the '=' function could have failed because a wrong value was provided. In this case, Icon checks to see if the function or procedure that provided the value is of a special type called a generator, in which case it is called again to produce newer results that might cause '=' to succeed. To continue with our previous example, this is how the procedure could be made into a generator:
procedure addthree( x )
while x < 8 do {
suspend x + 3
x +:= 1 }
end
If x is greater than 7, then the suspend function, which returns the value, is not even called because in our example anything over 7 would not be equal to 10 if 3 were added to it anyways. If the '=' function fails because of the value returned by the suspend function, then the program returns to continue where the suspend was called. A 1 gets added to x in the next line, and the 'while' function causes the whole process to repeat itself. If for example we called addthree( x ) with a value of 2, the addthree( x ) procedure would be called a total of six times before '=' succeeded.