Suppose I have the following lists:
eqexp={a,b,c,d}
eqval={e,f,g,h}
signval={{},{1},{-1},{1,-1}}
I want to create a new list of inequalities, where the signval list signals whether to use greater than or less than. I need it to handle empty sublists, and multi-component sublists. My desired output is:
{{},{b>f},{ch,d
All lists have the same number of top-level elements. eqexp and eqval are one-dimensional. signval is two-dimensional, but the length of the sub-lists is variable. The only numerical values allowed in signval are 1 and -1.
How do I do this?
Answer
MapThread[#3 /. {1 -> #1 > #2, -1 -> #1 < #2} &, {eqexp, eqval, signval}]
(* {{}, {b > f}, {c < g}, {d > h, d < h}} *)
Comments
Post a Comment