This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// Based on: https://gist.github.com/kyro38/50102a47937e9896e4f4 | |
// (Updated to Swift 5, formatted to follow Swift conventions and fixed bug with empty strings) | |
extension String { | |
/// Levenshtein distance between strings. | |
static func levenshteinDistance(_ x: String, _ y: String) -> Int { | |
let xArray = Array(x.utf16) | |
let yArray = Array(y.utf16) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
A function. | |
- parameters: | |
- alpha: First parameter | |
- beta: Second parameter | |
- parameter alpha: 1st parameter | |
- parameter beta: 2nd parameter |