Source: prost.pl.

Here, "stream" is used in the sense of "sequence", "delayed list", "lazy list" etc. as in

The file contains the following examples of infinite streams (sequences):

- Stream of 1s
?- ones(Os), seq_take(7, Os, Ts). Ts = [1, 1, 1, 1, 1, 1, 1]

- List patterns (as in Haskell: [1,3..])
?- lp(-5, 2, Ls), seq_take(10, Ls, Ts). Ts = [-5, 2, 9, 16, 23, 30, 37, 44, 51, 58]

- Sequence of primes
?- primes(Ps), seq_take(15, Ps, Ts). Ts = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]

- Fibonacci sequence
?- fibs(Fs), seq_take(12, Fs, Ts). Ts = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]

- Harmonic sequence (using SWI Prolog rational arithmetic)
?- harms(Hs), seq_take(6, Hs, Ts). Ts = [1, 1 rdiv 2, 1 rdiv 3, 1 rdiv 4, 1 rdiv 5, 1 rdiv 6]

A program making use of the sequence of primes is here. It finds Meertens numbers, i.e., natural numbers N such that N is its own Gödel number (see source for details).

?- time(meertens(M)). % 1,307,951,016 inferences, 1509.23 CPU in 1538.53 seconds (98% CPU, 866635 Lips) M = 81312000

Main page