Questions tagged [return-value]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
4
votes
1answer
119 views

Best practice with Return in Module or Block

I am a bit confused on the use of Return in either Block or Module when defining a custom ...
2
votes
1answer
71 views

Defining a function that has no return value

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 ...
2
votes
2answers
76 views

Compound Statements and returning earlier results in () parentheses

I am trying to debug some script and need to Print[] out some results, sometimes before, and sometimes after, certain executions. These 3 trials exemplify my ...
3
votes
2answers
78 views

Catch parameter order and error using functional form

Question: Why does this fail? In:= (Catch[#] &)[Throw[17]] ...
1
vote
1answer
129 views

Iterations in Mathematica [closed]

this is probably a very easy question for all of you. I have a stochastic Mathematica code (not important what it's exactly) which gives me a number at the end. Now I want Mathematica to run this ...
1
vote
2answers
102 views

Returning value if a point is in a region?

I'm writing a function so that if the user clicks on a certain region, a value is returned. The function takes in a condition list like the one below and a point. ...
3
votes
2answers
399 views

How to force Return[] to return from an arbitrary point (like in C++)?

I need to test some complicated conditions to calculate a Return value. But MMa doesn't let you Return[] from anywhere the way C++ does. The structure of my Module is similar to this: ...
4
votes
1answer
166 views

Throw and Catch return wrong result inside Compile

Consider this code: fun = Compile[{{i, _Integer}}, Catch[Do[ If[j >= i, Throw[j]] , {j, 1, 10}]] ] I put an integer as argument then if this ...
1
vote
1answer
157 views

Throw and Catch or Return inside Compile

Consider this code: ...
1
vote
1answer
947 views

How to check empty tables using SQL Select or Execute?

If[SQLExecute[con, "Select * from TABLE"] == "{}", Print["TRUE"], Print["FALSE"]] I need to know the way, if the TABLE is empty or not
4
votes
2answers
185 views

Returning ancillary computation results from a function

Suppose I want to implement a function to solve a very basic Elliptic problem using Finite Element of some degree (It's just an example). Normally the user of my function is only interested to the ...
17
votes
1answer
4k views

Returning a value from a Module

In the following simple example MyMod := Module[{i}, Do[ Return[1], {i, 3} ]; Print["test"] ] I expected the module to exit on ...
6
votes
1answer
202 views

Return struct from function (with DownValues)

In Mathematica there is a way to create struct-like data type: struct[myField]=value I want to return myStruct from a function: ...
4
votes
2answers
4k views

Function returning Null along with other unexpected expressions

When I use some function, at the end along with the output I get some NULLs returned that I don't understand the reason for and are highly undesirable. For example, when I define the reversal of list ...
14
votes
4answers
1k views

How can I return a Sequence?

Recently I had the need to redefine a certain symbol in my init.m so it would be automatically omitted from any lists it appears in. I decided to redefine it to an empty sequence, e.g. ...
5
votes
4answers
2k views

Compile and “True should be a machine-size real number…” Error

I am trying to compile a little summation function. As far as I understand, because the built-in Sum function can also return NaN...
53
votes
8answers
20k views

How to avoid returning a Null if there is no “else” condition in an If construct

I need to use If but with only one option that is if "a" then do "b", else do nothing. So I wrote If[a,b] but the problem is ...