login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Submitted by : (unknown) at: 2007-11-17T21:52:18-08:00 (16 years ago)
Name :
Axiom Version :
Category : Severity : Status :
Optional subject :  
Optional comment :

Section 5.6 An Example: [Streams]? of Primes

of the Axiom Book says: "This is how you use generate to generate an infinite stream of primes." In FriCAS, the function generate has been renamed to stream.

fricas
(1) -> primes := stream(nextPrime,2)

\label{eq1}\left[ 2, \: 3, \: 5, \: 7, \:{11}, \:{13}, \:{17}, \:{19}, \:{2
3}, \:{29}, \: \ldots \right](1)
Type: InfiniteTuple?(Integer)

but the result is an InfiniteTuple?, not a Stream. The domain InfiniteTuple? is not documented in the book.

To create a stream one must explicitly write:

fricas
primes := stream(nextPrime,2)$Stream Integer

\label{eq2}\left[ 2, \: 3, \: 5, \: 7, \:{11}, \:{13}, \:{17}, \:{19}, \:{2
3}, \:{29}, \: \ldots \right](2)
Type: Stream(Integer)

or

fricas
primes := construct stream(nextPrime,2)

\label{eq3}\left[ 2, \: 3, \: 5, \: 7, \:{11}, \:{13}, \:{17}, \:{19}, \:{2
3}, \:{29}, \: \ldots \right](3)
Type: Stream(Integer)

In ituple.spad, you can see that InfiniteTuple? is represented as Stream. And there is special treatment for InfiniteTuple? in interpreter code. Maybe InfiniteTuple? can be removed, to be investigated.




  Subject: (replying)   Be Bold !!
  ( 14 subscribers )  
Please rate this page: