| [#1158] | project: compiler | priority: low | category: bug | |
|---|---|---|---|---|
| submitter | assigned to | status | date submitted | |
| Nikolay | Sean | fixed | 2007-05-30 13:32:44.0 | |
| subject | [contrib #576] Type inferencer problem | |||
| code |
val alphabet = "abcdefghijklmnopqrstuvwxyz"
def edits1(word: String) = {
val n = word.length() - 1
val deletions = for (i <- (0 to n)) yield word.substring(0, i) + word.substring(i + 1)
var transpositions = for (i <- (0 to n - 1))
yield word.substring(0, i) + word(i + 1) + word(i) + word.substring(i + 2)
val alterations = for (i <- (0 to n - 1); c <- alphabet)
yield word.substring(0, i) + c + word.substring(i + 1)
val insertions = for (i <- (0 to n + 1); c <- alphabet)
yield word.substring(0, i) + c + word.substring(i)
deletions ++ transpositions ++ alterations ++ insertions
}
|
|||
| what happened | /home/dpp/tmp/scala/Spell3.scala:51: error: no type parameters for method map: ((Char) => B)Seq[B] exist so that\
it can be applied to arguments ((Char) => java.lang.String)
--- because ---
result type Seq[B] is incompatible with expected type Iterator[?]
val alterations = for (i <- (0 to n - 1); c <- alphabet)
^
/home/dpp/tmp/scala/Spell3.scala:53: error: no type parameters for method map: ((Char) => B)Seq[B] exist so that\
it can be applied to arguments ((Char) => java.lang.String)
--- because ---
result type Seq[B] is incompatible with expected type Iterator[?]
val insertions = for (i <- (0 to n + 1); c <- alphabet)
^
/home/dpp/tmp/scala/Spell3.scala:66: error: type mismatch;
found : AnyRef with Iterator[java.lang.String]
required: Iterable[String]
val choices = known(List(word)) or known(edits1(word)) or known_edits2(word) or List(word)
^
three errors found
dpp@think:~/tmp/scala$
|
|||
| what expected | Clean compile | |||
| [back to overview] | ||||
| Nikolay edited on 2007-05-30 13:33:04.0 |
| Martin edited on 2007-06-01 16:19:58.0 |
| We have already agreed tp change `to' to yield a Sequence instead of an iterator. With that change, the error messages in the code abovve should go away. I leave for Sean to check this. |
| Sean edited on 2007-07-17 17:38:06.0 |
| Fixed with new Range class. |