
-- 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)
