All Questions

Filter by
Sorted by
Tagged with
2
votes
1answer
36 views

Construction of symmetric function / matching function argument patterns

[Edited for clarification after comment] Suppose that the function f is defined as the linear combination of several translated/reflected functions starting from the primitive f0[x,y,z] ...
3
votes
1answer
31 views

Applying pure function to rotate the label in a BoxWhiskerChart

Data is available from here https://www.ocr.org.uk/Images/400305-large-data-set-lds_1-h630-2018-h640-2018-2019-pre-release-data-mei.xlsx ...
3
votes
2answers
233 views

Outputting expressions in the order in which they're entered

Background For display purposes, I sometimes find it desirable to defeat Mathematica's canonical ordering of variables, and instead have it output terms in the order in which I type them. E.g., ...
5
votes
1answer
182 views

Pure function as a variable of another function

In a notebook, I have a function that basically needs to do something like calling a pure function within a function. I would say that what best describes would be an example like: ...
1
vote
2answers
81 views

Reproducing Nest-function with recursive nesting does not work

In general, when I am learning a new programming language, it helps me to understand how builtin functions works. I am trying to reproduce the builtin Nest[f,exp,n] ...
1
vote
0answers
47 views

Mapping over array/matrix the efficient(compact) way

Update In short, I have myCAans[[1 ;; 5]] like this: {{0, 0, 0, True, 0, 0, 0, 0, True, 0, "T0", 39}, {0, 0, 0, True, 0, 0, 0, 1, True, 1, "B", 101500}, {...
5
votes
1answer
648 views

Writing lambda expressions in terms of pure functions

I am trying to create some functions that I want to comfortably compose together using the pure functions. The functions were originally written in $\lambda$-expressions so I would like to keep the ...
11
votes
2answers
461 views

Combining pure functions

Is there an easy way to combine pure functions into a single pure function? For example, say I have f = #1^2 &; g = #1 - 2 &; and I want to define a new ...
8
votes
2answers
542 views

Creating a pure function that does operations with pure functions

Suppose I have two functions defined as follows: a = #+3& b = #^2 + 3& So when I call a[2] and ...
11
votes
4answers
530 views

Using predefined expressions as free variables in a pure function [duplicate]

I want to have a function value of an expression where some variables are solutions to some set of equations, with some values of parameters. I had an idea to use pure functions for that. However, ...
0
votes
0answers
37 views

How to use OptionValue inside a pure function [duplicate]

I want to define a function with OptionsPattern as argument which returns a pure function using OptionValue: ...
6
votes
1answer
160 views

Select with test function that depends on # [duplicate]

I'm trying to teach myself to use pure functions and slots as much as possible. Here is my problem. I have a list: ...
8
votes
3answers
474 views

How can I create currying functions using pure function syntax?

For example how can I write In: pureFunctionSyntax[myF] /@ {7, 3} Out: {myF[7, Log[7]], myF[3, Log[3]]}
0
votes
1answer
173 views

Working with functionals [closed]

I am trying to work with functionals in Mathematica, this means that I want to define a function of a function. I defined my function of a function as: ...
4
votes
1answer
242 views

Substitute a function's definition for its name

I'm having trouble with a function which is supposed to work on another function. Simplified version: ...
7
votes
5answers
633 views

How to write an operator that acts on pure function (to give another pure function)

I would like to write an operator oper that acts on a pure function f with an undetermined number of arguments, with the syntax <...
1
vote
0answers
102 views

How to Fold (FoldList) this in a more compact (efficient) way?

Example code: x = Table[something[i], {i, 5}] Table[Fold[f1[#1, f2[#2, a], a] &, x[[i]], {c1, c2, c3}], {i, Length[x]}] This above is just an example. I ...
2
votes
1answer
961 views

Why is either Listable or HoldFirst not working?

Starting with a fresh kernel, I evaluate the following: ...
2
votes
1answer
377 views

Requiring NumericQ in Pure Function

Potential duplicate, but doesn't seem to solve my problem: Using patterns in pure functions I have a function that returns an InterpolatingFunction, and it works ...
0
votes
1answer
133 views

Define a function that returns a function with a variable number of arguments

Previously, I've defined a function with a variable number of arguments with the following method. ...
1
vote
1answer
141 views

How to input pure function to package?

I would like to input a pure function into a custom written package, but am running into a variety of errors. The package I have created is as follows: ...
2
votes
1answer
88 views

Need to run evaluation 2 times

Why does this only work after running the evaluation 2 times? ...
4
votes
1answer
141 views

How to make InverseFunction work on function defined with restriction on arguments

This example works to define InverseFunction on the first argument of a function ...
32
votes
3answers
2k views

Is there any way to define pure functions with optional arguments?

For example consider the following function: Function[{u,v},u^2+v^4] Is there anyway to define default values for the variables ...
0
votes
1answer
649 views

How to define a pure function with a Module?

I was not able to use a self defined (using Module and For loops) piecewise function to fit data. It seems that the problem is that I have to define a pure function. I would like to learn how to ...
46
votes
4answers
2k views

Enforcing correct variable bindings and avoiding renamings for conflicting variables in nested scoping constructs

Using global variables the following turns an "expression" into a Function: expr = 2 x; Function[x, Evaluate[expr]] Of course ...
26
votes
4answers
3k views

Second level depth pure function?

I have the following working construction: Select[ln125, # == Nearest[ln125, 551.748][[1]] &] Here, ln125 is a one ...
20
votes
2answers
647 views

Using several anonymous functions mixed together

This works: list // BarChart[#[[2]], ChartLabels -> DateString @@@ #[[1]], ChartStyle -> "Pastel"] & This doesn't: ...
28
votes
8answers
2k views

Using patterns in pure functions

Pure functions may be handy if you don't want to assign your function a name. For example I would calculate $x(x-1)$ for some numbers $x$ by ...