Я пытаюсь читать входной поток в кусках:результатов TakeWhile в типе несоответствии
import scala.io.Source
// val in = Source.stdin.mkString("")
val in = Source.fromFile("/shared/american.txt").getLines.mkString("")
var ptr = 0
val out = Stream.continually {
val ix = math.min(ptr+80,in.length)
val ret = in.substring(ptr, ix)
ptr = ix
ret
}
out: scala.collection.immutable.Stream[String] = Stream(Unmentionable has an enthusiastic 35% of the popular vote. I discount the other 10% or s, ?)
Но что синтаксис для take
кусковых? Я пробовал:
val chunks = out.takeWhile(ptr < in.length)
<console>:13: error: type mismatch;
found : Boolean
required: String => Boolean
val ret = out.takeWhile(ptr < in.length)
сгруппировано (n) будет делать то же самое, что и скользящий (n, n) – soote
К сожалению. Пропустил это. Благодарю. – jwvh