Liu Xiaojun wrote:
>
> Oh, this explanation is quite reasonable. What should we do if we want
> "explicitlyFinite?"
> returns right answer (true) in a function call ? Namely is there a way to
> make the "lazy"
> computation performed within a function call.
>
Well, if you _know_ that stream is finite (and reasonable short!)
you just use the function 'complete':
(16) -> res := [i for i in 1..1000];
Type: List(PositiveInteger)
(17) -> s1:Stream(INT) := res::Stream(INT);
Type: Stream(Integer)
(18) -> s2 := map(x +-> x, s1);
Type: Stream(Integer)
(19) -> explicitlyFinite? s2
(19) false
Type: Boolean
(20) -> s3 := complete(s2);
Type: Stream(Integer)
(21) -> explicitlyFinite? s3
(21) true
Type: Boolean
The tricky case if you do not know if stream is finite. On
infinte stream 'complete' will work long time and eventually
will run out of memory. As a compromise one could try
to evaluate stream element up to some limit (for example
in few places power series functions compute 1000 terms
and if all of them are zero, then they give up searching
for nonzero terms).
--
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.