rosetta-code

Levenshtein distance in Swift3

余生颓废 提交于 2019-12-24 01:39:14
问题 I'm using a tutorial from Rosetta Code to calculate Levenshtein distance. It seems their code is in Swift2 so I get this error Binary operator '+' cannot be applied to operands of type '[Int]' and 'Repeated<String.CharacterView>' when doing this: var cur = [i + 2] + empty where let empty = repeatElement(s, count: 0) . How can I go about this? 回答1: There were a couple of changes to make. The construction of the Array empty. enumerate() is now enumerated() successor() doesn't exist anymore so I

Levenshtein distance in Swift3

天涯浪子 提交于 2019-12-24 01:39:12
问题 I'm using a tutorial from Rosetta Code to calculate Levenshtein distance. It seems their code is in Swift2 so I get this error Binary operator '+' cannot be applied to operands of type '[Int]' and 'Repeated<String.CharacterView>' when doing this: var cur = [i + 2] + empty where let empty = repeatElement(s, count: 0) . How can I go about this? 回答1: There were a couple of changes to make. The construction of the Array empty. enumerate() is now enumerated() successor() doesn't exist anymore so I