2
$\begingroup$

In another question here, I saw this

poincareMetric[u_?VectorQ, v_?VectorQ] := ...

Whilst I am familiar with the syntax label_Type, e.g. x_Real, I had not seen this form, but when I tried to search the MMA documentation I found that searching for _? returned no results and neither _ or ? on their own suggested to me a clear meaning for _? - especially since I would have written u_List for u_?VectorQ

So,

1/ What does _? actually mean, and

2/ What is this function definition doing that would not be done by e.g. u_List?

but most importantly,

3/ How does one search for help on such terse syntactic constructions effectively? (So as not to ask almost trivial questions here)

$\endgroup$
10
  • $\begingroup$ Almost all of these can be found by a documentation search. Your only mistake is assuming that _? is a single unit. It's _ and ? separately. You can search for both. $\endgroup$
    – Szabolcs
    Oct 29, 2016 at 8:59
  • 4
    $\begingroup$ Otherwise look at this post: mathematica.stackexchange.com/questions/18393/… $\endgroup$
    – Szabolcs
    Oct 29, 2016 at 8:59
  • $\begingroup$ Also see my comments on VectorQ here. $\endgroup$
    – Szabolcs
    Oct 29, 2016 at 9:02
  • $\begingroup$ Whilst searching for "_" produced only 1 result, searching for "?" produced 1055 hits. Searching for "_ ?" returned none. When you say I could "search for both", what could I enter in the search box (one search) or how could I combined multiple searches? (process) to identify relevant entries? Also, following links I arrive at controlling order of evaluation "define the function f to only evaluate if it receives a numeric value by using NumericQ and pattern testing. Append the pattern ?NumericQ to the argument of the function f"... TBC $\endgroup$ Oct 29, 2016 at 9:21
  • 1
    $\begingroup$ Searching for ? produces precisely three results. It has two uses in Mathematica syntax and one in regular expressions. Go to Help -> Wolfram Documentation, type ? and hit Enter. Use the builtin documentation, not Google or the Wolfram website. $\endgroup$
    – Szabolcs
    Oct 29, 2016 at 9:22

0

Browse other questions tagged or ask your own question.