Consider this code :
/** Takes a list and turns it into an infinite looping stream. */
def loop(l: List[Char]): LazyList[Char] = {
l.to(LazyList) #:::loop(l)
}
/** Encodes a sequence of characters with a looped key. */
def codec(message: Seq[Char], key: Seq[Char], cipher: (Char, Char) => Char): Seq[Char] = {
val loopedKey = loop(key.toList)
val mergedMessage = message.toList zip loopedKey
val xorResult = mergedMessage.map(cipher)
xorResult.toSeq
}
The loop function is correct, but the function named codec yield the following error when compiled :
[error] type mismatch;
[error] found : (Char, Char) => Char
[error] required: ((Char, Char)) => ?
[error] val xorResult = mergedMessage.map(cipher)
I don't understand why the required part says : ((Char, Char)) => ?.