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

Write cons as a func.

This commit is contained in:
Rob Rix 2015-10-06 11:54:42 -04:00
parent c0ab03e73d
commit cc6627bb52

View File

@ -118,8 +118,8 @@ public enum FreeAlgorithm<A, B> {
}
}
let cons: (Diff, Memo<Stream<(Diff, Int)>>) -> Stream<(Diff, Int)> = {
return .Cons(($0, cost($0) + ($1.value.first?.1 ?? 0)), $1)
func cons(diff: Diff, rest: Memo<Stream<(Diff, Int)>>) -> Stream<(Diff, Int)> {
return .Cons((diff, cost(diff) + (rest.value.first?.1 ?? 0)), rest)
}
var matrix: Matrix<Stream<(Diff, Int)>>!
@ -138,16 +138,16 @@ public enum FreeAlgorithm<A, B> {
// right extent of the edit graph; can only move down
if let down = down {
return cons(diff, down)
return cons(diff, rest: down)
}
// bottom extent of the edit graph; can only move right
if let right = right {
return cons(diff, right)
return cons(diff, rest: right)
}
// bottom-right corner of the edit graph
return cons(diff, Memo(evaluated: Stream.Nil))
return cons(diff, rest: Memo(evaluated: Stream.Nil))
}
return f(Array(matrix[0, 0]!.value.map { diff, _ in diff })).evaluate(equals)