Skip to content

Instantly share code, notes, and snippets.

@knguyen2708
knguyen2708 / String+LevenhsteinDistance.swift
Created January 17, 2020 06:00
Levenshtein distance between strings (Swift)
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)
@knguyen2708
knguyen2708 / swift-docs
Last active July 1, 2018 05:56
Swift Docs
/**
A function.
- parameters:
- alpha: First parameter
- beta: Second parameter
- parameter alpha: 1st parameter
- parameter beta: 2nd parameter