Skip to content

Commit 3de6816

Browse files
Handle array comprehensions.
1 parent 95d9cae commit 3de6816

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/Symbolic.jl

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,15 @@ function findIncidence!(ex::Expr, incidence::Array{Incidence,1})
130130
# if ex.args[2].value != :all
131131
# push!(incidence, ex.args[1])
132132
# end
133+
elseif ex.head == :generator
134+
vars = [v.args[1] for v in ex.args[2:end]]
135+
incid = Incidence[]
136+
[findIncidence!(e, incid) for e in ex.args]
137+
unique!(incid)
138+
setdiff!(incid, vars)
139+
push!(incidence, incid...)
133140
else
134-
# For example: =, vect, hcat, block
141+
# For example: =, vect, hcat, block, ref
135142
[findIncidence!(e, incidence) for e in ex.args]
136143
end
137144
nothing
@@ -239,9 +246,15 @@ function linearFactor(ex::Expr, x)
239246
linears = [f[3] for f in factored]
240247
(ex, 0, all(linears))
241248
else
242-
@warn "Unknown expression type" ex
243-
dump(ex)
244-
(ex, 0, false)
249+
# @warn "Unknown expression type" ex
250+
# dump(ex)
251+
incidence = Incidence[]
252+
findIncidence!(ex, incidence)
253+
if x in incidence
254+
(ex, 0, false)
255+
else
256+
(ex, 0, true)
257+
end
245258
end
246259
end
247260

0 commit comments

Comments
 (0)