:+ dates.last.plusDays(1)) } else { dates } } val dates = iterate(List(startDate)) println(dates) iterate [d1,d2,d3,d4,d5] iterate [d1] iterate [d1,d2] iterate [d1,d2,d3] iterate [d1,d2,d3,d4] [d1,d2,d3,d4,d5] [d1,d2,d3,d4,d5] [d1,d2,d3,d4,d5] [d1,d2,d3,d4,d5] [d1,d2,d3,d4,d5]