# Julia-ism for two-dimensional map?

**URL:** <https://discourse.julialang.org/t/julia-ism-for-two-dimensional-map/10613>\
**Category:** New to Julia\
**Created:** [April 30, 2018, 4:20am UTC](https://discourse.julialang.org/t/julia-ism-for-two-dimensional-map/10613 "2018-04-30T04:20:25Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [May 1, 2018, 2:40pm UTC](https://discourse.julialang.org/t/julia-ism-for-two-dimensional-map/10613/21 "2018-05-01T14:40:14Z")

</div>

> [@improbable22](#):
>
> `struct_prod(xlist, ylist)`

Your parameters are called `xlist` and `ylist`, but the body of the functions are referencing the global variables `xset` and `yset`.

---

<div class="post-metadata">

**Author:** ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Post date:** [May 1, 2018, 3:25pm UTC](https://discourse.julialang.org/t/julia-ism-for-two-dimensional-map/10613/22 "2018-05-01T15:25:49Z")

</div>

thx, improbable. yes, I did change the loop. the original was for print illustration. this one has become more for basic benchmarking, which wasn’t really my question originally, but then became quite interesting.

[I fixed the sa in the post above.]

---

<div class="post-metadata">

**Author:** ![improbable22](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/improbable22/32/5464_2.png) [@improbable22](https://discourse.julialang.org/u/improbable22)\
**Post date:** [May 1, 2018, 5:20pm UTC](https://discourse.julialang.org/t/julia-ism-for-two-dimensional-map/10613/23 "2018-05-01T17:20:59Z")

</div>

> [@stevengj](#):
>
> the functions are referencing the global variables xset and yset.

Ah indeed, sorry about that!

After fixing that, the version with `for x in xset for y in yset]` takes only about twice as long (141.284 μs) as the version with `Iterators.product(xset,yset)]`. This seems surprising, is there an obvious reason? Or just something to keep in mimd?

[Previous page](https://discourse.julialang.org/t/julia-ism-for-two-dimensional-map/10613.md?page=1)
