Nir
12/18/2020, 7:04 PMline.mapIndexedNotNull{ y, c -> if(c == '#') (x to y).toPoint(d) else null }
Or:
line.withIndex().filter { it.value == '#' }.map { (y, _) -> (x to y).toPoint(d) }
ephemient
12/18/2020, 7:05 PMephemient
12/18/2020, 7:06 PMKroppeb
12/18/2020, 7:07 PMNir
12/18/2020, 7:12 PMNir
12/18/2020, 7:12 PMline
were a sequence instead of an iterable the difference should be pretty minimal no?Nir
12/18/2020, 7:13 PMephemient
12/18/2020, 7:15 PMlist
in front so I was not expecting it to be a sequence ;) for sequence, if your type is a primitive, going through the extra stage forces an extra box/unbox, so sometimes the cost is measureableNir
12/18/2020, 7:15 PMephemient
12/18/2020, 7:16 PMKroppeb
12/18/2020, 7:18 PMKroppeb
12/18/2020, 7:18 PMbjonnh
12/18/2020, 9:20 PMbjonnh
12/18/2020, 9:21 PMbjonnh
12/18/2020, 9:21 PM