Skip to main content

Questions tagged [return-value]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer

How to get the value of expression if I have some equalities?

I have this system of equations: ...
Antoine Russ's user avatar
2 votes
1 answer

How to modify the argument of a specific function below?

I would like to change the values of a and b in the following function: ...
TobiR's user avatar
  • 254
2 votes
2 answers

about Return value of Module[]

questions are in the below code. Although I'm pretty sure of the answer, I still feel a little uncomfortable, because I feel that the format of the body of Module[] ...
Aerterliusi's user avatar
4 votes
1 answer

How to get a function from a string?

I'm trying to create a function that takes in input a function written as string and the return it applying a ToExpression and an Evaluate (Code below). The goal of this function is to transform the ...
cgcg's user avatar
  • 69
0 votes
0 answers

How to use Mathematica to return value from for-loop [duplicate]

I tried to use Mathematica to implement random generator. The pseudo code I use is as following: ...
Dan's user avatar
  • 47
4 votes
0 answers

Should I worry about concurrent access to LibraryLinked code?

According to these answers, when several heterogeneous results (say {MTensor, mint, double}) are needed to be returned from a LibraryLink ...
iago-lito's user avatar
  • 163
2 votes
1 answer

How to return two values from function

I have a function that generates cipher text for ElGamal encryption and I want to make return two values, but it returns only one. This is the code: ...
John Carter's user avatar
0 votes
1 answer

How to get While to Return a Custom Value?

The Documentation for While says: Unless an explicit Return is used, the value returned by While is Null. But how do I implement it? I'd like to build a function ...
user avatar
3 votes
3 answers

Return[] being saved to DownValues

Example: f[x_] := f[x] = (If[x < 0, Return[x]]; x) f[1]; f[-5]; DownValues[f][[1 ;; 2]] (* {HoldPattern[f[-5]] :> Return[-5], HoldPattern[f[1]] :> 1} *) ...
H.v.M.'s user avatar
  • 1,093
2 votes
2 answers

Vanishing function and Manipulate

Within Manipulate, I want to vanish certain controls if other controls satisfy a specific condition. The simplest case is to consider two checkboxes, ...
sam wolfe's user avatar
  • 4,863
5 votes
1 answer

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 ...
Bulkilol's user avatar
  • 289
2 votes
1 answer

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 ...
Kevin Ausman's user avatar
  • 2,277
2 votes
2 answers

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 ...
nate's user avatar
  • 445
3 votes
2 answers

Catch parameter order and error using functional form

Question: Why does this fail? In:= (Catch[#] &)[Throw[17]] ...
Jess Riedel's user avatar
  • 1,525
1 vote
1 answer

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 ...
QuantumMechanics's user avatar
1 vote
2 answers

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. ...
studentguest's user avatar
5 votes
2 answers

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: ...
Jerry Guern's user avatar
  • 4,612
4 votes
1 answer

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 ...
MOON's user avatar
  • 3,874
1 vote
1 answer

Throw and Catch or Return inside Compile

Consider this code: ...
MOON's user avatar
  • 3,874
1 vote
1 answer

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
Nicolas Guasch's user avatar
5 votes
2 answers

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 ...
unlikely's user avatar
  • 7,103
17 votes
1 answer

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 ...
enzotib's user avatar
  • 1,094
6 votes
1 answer

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: ...
EvgenijM86's user avatar
4 votes
2 answers

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 ...
Pankaj Sejwal's user avatar
14 votes
4 answers

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. ...
Sparkette's user avatar
  • 283
5 votes
4 answers

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...
Petr's user avatar
  • 549
60 votes
8 answers

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 ...
Raph's user avatar
  • 711