List manipulation: conditional result based on variable-length sublists
MapThread[#3 /. {1 -> #1 > #2, -1 -> #1 < #2} &, {eqexp, eqval, signval}]
(* {{}, {b > f}, {c < g}, {d > h, d < h}} *)
MapThread[Through @ # @ ##2 &, {signval /. {1 -> Greater, -1 -> Less}, eqexp, eqval}]
{{}, {b > f}, {c < g}, {d > h, d < h}}
Or do the replacement inside the first argument of MapThread
:
MapThread[Through @ ReplaceAll[ {1 -> Greater, -1 -> Less}][#] @ ##2 &,
{signval, eqexp, eqval}]
same result
Alternatively, define a function f0
with attribute Listable
and use regular function application:
f0 = Function[, # @ ##2, Listable];
f0[signval /. {1 -> Greater, -1 -> Less}, eqexp, eqval]
{{}, {b > f}, {c < g}, {d > h, d < h}}
Or use ReplaceAll
in the definition of the listable function:
f1 = Function[, ReplaceAll[{1 -> Greater, -1 -> Less}][#] @ ##2, Listable];
f1[signval, eqexp, eqval]
same result