3 ms·
Would this be equivalent to: plusOne = (x+1 for x in (1,2,3)) And then the second example: mult = (x*y for x,y in zip((1,2,3), (4,5,6))) In python?
by deckiedan 13y ago
Would this be equivalent to:
plusOne = (x+1 for x in (1,2,3))
And then the second example:
mult = (x*y for x,y in zip((1,2,3), (4,5,6)))
In python?
- virtualwhys 13y agoyup, not sure what Python does with your examples under the hood, but they're equivalent, and, I must say, nicely concise ;-) In Scala I guess we could go zip-style and do: List(1,2,3) zip List(4,5,6) map{case(x,y)=> x*y} but I was trying to demo for comprehensions and their relation to map/flatMap for the OP.