10
$\begingroup$

I just noticed that Exit and Quit can work without brackets i.e. a single

Exit

or

Quit

will quit the kernel. Quite surprising!

This isn't mentioned in the document of them. Is there a list for functions with this feature?

Well, I admit I asked this question mainly to show the discovery above :D

$\endgroup$
6
  • $\begingroup$ Pi and E and EulerGamma though you could argue these are constants (and boringly return themselves). I'd look for functions that take no arguments, though I can't imagine there are many interesting ones that aren't constants. $\endgroup$
    – user1722
    Dec 1, 2014 at 16:31
  • 3
    $\begingroup$ These have been mentioned before and they came as quite a surprise to me. Following standard syntax these should be Exit[] or Quit[]. I suspect that these were included only to reduce the frustration of new users who were entering Exit and not getting the desired effect. I have never looked for additional cases though they may exist. $\endgroup$
    – Mr.Wizard
    Dec 1, 2014 at 18:29
  • 4
    $\begingroup$ They work without brackets when it's the only input to the cell, not when they are part of any expression though. Suggesting this is some sort of ancient flow control loophole, I dunno. $\endgroup$
    – swish
    Jan 18, 2017 at 7:03
  • $\begingroup$ I suppose Nothing will not fit your criterion? Tho Nothing and Nothing[] are equivalent, it is handy to be able to do things like Nothing @@ {{1}, {2}} and Nothing @@@ {{1}, {2}}. $\endgroup$ Jul 25, 2019 at 13:50
  • $\begingroup$ @J.M.isaway It fits, please add this as an answer :) . (BTW why do you think it doesn't fit my criterion? ) $\endgroup$
    – xzczd
    Jul 25, 2019 at 14:36

3 Answers 3

4
$\begingroup$

Just noticed Return can work without brackets when it's inside a dialog:

enter image description here

$\endgroup$
4
$\begingroup$

At the OP's request, I am adding the following:

Nothing is a function with very peculiar behavior:

Nothing === Nothing[] === Nothing[x, y]
   True

This means that

Nothing & /@ {{a}, {b}}

and

Nothing /@ {{a}, {b}}

and

Nothing @@@ {{a}, {b}}

all give {} as the result.

$\endgroup$
-1
$\begingroup$
Here

Could also work without brackets.

$\endgroup$
5
  • $\begingroup$ (-1) I'm sorry, but Here is not a function. $\endgroup$
    – xzczd
    Jul 25, 2019 at 5:26
  • $\begingroup$ @xzczd what is the definition of a function here? p.s. how about Now? $\endgroup$
    – Kuba
    Jul 25, 2019 at 5:46
  • $\begingroup$ @Kuba Perhaps I should say "function relationship" or "Head"? Now is not, either. Both Here and Now are used without [], they're built-in symbols, but not functions. $\endgroup$
    – xzczd
    Jul 25, 2019 at 5:54
  • $\begingroup$ Right, fair enough. $\endgroup$
    – Kuba
    Jul 25, 2019 at 5:56
  • $\begingroup$ @xzczd Yes, you are right. $\endgroup$
    – shelure21
    Jul 25, 2019 at 7:28

Your Answer

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

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