# How to create a function from a vector of expressions?

**URL:** <https://discourse.julialang.org/t/how-to-create-a-function-from-a-vector-of-expressions/73457>\
**Category:** New to Julia\
**Tags:** macros, metaprogramming\
**Created:** [December 21, 2021, 9:38pm UTC](https://discourse.julialang.org/t/how-to-create-a-function-from-a-vector-of-expressions/73457 "2021-12-21T21:38:50Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Bardo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bardo/32/21601_2.png) [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Post date:** [December 22, 2021, 5:46am UTC](https://discourse.julialang.org/t/how-to-create-a-function-from-a-vector-of-expressions/73457/3 "2021-12-22T05:46:39Z")

</div>

[dump again](https://discourse.julialang.org/t/how-to-rewrite-this-macro/73333/2) (pun intended)  
Thanks a lot!

```julia
evec = [:(a[3] = a[1] + a[2]), :(a[4] = a[2] + a[3])]
eblk = Expr(:block,evec...)
fib = genfun(eblk, (:a,))
a = [1,1,0,0]
fib(a)
a

4-element Vector{Int64}:
 1
 1
 2
 3

```

---

_[View the full topic](https://discourse.julialang.org/t/how-to-create-a-function-from-a-vector-of-expressions/73457)._
