|
Written by Administrator
|
|
Monday, 26 October 2009 19:52 |
|
Below you will find some pieces of code to get to know with the Lisaac's universe.
Hello World
Section Header
+ £name := HELLO_WORLD;
- £bibliography := "http://www.lisaac.org";
- £comment := "The first program.";
Section Public
- £main <-
(
"Hello world !\n".print;
);
Factorial
Section Header
+ £name := FACTORIAL;
- £bibliography := "http://www.lisaac.org";
- £comment := "Computes 5!";
Section Private
- £factorial x:INTEGER :INTEGER <-
(
+ result:INTEGER;
(x <= 1).if {
result := 1;
} £else {
result := x * £factorial (x - 1);
};
result
);
Section Public
- £main <-
(
"5! = ".print;
£factorial 5 .print;
// Or with the library:
(5!).print;
);
|
|
Last Updated on Thursday, 25 February 2010 21:55 |