# Form a matrix to have inequality elements

It looks like a silly question, but I could not find any answers online. Your help is greatly appreciated!

Say I have two lists now.

L1={{k},{2k+1},{3k+3},{4k},{5k-4},{6k}};
L2={">0","<0",">0",">0",">0","<0"}; (*it's in string form, mathematica wont let me run >0 without quotation marks*)


and I want to form a matrix like this shown as result (no string form contained)

result={{k>0},{2k+1<0},{3k+3>0},{4k>0},{5k-4>0},{6k<0}}


so that I can use Reduce to find the range of k for all elements in the result list. Thanks in advance!!

Use a different format from the start to avoid this complication.

L1 = {k, 2 k + 1, 3 k + 3, 4 k, 5 k - 4, 6 k};
L2 = {1, 2, 1, 1, 1, 2};

MapThread[{# > 0, # < 0}[[#2]] &, {L1, L2}]

{k > 0, 1 + 2 k < 0, 3 + 3 k > 0, 4 k > 0, -4 + 5 k > 0, 6 k < 0}

• Thanks Mr. Wizard! I will try this as well! – user11726 Feb 1 '15 at 3:53

Also:

L2a = L2 /. {">0" -> (Greater[#, 0] &),  "<0" -> (Less[#, 0] &)};

(*  {k > 0, 1 + 2 k < 0, 3 + 3 k > 0, 4 k > 0, -4 + 5 k > 0, 6 k < 0} *)


Or

Apply @@@ Thread[{L2a, L1}]
(*  {k > 0, 1 + 2 k < 0, 3 + 3 k > 0, 4 k > 0, -4 + 5 k > 0, 6 k < 0} *)

List /@ Apply @@@ Thread[{L2a, L1}]
(* {{k > 0}, {1 + 2 k < 0}, {3 + 3 k > 0}, {4 k > 0}, {-4 + 5 k >  0}, {6 k < 0}} *)

• Congratulations on entering the 60K club! :-) – Mr.Wizard Jan 30 '15 at 8:57
• Thanks for your answer, kguler! – user11726 Feb 1 '15 at 3:53

ClearAll[k]