$SPAD/src/input tbagg.input

Timothy Daly December 3, 2016

Abstract

Equality testing was broken in TableAggregate (TBAGG)

Contents

The equality function int TableAggregate used to read:

     s:% = t:% ==
       eq?(s,t) => true
       #s ^= #t => false
       for k in keys s repeat
 (e := search(k, t)) case "failed" or (e::Entry) ^= s.k => false
       true

but this always returns true. Using the “=>” operator in a loop just causes the loop to move to the next iteration. Thus the loop will not take an early exit from the function and the code will always fall thru to the “true” case. This is fixed by calling the return function.

     s:% = t:% ==
       eq?(s,t) => true
       #s ^= #t => false
       for k in keys s repeat
 (e := search(k, t)) case "failed" or (e::Entry) ^= s.k => return false
       true

— * —

)set break resume
)spool tbagg.output
)set message test on
)set message auto off
)clear all
--S 1 of 7
R ==> Record(key: Symbol, entry: String)
--R                                                                   Type: Void
--E 1
--S 2 of 7
T ==> AssociationList(Symbol, String)
--R                                                                   Type: Void
--E 2
--S 3 of 7
t1:=construct([[x,"ix"]$R])$T
--R
--R   (3)  table(x= "ix")
--R                                         Type: AssociationList(Symbol,String)
--E 3
--S 4 of 7
t2:=construct([[y,"iy"]$R])$T
--R

--R   (4)  table(y= "iy")
--R                                         Type: AssociationList(Symbol,String)
--E 4
--S 5 of 7
(t1=t2)::Boolean
--R
--R   (5)  false
--R                                                                Type: Boolean
--E 5
--S 6 of 7
t3:=construct([[y,"iy"]$R])$T
--R
--R   (6)  table(y= "iy")
--R                                         Type: AssociationList(Symbol,String)
--E 6
--S 7 of 7
(t3=t2)::Boolean
--R
--R   (7)  true
--R                                                                Type: Boolean
--E 7
)spool
)lisp (bye)

———-

References^{[1] nothing}

4