| Slideshow ^ |< << Slide 1 of 1 >> >| |
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.
#pile
#include "axiom.as"
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