[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-developer] [Streams] Re: Clarifications

From: Bill Page
Subject: [Axiom-developer] [Streams] Re: Clarifications
Date: Wed, 22 Feb 2006 19:58:59 -0600

unknown wrote:

> It seems that the example:
>  [p for p in smallPrimes for i in 1..11]
> depends on multiple for clauses being interpreted in parallel
> instead of all their combinations.

Yes, that is correct. The index 'i' is present for no other
purpose then to ensure exactly 11 elements are generated. It
is not directly evident in the generated output, but the
resulting stream does have only 11 elements. We can see this
by asking Axiom to count them:
# entries %%(5)

'%%(5)' refers to the result from calculation (5).

> What does this syntax mean:
>  thesePrimes:=entries complete %

'%' refers to the immediately previous result.
'complete' means to compute all the members of the stream
(only possible if the stream in finite).
'entries' means to convert the stream to a list.

So this command means to assign to the variable 'thesePrimes'
the list consisting of all the members of the stream in
the previous result.

> Does the conversion depend on the while p < 1200 used
> above instead of | p < 1200?

There is no "conversion" going on here, as such. It is just
the evaluation of streams. No, this evaluation does not require
the 'while' syntax. In this example the 'while' clause and the
| notation (which is read: such that) are equivalent. But in
more general situations however there may a difference. The
failure of the 'while' condition causes the list to terminate
but the failure of the | condition simply skips that entry.
forwarded from

reply via email to

[Prev in Thread] Current Thread [Next in Thread]