# Syntax in a loop

**URL:** <https://community.freefem.org/t/syntax-in-a-loop/2100>\
**Category:** General Discussion\
**Created:** [November 4, 2022, 10:04am UTC](https://community.freefem.org/t/syntax-in-a-loop/2100 "2022-11-04T10:04:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Loic](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Loic](https://community.freefem.org/u/Loic)\
**Post date:** [November 4, 2022, 10:04am UTC](https://community.freefem.org/t/syntax-in-a-loop/2100/1 "2022-11-04T10:04:35Z")

</div>

Hello all !

I have a small practical question.

For example if I want to replace something like this:

```auto
mesh Th=square(2,2);

fespace Vh1(Th, P1);
fespace Vh0(Th, P0);

func w1=1;
func w2=x;
func w3=y;

varf vL1(u,uu) = int2d(Th)(u*w1*uu);
varf vL2(u,uu) = int2d(Th)(u*w2*uu);
varf vL3(u,uu) = int2d(Th)(u*w3*uu);

matrix MatL1 = vL1(Vh0,Vh1);
matrix MatL2 = vL2(Vh0,Vh1);
matrix MatL3 = vL3(Vh0,Vh1);

```

By a loop as:

```auto
for (int k=1; k<4; k++){
  varf vLk(u,uu) = int2d(Th)(u*wk*uu);
  matrix MatLk = vLk(Vh0,Vh1);}

```

What is the syntax to do this ?  
(I have tried several things, but it does not work)

Thank you in advance,

Best regards,

Loïc,

---

<div class="post-metadata">

**Author:** ![Loic](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Loic](https://community.freefem.org/u/Loic)\
**Post date:** [November 7, 2022, 9:11am UTC](https://community.freefem.org/t/syntax-in-a-loop/2100/2 "2022-11-07T09:11:39Z")

</div>

macro MyVarf(i) varf vL#i(u, uu) = int2d(Th)(u\*w#i’\*uu);
