1
1
mirror of https://github.com/github/semantic.git synced 2024-12-28 09:21:35 +03:00

Recur through pairs of equal-length indexed terms.

This commit is contained in:
Rob Rix 2015-10-15 11:33:13 -04:00
parent 8680bb4165
commit 52c1b581c6

View File

@ -23,6 +23,16 @@ public struct Interpreter<Term: TermType> {
switch algorithm { switch algorithm {
case let .Pure(diff): case let .Pure(diff):
return diff return diff
case let .Roll(.Recursive(a, b, f)):
switch (a.unwrap, b.unwrap) {
case let (.Indexed(a), .Indexed(b)) where a.count == b.count:
return recur(f(.Indexed(zip(a, b).map(run))))
default:
return nil
}
default: default:
return nil return nil
} }