I am new to programming and was wondering if anyone can please help me out with this simple problem which is slightly confusing for me.
Code:
(1 to 3).toList.flatMap(i => (1 to i).map(j => i * j))
I don't understand int his part flatMap(i => (1 to i) <-- i is not assigned so what pattern does it get mapped in and why?
Also same thing with (j => i * j) how do we know what j is? there is no value for j.
I tried to figure out what pattern it makes:
1,1,2,1,2,3 <-- don't understand why it creates this pattern?
I hope i am making sense.
Thanks,