# Help for the lazy

**URL:** <https://discourse.julialang.org/t/help-for-the-lazy/68801>\
**Category:** General Usage\
**Tags:** namedtuple\
**Created:** [September 27, 2021, 8:44am UTC](https://discourse.julialang.org/t/help-for-the-lazy/68801 "2021-09-27T08:44:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amrods](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrods/32/2543_2.png) [@amrods](https://discourse.julialang.org/u/amrods)\
**Post date:** [September 27, 2021, 8:44am UTC](https://discourse.julialang.org/t/help-for-the-lazy/68801/1 "2021-09-27T08:44:15Z")

</div>

I have several matrices `x1, ..., xn` what’s a way to create a named tuple `(x1=x1, ..., xn=xn)` without having to type all components one by one?  
For example:

```julia
x1 = rand(2, 2)
x2 = rand(2, 2)
x3 = rand(2, 2)

lazyhelper(x1, x2, x3)
# returns (x1=x1, x2=x2, x3=x3)

```

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [September 27, 2021, 9:34am UTC](https://discourse.julialang.org/t/help-for-the-lazy/68801/2 "2021-09-27T09:34:24Z")

</div>

Just:  
`(; x1, x2, x3)` (needs Julia 1.6)

If you want to automate it for a large number of variables, you’ll either need to define a macro or create an expression and `eval` it.

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [September 27, 2021, 3:33pm UTC](https://discourse.julialang.org/t/help-for-the-lazy/68801/3 "2021-09-27T15:33:26Z")

</div>

I have a package [AddToField.jl](https://github.com/pdeffebach/AddToField.jl/) that makes the creation of a named tuple easier as well

```julia
@addnt begin 
    @add m1 = ...
    @add m2 = f(m1)
end

```
