Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Levenshtein distance in net.liftweb.util.LD - exception if first parameter is empty. #1225

Merged
merged 2 commits into from

2 participants

@emssik

[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).

scala> import net.liftweb.util.LD
import net.liftweb.util.LD

scala> LD("aa", "bb")
res3: Int = 2

scala> LD("aa", "")
res4: Int = 2

scala> LD("", "bb")
java.util.NoSuchElementException
at scala.collection.LinearSeqOptimized$class.last(LinearSeqOptimized.scala:135)
at scala.collection.immutable.List.last(List.scala:45)
at net.liftweb.util.LD$.apply(LD.scala:94)
at .(:11)
at .()
at .(:11)
at .()
at $print()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:704)
at scala.tools.nsc.interpreter.IMain$Request.loadAndRun(IMain.scala:914)
at scala.tools.nsc.interpreter.IMain.loadAndRunReq$1(IMain.scala:546)
at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:577)
at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:543)
at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:694)
at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:745)
at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:651)
at scala.tools.nsc.interpreter.ILoop.processLine$1(ILoop.scala:542)
at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:550)
at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:822)
at scala.tools.nsc.interpreter.ILoop.main(ILoop.scala:851)
at xsbt.ConsoleInterface.run(ConsoleInterface.scala:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:57)
at sbt.compiler.AnalyzingCompiler.console(AnalyzingCompiler.scala:48)
at sbt.Console.console0$1(Console.scala:23)
at sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply$mcV$sp(Console.scala:24)
at sbt.TrapExit$.executeMain$1(TrapExit.scala:33)
at sbt.TrapExit$$anon$1.run(TrapExit.scala:42)

@dpp dpp closed this pull request from a commit
@dpp dpp Closes #1225 648e52c
@dpp dpp closed this in 648e52c
@dpp dpp reopened this
@dpp dpp was assigned
@dpp dpp merged commit d6215e6 into from
@fmpwizard fmpwizard deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 27, 2012
  1. @dpp
  2. @dpp

    Closes #1225

    dpp authored
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 1 deletion.
  1. +4 −1 core/util/src/main/scala/net/liftweb/util/LD.scala
View
5 core/util/src/main/scala/net/liftweb/util/LD.scala
@@ -91,7 +91,10 @@ object LD {
new ListBuffer))
}
- matrix(y1, 0, (1 to x.length).toList).last
+ matrix(y1, 0, (1 to x.length).toList) match {
+ case Nil => 100000
+ case xs => xs.last
+ }
}
}
Something went wrong with that request. Please try again.