(Ab?)using Range.map to generate Arrays of random numbers:
let randoms = (1...n).map { _ in Int(arc4random()) }
Conversation
1
I’m pretty skeptical of any use of map() where the input values are ignored entirely. It’s really fake each() here.
3
Replying to
Fair, though the nice thing about using map() is that it communicates how many outputs there will be to my scanning eye.
Replying to
1
2
Replying to
In Haskell you could do
sequence $ repeat n randomIO
which I think is a little cleaner.



