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

--
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/da9449f4-5dcc-212a-4ddc-7ed6455ee767%40hemmecke.org.

Reply via email to