2
私はこのようなzipWith
を定義していたとします、私はエラーを得たしかしこのタイプの不一致を修正するにはどうすればよいですか?
type Matrix = Vector[Vector[Int]]
val zipMatrix: ((Int, Int) => Int) => Matrix => Matrix => Matrix = f =>
zipWith(zipWith(f))
:
<console>:15: error: type mismatch;
found : (Iterable[Iterable[Int]], Iterable[Iterable[Int]]) => Iterable[Iterable[Int]]
required: Matrix => (Matrix => Matrix)
(which expands to) scala.collection.immutable.Vector[Vector[Int]] => (scala.collection.immutable.Vector[Vector[Int]] => scala.collection.immutable.Vector[Vector[Int]])
def zipWith[A](f:(A, A) => A)(xs:Iterable[A], ys:Iterable[A]): Iterable[A] =
(xs, ys).zipped map f
今、私はそのような行列をビュン用に使用したいですなぜVector[Vector[Int]]
はIterable[Iterable[Int]]
と一致しないのですか?このエラーを修正するには?
おかげで私はより一般的な解決策を取得したいのですが。より一般的な方が良いでしょう:) – Michael
[OK]をクリックすると、マトリックスタイプをより一般的に定義する必要がありますか? Matrix = Iterable [反復可能[Int]]と入力しますか?おそらく、 – Nyavro
。しかし、Vector [Vector [Int]]の何が間違っていますか?私が 'Matrix'型を変更できないとします。 – Michael