From 39c46edeb94ecb6f935eab252626f9cc143772d5 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 25 Sep 2015 12:37:08 -0400 Subject: [PATCH] Implement the eliminators with analysis. --- prototype/Doubt/Vertex.swift | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/prototype/Doubt/Vertex.swift b/prototype/Doubt/Vertex.swift index 0f4d88ff0..d5c84bc95 100644 --- a/prototype/Doubt/Vertex.swift +++ b/prototype/Doubt/Vertex.swift @@ -12,30 +12,21 @@ public enum Vertex { } public var element: Element? { - switch self { - case let .XY(a, _, _): - return a - case .End: - return nil - } + return analysis( + ifXY: { x, _, _ in x }, + ifEnd: const(nil)) } public var right: Memo { - switch self { - case let .XY(_, xs, _): - return xs - case .End: - return Memo(evaluated: .End) - } + return analysis( + ifXY: { _, xs, _ in xs }, + ifEnd: const(Memo(evaluated: .End))) } public var down: Memo { - switch self { - case let .XY(_, _, ys): - return ys - case .End: - return Memo(evaluated: .End) - } + return analysis( + ifXY: { _, _, ys in ys }, + ifEnd: const(Memo(evaluated: .End))) } public var diagonal: Memo {