# Defining vector partition functions in sage

I want to define a vector partition function starting from a given list of vectors. For example, let's say I have vectors $v_1,v_2,v_1+v_2$ where $v_1,v_2$ are linearly independent and I want to list all the partitions using these three vectors. For convenience I can define the set of positive vectors to be the set ${kv_1+lv_2:k,l \in \mathbb{Z}_{\geq 0} } $, and for the program to be finite I am okay with taking $k,l$ only up to some fixed number, for example I have taken 2 below. I am trying as follows:

```
sage: v1,v2 = var('v1','v2')
sage: S = [v1,v2,v1+v2]
sage: Pos = [k*v1+l*v2 for k in [0,1,2] for l in [0,1,2]]
sage: def par(x):
sage: p(x) = []
sage: for y in S :
sage: if x-y in Pos:
sage: for z in p(x-y):
sage: n = z + y
sage: if n not in p(x):
sage: p(x)=p(x)+n
sage: return p(x)
```

This does not work. I don't understand why. Somehow `sage: par(v1)`

gives () as answer and `sage: par(v1+v2)`

gives TypeError: Must construct a function with a tuple (or list) of variables.

Please help me out.

Edit:

Vector partition function: I have a fixed set $S={ v_1,...,v_n} $ of vectors, let $v$ be a vector. An expression of the form $v=c_1v_1+...+c_nv_n$ with $c_i\in \mathbb{Z}_{\geq 0}$ is called a partition of $v$. $Par(v)$ be the set of partitions of $v$. I want to find out this set at the end of the program.

Roughly, what I wanted was: Start with L an empty list/set. Find $P(v-v_i)$ for each $i$. For each partition of $v-v_i$ attach $v_i$ to make it a partition of $v$. Now check whether the new partition thus formed is already counted before or not, if not then enter it in L.