1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 08:54:07 +03:00

Convenience helper for keyed locations.

This commit is contained in:
Rob Rix 2015-11-05 10:33:49 -05:00
parent ccbb3f1bb4
commit e6429cee40

View File

@ -79,6 +79,10 @@ public struct Location<A>: SequenceType {
return Location(flip(weave), reconstruct >>> up, ts)
}
public static func variadic<Key>(ts: [Key:A], _ weave: Weave, _ reconstruct: [Key:A] -> A)(_ up: A -> Location?) -> Location? {
return Location(flip(weave), Dictionary.init >>> reconstruct >>> up, Array(ts))
}
public static func explore(weave: Weave)(_ a : A) -> Location {
return Location(it: a, down: flip(weave)(explore(weave) >>> Optional.Some), up: const(nil), left: const(nil), right: const(nil))
}