
Sample program
The following program is a simple example of FiPL. Copy and paste it into the Fish Underwater Programming Environment editor's window and see the results by yourself !
S3 is flip-flop of BLACK and WHITE;
S3W is incident when S3 becomes WHITE;
all the fish is haphazard;
FF is aftermath of S3W as follows [
S0 is flip-flop of like S1 and like S2;
S0W is incident when S0 becomes like S1;
S0B is incident when S0 becomes like S2;
S3 is BLACK;S10 is BLACK;
S20 is BLACK;
S30 is BLACK;
S40 is BLACK;
S50 is BLACK;S49 is BLACK + (0,0,250);
S42 is BLACK;CT1 is aftermath of S0W as follows [
S10 is like S10 + (10,0,0);
S20 is like S20 + (10,10,0);
S30 is like S30 + (0,10,0);
S40 is like S40 + (0,10,10);
S50 is like S50 + (0,0,10);
t2 is like S20;
t4 is like S40;
]
CT2 is aftermath of S0B as follows [
t1 is like S10;
t3 is like S30;
t5 is like S50;
]
TP is incident when S50 becomes like S49;
CC is aftermath of TP as follows [
S10 is BLACK;
S20 is BLACK;
S30 is BLACK;
S40 is BLACK;
S50 is BLACK;
S42 is like S42 + (0,0,10);
]
FINISH is incident when S42 becomes (0, 0, 20);
TFA is aftermath of FINISH as follows [
thanks for all the fish;
]
]
Deferred addressing
Since the language does not provide the construction S[Sx], the following can be used instead:
/* This part is the preparation for deferred addressing */
Inc1 is incident when somebody becomes (1,0,0);
Inc2 is incident when somebody becomes (2,0,0);
Inc3 is incident when somebody becomes (3,0,0);/* S0 will be the deferred addressing register */
/* This command will be performed on the deferred scale */
C is command as follows [
apprentice is RED; /* for example */
]s1 is apprentice of s0 doing C after Inc1;
s2 is apprentice of s0 doing C after Inc2;
s3 is apprentice of s0 doing C after Inc3;
Thus, the assignment S0 is (1,0,0) implies S1 is RED, which is equal to S[S0] is RED;
S0 is (2,0,0) -> S2 is RED
S0 is (3,0,0) -> S3 is RED
Multiple scale color addition
There is no possibility to find a sum of several given scales within one cycle, the following code can be used.
Here the result is accumulated in a dedicated scale cycle by cycle:
/* Items to find a sum of */
s1 is (0,0,10);
s2 is (0,0,20);
s3 is (0,0,30);
s4 is (0,0,40);/* Triggers fo the consequent loops */
Loop1 is incident when somebody becomes (1,0,0);
Loop2 is incident when somebody becomes (2,0,0);
Loop3 is incident when somebody becomes (3,0,0);
Loop4 is incident when somebody becomes (4,0,0);Sum is command as follows [
/* The result will be accumulated in S0 */
s0 is like s0 + like apprentice;
/* Trigger the next loop; S50 serves as a loop counter */
s50 is like s50 + (1,0,0);
]/* Each one of the input values will be processed on its own loop */
s1 is apprentice of s50 doing Sum after Loop1;
s2 is apprentice of s50 doing Sum after Loop2;
s3 is apprentice of s50 doing Sum after Loop3;
s4 is apprentice of s50 doing Sum after Loop4;/* Initialize the result */
S0 is (0,0,0);/* Kick-start the processing (invokes Inc1) */
s50 is (1,0,0);
The result will be in S0: (0,0,100)