aboutsummaryrefslogtreecommitdiff
path: root/src/input/fns.input.pamphlet
blob: b183a586061512a0cd77e62ee623749f361f2944 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
\documentclass{article}
\usepackage{axiom}
\begin{document}
\title{\$SPAD/src/input fns.input}
\author{The Axiom Team}
\maketitle
\begin{abstract}
\end{abstract}
\eject
\tableofcontents
\eject
<<*>>=

-- Input for page ExampleFunctions
)clear all

odd(i) == 2*i - 1
[odd(i) for i in 1..10]
odd == i +-> 2*i - 1
odd(1111)
[i for i in 2.. | prime? i]
primes := /
primes == [p := nextPrime(i = 0 => 2; p) for i in 1..]
primes
primes(20)
firstPrimes(n) == [primes(i) for i in 1..n]
firstPrimes(25)
primesLessThan(n) == [p for p in primes while p < n]
primesLessThan 1000
isPrime? n == reduce(or,[n = p for p in primes while n <= p])
isPrime?(1111)
twins := [p,p+2 for p in primes | prime?(p+2)]
twins := [p, p+2 for i in 1.. | (p := primes(i)) + 2 = primes(i+1)]
firsts := [p for i in 1.. | (p := primes(i)) + 2 = primes(i+1)]
twins := [p, p + 2 for p in firsts]
twins(i) ==firsts(i),2 + firsts(i)
@
\eject
\begin{thebibliography}{99}
\bibitem{1} nothing
\end{thebibliography}
\end{document}