0
$\begingroup$

I know that

MatrixQ[expr,NumericQ]

tells whether expr is a matrix with numerical values or not.

How do I implement such a check for an argument of a function?

func[matr_?WhatShouldIWriteHere]:=Module[{},...];

(should only work if matr is a matrix with numerical values)

$\endgroup$
  • 1
    $\begingroup$ Any predicate is ok: just write MatrixQ[#,NumericQ]&. (Although you might prefer NumberQ.) $\endgroup$ – Alan Sep 20 at 21:54
  • 1
    $\begingroup$ In addition to @Alan's comment, use parentheses, e.g., func[matr_?(MatrixQ[#, NumericQ]&)] := .. $\endgroup$ – Carl Woll Sep 20 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.