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

Edit detail for #328 AXIOM interpreter cannot iterate over Stream revision 2 of 2

1 2
Editor: test1
Time: 2014/12/16 17:38:55 GMT+0
Note:

changed:
-L:=generate(s+->s+1,1.1)$Stream Float
L := stream(s+->s+1,1.1)$Stream Float

added:

The first loop is nonterminating (there is nothing to stop iteration),
so it is good that interpreter rejects it.  The problem is where to
draw line between nonterminationg loops and terminating ones.

Note that list comprehension produces a stream which is quite
different than the first loop (in particular, since streams are
lazy there a no extra problem with termination).


Submitted by : (unknown) at: 2007-11-17T22:27:06-08:00 (17 years ago)
Name :
Axiom Version :
Category : Severity : Status :
Optional subject :  
Optional comment :

fricas
L := stream(s+->s+1,1.1)$Stream Float

\label{eq1}\left[{1.1}, \:{2.1}, \:{3.1}, \:{4.1}, \:{5.1}, \:{6.1}, \:{7.1}, \:{8.1}, \:{9.1}, \:{10.1}, \:...\right](1)
Type: Stream(Float)
fricas
for i in L repeat
  output i+0.01
FriCAS cannot iterate with i over your form now. Perhaps you should try using a conversion to make sure your form is a list or stream, for example.

But of course L is a Stream and iteration within list comprehension works.

fricas
P:=[i+0.01 for i in L]

\label{eq2}\left[{1.11}, \:{2.11}, \:{3.11}, \:{4.11}, \:{5.11}, \:{6.11}, \:{7.11}, \:{8.11}, \:{9.11}, \:{10.11}, \:...\right](2)
Type: Stream(Float)

The first loop is nonterminating (there is nothing to stop iteration), so it is good that interpreter rejects it. The problem is where to draw line between nonterminationg loops and terminating ones.

Note that list comprehension produces a stream which is quite different than the first loop (in particular, since streams are lazy there a no extra problem with termination).