On Sat, Jun 11, 2022 at 09:53:39PM +0200, Ralf Hemmecke wrote:
> While implementing, I have a problem with
> 
> x: Stream Integer := [k for k in 1..29]
> st := x(2..-2 by -1);
> 
> The creation itself will succeed.
> Now what exactly should st be?
> 
> Naively, that would be a stream consisting of 5 elements
> 
>   st := [x(2), x(1), x(0), x(-1), x(-2)]              (*)
> 
> Clearly the only sensible stream that I can return is
> 
>   st2 := [x(2), x(1)]                                (**)

If you want schematic representation it would be:

[x(2), x(1), bomb]

Like in:

f_elt(i : Integer) : Integer == (i < 2 => i + 1; error "invalid access")
st := stream(f_elt, 1)@Stream(Integer);

After that:

(6) -> st2 := rest(rest(st));

                                                        Type: Stream(Integer)
(7) -> empty?(st2)

   Error signalled from user code in function f_elt:
      invalid access

This may look perverse.  However, it allows lazy evaluation,
and has nice property that if computation finishes without
error, then all values used in computation were in bound.

--
                              Waldek Hebisch

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/20220611204148.GB18522%40fricas.math.uni.wroc.pl.

Reply via email to