On Sat, May 28, 2022 at 11:45:26PM +0200, Ralf Hemmecke wrote:
> Does anyone know why the original developers did not allow to copy a cyclic
> list?
> 
> I guess, one could implement a copy that is again a cyclic list.
> 
> And there seems to be a misbehaviour. If I construct l2 in the same way as I
> construct l below, then
> 
>   (l=l2)@Boolean
> 
> runs forever. Since a list is a finite datastructure (i.e. finitely many
> list cells) we should be able to recognize equality. We just need to figure
> out where the cycle begins. Am I wrong?
> 
> Ralf
> 
> (41) -> l := [1,2,3]
> 
>    (41)  [1, 2, 3]
>                                Type: List(PositiveInteger)
> (42) -> setrest!(rest(l,2), l)
> 
>           _______
>    (42)  [1, 2, 3]
>                                Type: List(PositiveInteger)
> (43) -> copy l
> 
>    >> Error detected within library code:
>    cyclic list
> 
>    copy x ==
>        y := empty()
>        for k in 0.. while not empty? x repeat
>            k = cycleMax and cyclic? x => error "cyclic list"
>            y := concat(first x, y)
>            x := rest x
>        reverse! y
> 

AFAICS there are pragmatic decisions based on execution time and                
expected use cases.  Years ago we had similar disscussion about                 
'length'.

-- 
                              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/20220528225744.GB12879%40fricas.math.uni.wroc.pl.

Reply via email to