# Map\_rect and future Stan - any chance it gets easier? :)

**URL:** https://discourse.mc-stan.org/t/map-rect-and-future-stan-any-chance-it-gets-easier/6499
**Category:** Developers
**Created:** [November 13, 2018, 11:17am UTC](https://discourse.mc-stan.org/t/map-rect-and-future-stan-any-chance-it-gets-easier/6499 "2018-11-13T11:17:15Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Charles\_Driver](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/charles_driver/32/6524_2.png) [@Charles\_Driver](https://discourse.mc-stan.org/u/Charles_Driver)
#### Post date: [November 13, 2018, 11:17am UTC](https://discourse.mc-stan.org/t/map-rect-and-future-stan-any-chance-it-gets-easier/6499/1 "2018-11-13T11:17:15Z")

</div>

So I have a big for loop with many many dependencies, packing them all into the current map\_rect format is not something I’m in a hurry to do. Just wondering what, if anything, might be coming down the pipeline – is there any chance this sort of thing gets easier? I guess allowing arbitrary function structure, or allowing references to the general stan model environment from within the function and automagically determining the bits to pass out with map\_rect, are the kind of things I’d enjoy very much ;)

---

<div class="post-metadata">

### Author: ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)
#### Post date: [November 19, 2018, 7:30am UTC](https://discourse.mc-stan.org/t/map-rect-and-future-stan-any-chance-it-gets-easier/6499/2 "2018-11-19T07:30:10Z")

</div>

> [@Charles\_Driver](#):
>
> Just wondering what, if anything, might be coming down the pipeline – is there any chance this sort of thing gets easier?

Let’s hope so! We try to start by rolling out the most primitive form that’s workable and then see what we need after that.

I discussed one enhancement in my whirlwind roadmap talk at StanCon Helsinki :-) I suggested we can do something like this:

```no-highlight
map_rect(f, theta, phi1, ..., phiJ, x1, ..., xM)

      = append_col(f(theta[1], phi1, ..., phiJ, x1[n], ..., xM[n])
                   ...,
                   f(theta[N], phi1, ..., phiJ, x1[n], ..., xM[n])

```

Where you can add arbitrary many parallel arrays after the main argument `theta` and shared arguments `phi1`, …, `phiN`., and where the data args can be real or floating point.

Part of what will make map\_rect easier is ragged data structures, which is an independent ehancement from variadic arguments.
