|
Size: 1162
Comment:
|
Size: 1166
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 25: | Line 25: |
| }}}} | } }}} |
Introduction to the Axiom Library compiler for Python Programmers
SPAD is the 1st generation compiler and Aldor (http://wiki.axiom-developer.org/Aldor) is the 2nd generation compiler for the strongly-typed object-oriented high-level language which is used to implement Axiom's library of over 1,300 mathematical domains and categories. The language is similar in many respects to Python which plays the same role in Sage.
Example 1: A prime number sieve to count primes <= n.
import from Boolean, Integer, NonNegativeInteger;
sieve(n: Integer): Integer == {
isprime: OneDimensionalArray Boolean := new(n::NonNegativeInteger, true);
np:Integer := 0;
for p in 2..n | isprime p repeat {
np := np + 1;
for i in (p+p)..n by p repeat isprime i := false;
}
np
}