Linked Questions

1
vote
3answers
197 views

Assign a function within a function [duplicate]

What I'm doing wrong? 1st function works as expected but the 2nd one doesn't. What I want is to enter an algebraic expression and two numeric constants and get the same result as with the first ...
3
votes
1answer
126 views

How to inject segments of code into functions defined by SetDelayed [duplicate]

I need to define a set of functions that are written in terms of common but lengthy expressions. To effect this, I want to inject abbreviations for such expressions into the RHS of ...
0
votes
1answer
157 views

Function generating a rule with a Patterns: e.g. toRule[ lhs, rhs] into lhs[x_] -> rhs [duplicate]

I want to create a rule as a function of z from a left and right hand side. My (non-working) code and usage is: ...
1
vote
0answers
92 views

Why does With return a temporary symbol? [duplicate]

Why does With[{x0 = 1, y0 = 2}, f[x_] = a + b x /. First[ Solve[{y0 == a + b x0, b == 0.1}, {a, b}]]] evaluate to ...
2
votes
1answer
68 views

How to define a function inside a module through Evaluate [duplicate]

I am trying to define a function inside a module as following ...
1
vote
0answers
77 views

Odd problem with `Module` and `Block` [duplicate]

I found some bizarre phenomena in my code. While I'm using Module in my function, the result is incompatible with which I did outside ...
2
votes
0answers
55 views

Immediate Function Definition inside a Module [duplicate]

In mathematica, it is possible to perform immediate definition of a function where the dependent variable is not explicitly mentioned on the RHS. For example: ...
1
vote
0answers
43 views

How to use Evaluate inside function definitions? [duplicate]

How to use Evaluate inside function definition so that is acts as Evaluate only whet function is called? This is toy exampl, where I want to define function inside another function: ...
0
votes
0answers
26 views

Why are unrelated symbols localized in Module? [duplicate]

As I understand, an expression like Module[{var},expr[var]] localizes var and evaluates ...
0
votes
0answers
26 views

Patterns in module [duplicate]

I have this weird behavior of patterns inside the Module construct. Note that we have In: Module[{}, a_->x] Out: a_ -> x ...
527
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 ...
23
votes
3answers
761 views

Nested definition: How can I define a function with a passed-in expression?

Here's a simplified version of what I'm trying to do: ...
33
votes
2answers
2k views

Going full functional (Haskell style)

I'm trying to define some notation so that Mathematica code would be more functional, similar to Haskell (just for fun): currying, lambdas, infix operator to function conversion, etc.. And I have some ...
14
votes
4answers
451 views

Using With to scope over pure functions

Consider this example: given an option for a function func as "x" :> (a&), how can one assign different values to ...
29
votes
1answer
840 views

Is the renaming mechanism of `With` flawed?

I'm confused about the renaming mechanism of With: ...

15 30 50 per page