Currently, construct$AssociationList is implemented
in DictionaryOperations, which forbids duplicated key.
And =$AssociationList is implemented in TableAggregate,
which also ignores duplicated keys.  I fixed that.

Patch is here:

https://github.com/oldk1331/fricas/commit/774357675049bb310748fbdf632cb5c34e059e9f.patch

Hmm, change the 'Record(key:Key,entry:Entry)' into 'Rec'
may be better.  (I forget to do so in the patch.)

All tests passed:

https://travis-ci.org/oldk1331/fricas/builds/223504075

diff --git a/src/algebra/aggcat.spad b/src/algebra/aggcat.spad
index 85f0c23..e174aed 100644
--- a/src/algebra/aggcat.spad
+++ b/src/algebra/aggcat.spad
@@ -2407,6 +2407,17 @@
                 l := [(r.key)::O = (r.entry)::O for r in parts(u)@List Rec]
                 prefix(message("table")$O, l)

+        if Entry has BasicType then
+            x = y ==
+                eq?(x, y) => true
+                while not empty? x and not empty? y repeat
+                    fx : Record(key:Key,entry:Entry) := first x
+                    fy : Record(key:Key,entry:Entry) := first y
+                    fx.key ~= fy.key or fx.entry ~= fy.entry  => return false
+                    x := rest x
+                    y := rest y
+                empty? x and empty? y
+
 )abbrev category SRAGG StringAggregate
 ++ Author: Stephen Watt and Michael Monagan. revised by Manuel
Bronstein and Richard Jenks
 ++ Date Created: August 87 through August 88
diff --git a/src/algebra/list.spad b/src/algebra/list.spad
index faa25a6..b608a62 100644
--- a/src/algebra/list.spad
+++ b/src/algebra/list.spad
@@ -502,6 +502,7 @@

         import from List Pair

+        construct l == ref l
         dictionary()            == ref empty()
         empty()                 == dictionary()
         empty? t                == empty? deref t
diff --git a/src/input/bugs2017.input b/src/input/bugs2017.input
index b82eac4..1044ced 100644
--- a/src/input/bugs2017.input
+++ b/src/input/bugs2017.input
@@ -119,5 +119,16 @@

 testTrue("not(node?([],[])$List(Integer))")

+testcase "construct and = from AssociationList"
+
+T ==> AssociationList(String, Integer)
+R ==> Record(key : String, entry : Integer)
+
+t1 : T := construct [["1", 1]::R, ["1", 1]::R]
+t2 : T := construct [["1", 1]::R, ["1", 2]::R]
+
+testEquals("#t1", "2")
+testTrue("t1 ~= t2")
+
 )set output algebra on
 statistics()

-- 
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