zipWith
(Scastie with the signature to start out with)
2 hours later…
1 hour later…
Scala 3 also has polymorphic function literals, although that requires modifying the use site a bit :(
19:47
That's because of
0 to list1.length
. to
makes an inclusive range, so it tries to access the element at index 3, which doesn't exist because there's only 3 elements in the list. You could try either 0 to list1.length - 1
or 0 until list1.length
instead
But you can use a for comprehension instead. Also,
Array
s are mutable and hard to print, so let's avoid those
Here's a horribly inefficient but fun version using pattern matching that also works with lists of different sizes (it trims to the size of the shorter list)
« first day (405 days earlier) ← previous day next day → last day (873 days later) »