1
1
mirror of https://github.com/github/semantic.git synced 2024-11-29 11:02:26 +03:00

Merge pull request #83 from github/recur-into-keyed-terms-with-equal-keys

Recur into Keyed terms with equal keys
This commit is contained in:
Josh Vera 2015-10-13 13:16:56 -04:00
commit bd4f1e7fc1

View File

@ -93,6 +93,9 @@ public enum Algorithm<A, B> {
case let (.Indexed(a), .Indexed(b)) where a.count == b.count:
return f(.Indexed(zip(a, b).map(recur))).evaluate(equals, recur: recur)
case let (.Keyed(a), .Keyed(b)) where Array(a.keys) == Array(b.keys):
return f(.Keyed(Dictionary(elements: b.keys.map { ($0, recur(a[$0]!, b[$0]!)) }))).evaluate(equals, recur: recur)
default:
// This must not call `recur` with `a` and `b`, as that would infinite loop if actually recursive.
return f(Diff.Pure(.Replace(a, b))).evaluate(equals, recur: recur)