-2
$\begingroup$
m = {{3, 12, -7, 1}, {16, 7, 2, 9}, {5, 3, 0, -6}, {8, 1, -4, 17}}

write a procedural programme and functional programme to find the smallest absolute element in each row of the matrix.

$\endgroup$

closed as off-topic by Szabolcs, José Antonio Díaz Navas, bbgodfrey, PlatoManiac, Johu Jan 23 at 15:00

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – Szabolcs, José Antonio Díaz Navas, bbgodfrey, PlatoManiac
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ What about Min /@ Abs[m]? $\endgroup$ – Fred Simons Oct 25 '18 at 14:54
  • 2
    $\begingroup$ Sounds like a homework problem to me. Do you have either answer? Have you tried anything? $\endgroup$ – N.J.Evans Oct 25 '18 at 15:04
  • $\begingroup$ yes i tried it with map.its easy with functional programming $\endgroup$ – Muhammad Oct 25 '18 at 15:06
  • $\begingroup$ m={-,-,-,-}: Map[Min, Abs[m]] like this one . $\endgroup$ – Muhammad Oct 25 '18 at 15:10
  • 1
    $\begingroup$ If you already knew this functional solution, you should have mentioned it in your question. Otherwise you are just repeating my comment. $\endgroup$ – Fred Simons Oct 25 '18 at 15:14
1
$\begingroup$

For functional programming (I think so):

TakeSmallestBy[Abs, 1] /@ m
{{1}, {2}, {0}, {1}}

For procedural programming: left for others.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.