Linked Questions

3
votes
2answers
3k views

Returning a function from a Module [duplicate]

I'm having problems working with the output from DSolve whilst in a module. To handle the result outside a module typically I would do something like ...
5
votes
3answers
143 views

Using a function from inside a module [duplicate]

I try to plot a function for special values of some parameters which I don't want to set globally: ...
5
votes
1answer
171 views

Problem with With [duplicate]

I am puzzled byWith. it does not seem to work. Please see example below (I have also used Evaluate and ...
1
vote
2answers
59 views

How to use With on previously defined expressions [duplicate]

The command With[{x = 1}, x] outputs 1. The command t = x; With[{x = 1}, t] outputs ...
5
votes
0answers
310 views

What is the difference between Block and Module? [duplicate]

Possible Duplicate: What are the use cases for different scoping constructs? I don't understand the difference between the Matheamtica functions Block and <...
1
vote
1answer
153 views

Using With in combination with Graphics [duplicate]

Assume that we are given a symbol p={x,y} which should represent a 2D point. If x and y have ...
0
votes
0answers
125 views

Block, With, Module, can anyone help me understand the distinction? [duplicate]

I've been working heavily with Block[] for months in my research so I've read the documentation for the seemingly similar commands With[], Block[], and Module[]. Personally, I've had by far the ...
0
votes
0answers
118 views

How do I declare global constants and local constants? [duplicate]

Many times I have a Mathematica code like this ...
2
votes
0answers
74 views

How do I define a collections of commands for later use? [duplicate]

Many ask me to tackle this problem by making another function(subroutine) of the lines I want to pick out, using Block,Module,etc The problem is different here.Notice that Block and Module ...
1
vote
0answers
49 views

Is this expected behavior for With? Should it be replaced by Block? [duplicate]

Evaluating the following piece of code, returns-as expected-3: g[a_] = a; With[{a = 1}, 2 + g[a] ] Why does the following ...
0
votes
0answers
44 views

Evalutation strategy [duplicate]

This example code: ...
0
votes
0answers
41 views

Creating functions that ignore if a variable is already set [duplicate]

I have noticed that there are functions in Mathematica that are ignoring already set parameters. I.e. Plot: ...
0
votes
0answers
37 views

RandomReal behavior in Block environment [duplicate]

I ran into an unexpected behavior of RandomReal function inside the Block environment. If I simplify my problem: I wanted to use two random local variables, such that the second one would be less that ...
528
votes
19answers
132k views

Where can I find examples of good Mathematica programming practice?

I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't ...
107
votes
9answers
5k views

Functional style using lazy lists?

Let's say I want to answer the question "what are the first 400 palindromic prime numbers?" The first approach that comes to my mind from the set of languages that I know is to use some sort of lazy ...

15 30 50 per page