-werners-
Esteemed Contributor III

So basically this can be done by generating 2 lists which are then zipped.

One list contains the first dates of the tuples, so these are in your case 2 days apart.

The other list is the 2nd dates of the tuples, also 2 days apart.

Now we need a function which creates these lists.

Mind that I found this function on the internet somewhere (forgot where) but it is elegant and works great!

import java.time.LocalDate

//create an infinite stream of dates starting at `fromDate`.

//streams are lazy evaluated so they are only filled as requested

def dates(fromDate: LocalDate): Stream[LocalDate] = {

 fromDate #:: dates(fromDate plusDays 2 ) //add 2 days

}

val x = dates(LocalDate.now()).take(5).toList //start from today

val y = dates(LocalDate.now().plusDays(1)).take(5).toList //start from tomorrow

val list = x zip y