2
$\begingroup$

How can I define a function with no return value. For example, the Notation function from the Notation package seems to have no return value; I am looking to do the same thing for some of my custom functions.

$\endgroup$
  • 2
    $\begingroup$ can it not even return Null? if you end last line in function with ; it returns Null. And Null is like nothing. seems to have no return value did you look at the InputForm of what it returns? Since Null does not print to screen. $\endgroup$ – Nasser May 4 at 19:02
  • $\begingroup$ Is that what happens with Notation? I can call Notation[...] without a semicolon and I do not get an Out box. If there is no way to do it without any return value, I can live with that, but it would be cleaner if I could avoid all return values. $\endgroup$ – Kevin Ausman May 4 at 19:13
  • 1
    $\begingroup$ I do not know about using Notation to define functions that is why I asked. But my understanding is that function return last evaluation. So if you put ; at end you'll get a Null as return value. So whatever the last thing in the function is what is returned. (Unless you have an explicit Return[..,Module] in the middle. I do not know how to make a function not even return Null. But may be someone knows... $\endgroup$ – Nasser May 4 at 19:18
  • $\begingroup$ Ok, just tried it, and Null seems to not produce an Out box, so I think indeed this is what my example of Notation seems to do. Thank you for pointing me in the right direction. $\endgroup$ – Kevin Ausman May 4 at 19:33
2
$\begingroup$

@Nasser's response in the comments is correct. Returning Null (using a semicolon in the last statement of the function) gives the behavior I was looking for.

$\endgroup$

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.