Re: [open-axiom-devel] [fricas-devel] Re: [fricas-devel] Re: [fricas-devel] Re: [fricas-devel] Re: [fricas-devel] Re: iterators and cartesian product.

Ralf Hemmecke <[email protected]> Sat, 27 Oct 2007 20:22:18 +0200
Newsgroups gmane.comp.mathematics.axiom.general
Message-ID <[email protected]>
On 10/25/2007 06:40 PM, Bill Page wrote:
> On 10/24/07, Ralf Hemmecke wrote:
>> ...
>> I cannot live anymore without "Generator". And I very much hope it will
>> make it into SPAD.

>>> Contrast this with 'Stream' in
>>> Axiom which (so far as I understand) does not require such an
>>> extension of Spad.
>> For me a stream is like a generator with memory.

> It is not my intention to sound critical but I would like to
> understand better this distinction. If Stream is a generalization of
> Generator, why do we need Generator?

Let me cite the documentation from stream.spad.pamphlet

++ A stream is an implementation of an infinite sequence using
++ a list of terms that have been computed and a function closure
++ to compute additional terms when needed.

First, a stream is an infinite sequence. If we get

(6) -> s:=construct([1,2,3])$Stream(Integer)
(6) ->
    (6)  [1,2,3]
                                                          Type: Stream 
Integer
(7) -> s.4
  7) ->
    >> Error detected within library code:
    elt: no such element

Then there is either something wrong with the code or with the 
documentation.

Second, according to the documentation a Stream is a pair (A,B) where A 
is a list of precomputed functions and B is a function that computes the 
next value.

If you would like to know the difference between Stream and Generator, 
then think of a Generator as the B part above.

In fact, in aldor-combinat, I have implemented a "DataStream" which has 
representation:
         Rep == Record(
	    gen: Generator T,
	    cache: PrimitiveArray T,
	    size: I,
	    numberOfElements: I,
	    constant?: Boolean
	);

In more simpler terms, my A is Array and my B is Generator. Does that help?

> The larger question remains however: When to use a domain to directly
> model something that is "set-like" and when to define a higher-order
> domain whose objects are "set-like"? To me this is not clear in either
> Spad or Aldor.

I don't think you gain very much if you only consider set-like domains. 
If, however, you are looking at finite fields, for sure, you will think 
of a domain, since it is more important that there are some operations 
that connect the elements.

Ralf