Ralf Hemmecke wrote:
>
> > This is difference between Spad compiler and interpreter: Spad
> > compiler can only produce List here (that is why Ralf got error
> > when he tried to say that he wants stream). Since the iteration
> > is infinite the list overflows memory.
>
> Ahm....
> Waldek, are you saying that the construction
>
> [x for y in open-or-closed-segment]
>
> will always produce a list? Thank you for pointing this out.
>
> I know why I like Generator and bracket:Generator(X)-> %.
>
> Unfortunately, the construct
>
> x for y in open-or-closed-segment
>
> has no type in SPAD.
>
x for y in open-or-closed-segment is not a single construct.
for y in open-or-closed-segment is an iterator and can only
be used in two contexts:
repeat loop, like:
for y in open-or-closed-segment repeat
value constructor, like:
[x for y in open-or-closed-segment]
You can qualify the value, for example:
[x for x in 1..10]@Vector(Integer)
or
[x for x in 1..10]@PrimitiveArray(Integer)
but this essentially exhausts all variants available in Spad
compiler. In Spad, without @ you always get list.
Internally, when parser sees:
[x for y in open-or-closed-segment]
it will turn it into (COLLECT ...) and the COLLECT form,
x, y, and the open-or-closed-segment each get type.
--
Waldek Hebisch
[email protected]
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en.