julia> x = [1,2,3,4,5];
julia> collect(Iterators.flatten((prod(u) for u in with_replacement_combinations(x,i)) for i in 0:3))
56-element Vector{Int64}:
It works for me can you post more details about the error you’re seeing?
Ah… seems like it is due to a change in Symbolics…
If I instead do:
using Symbolics, Combinatorics
@variables x[1:2]
x = collect(x)
collect(Iterators.flatten((prod(u) for u in with_replacement_combinations(x,i)) for i in 0:3))
Apparently, now @variables x[1:2] creates a symbolic array variable, but I need an array of symbolic variables — which is achieved by x = collect(x). [A trick I learned from @baggepinnen in a totally different setting.]
julia> using DynamicPolynomials
julia>
julia> x,y,z = @polyvar x y z
(x, y, z)
julia> monomials([x,y], 2)
3-element MonomialVector{true}:
x²
xy
y²
julia> monomials([x,y], 0:3)
10-element MonomialVector{true}:
x³
x²y
xy²
y³
x²
xy
y²
x
y
1
julia> monomials([x,y,z], 1:2)
9-element MonomialVector{true}:
x²
xy
xz
y²
yz
z²
x
y
z