
22 Jan
2009
22 Jan
'09
2:07 a.m.
Ahn, Ki Yung 쓴 글:
reduce (Bs (x:xs)) | all (x==) xs = x reduce (Rep x@(Rep _)) = x reduce x = x
I already found a bug. The second equation of reduce "reduce (Rep x@(Rep _)) = x" is wrong because it flattens two dimensions into one. The reduce function should be:
reduce x = x reduce (Bs (x:xs)) | all (x==) xs = reduce x reduce (Bs xs) = Bs (map reduce xs) reduce (Rep O) = O reduce (Rep I) = I reduce (Rep x) = Rep (reduce x) reduce x = x
This is why I am looking for existing work, because I am not yet very sure about my code I'm using.