I saw this in an old email from Martin Rubey in 2008,
titled "Bug in ALIST?":

(90) -> A := construct([[1, 10], [2, 20]]$List Record(key: INT, entry:
INT))$ALIST(INT, INT)

   (90) table(2= 20,1= 10)
                                       Type: AssociationList(Integer,Integer)
(91) -> map(x +-> x+1, A)

   (91) table(2= 21,1= 11)
                                       Type: AssociationList(Integer,Integer)
(92) -> A

   (92) table(2= 21,1= 11)
                                       Type: AssociationList(Integer,Integer)


That's because 'map' uses 'copy', but AssociationList
is a List of Records, so it only does "shallow" copy.

'copy' of Table works as intended.

Current 'copy' of AssociationList is implemented in LSAGG:

   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

I assume cyclic structure is not expected for AssociationList?
Then add this version to AssociationListAggregate is good enough:

   copy x ==
       y := empty()
       while not empty? x repeat
           y := concat(copy 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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to