Skip to main content

Questions tagged [core-language]

Questions on the basic structure of the Mathematica language (Wolfram language) including atomic data types, syntax etc

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

Central element of matrix

Let we have $(2\cdot r+1) \times (2\cdot r+1)$ matrix mat. Is there a better way to extract it's central element, rather than ...
lesobrod's user avatar
  • 1,904
0 votes
0 answers
59 views

Is it safe to modify system functions and distribute?

I am trying to add my definitions to FormulaData and looking through the source files It is clear that one can do that systematically by adding some DownValues to system functions and elements to ...
Felipe's user avatar
  • 669
3 votes
3 answers
135 views

Special case of CellularAutomaton

I’m interested in multi-state CA in a closed 2D space and try to implement them using CellularAutomaton but do not understand how to do it. The first question is, ...
lesobrod's user avatar
  • 1,904
0 votes
0 answers
86 views

Proving Exact Answers to Logistics Map for 3-Cycles

Seems that I may have found a pair of exact solutions to the logistics map with cycles of period three. However, I’ve run into a bit of a snag in proving it because of some “ambiguities” in the ...
Steersman's user avatar
9 votes
1 answer
183 views

List[...] + Association[...], or Association[...] + List[...], when does the order matter?

Values of a list can be added to an association's values like so, ...
Carl Verdon's user avatar
3 votes
7 answers
435 views

Extract result of Reap in a natural way no matter if it's empty

This feature has long troubled me, I would like to share it. If Reap has non-empty set of sown, result looks like: ...
lesobrod's user avatar
  • 1,904
1 vote
0 answers
60 views

Random replacement in array

In the spirit of this interesting article of Stephen Wolfram I also decided to study some issues related to mutations. I’m working with simple {0,1} arrays and I’ve ...
lesobrod's user avatar
  • 1,904
0 votes
1 answer
54 views

Specific array filtering - code optimization

I have a nested list where all sublists have a length 2, eg: {{1,2}, {1,1}, {3,4}, {3,5}, ...} I need to filter it for two requirements: Delete all sub-lists ...
lesobrod's user avatar
  • 1,904
9 votes
3 answers
1k views

Why doesn't b = a; f[a_] := b; f[2] return 2?

As the title asks, why does b = a; f[a_] := b; f[2] evaluate to a rather than 2?
xzczd's user avatar
  • 67.7k
2 votes
2 answers
141 views

Catch error propagation

I'd like my function to work only for arrays with all positive members, eg: myf[arr_] := Reverse@arr /; AllTrue[arr, Positive]; So ...
lesobrod's user avatar
  • 1,904
4 votes
5 answers
140 views

How to implement this zip function? zip[g,{f[{a,b}],f[{c,d}]}] to f[{g[{a,c}],g[{b,d}]}]

I have a function that returns an expression in the form f[{a,b}], and I use this function twice and assemble the expression ...
Tapiocaweasel's user avatar
2 votes
3 answers
93 views

Clearing a list of variables: Problems trying to control the order-of-evaluation [duplicate]

I am having trouble controlling the order of evaluation of mathematica expressions. What I would really like is a general solution, in the form of a pair of functions ...
J Tyson's user avatar
  • 132
2 votes
2 answers
55 views

FindClusters with custom DistanceFunction

Let we have an array of integers e.g. Range@365. Each index has a specific value by which clusterization of integers should be done. But these values cannot be ...
lesobrod's user avatar
  • 1,904
4 votes
1 answer
83 views

PatternTest in Function

This is probably trivial and already asked but I did not find it. How to use PatternTest inside Function (...
azerbajdzan's user avatar
  • 21.3k
2 votes
1 answer
90 views

Problem with RecurrenceTable of two variables

Let we have simple recursive function: ...
lesobrod's user avatar
  • 1,904
5 votes
3 answers
157 views

Evaluation control of nested With, If and Integrate

Can you explain the behaviour of the following? The first With outputs unevaluated If. So in the second ...
three777's user avatar
  • 187
0 votes
2 answers
81 views

Parametric Minimize strongly revisited

Let we try to run this simple code: Minimize[{Cos[x + a/2], {0 <= x <= \[Pi], 0 < a < 1}}, x] It doesn't work. But ...
lesobrod's user avatar
  • 1,904
3 votes
2 answers
41 views

Strange behavior of MinimalBy [duplicate]

data = {{1, 2}, {2, 2}, {3, 3}}; MinimalBy[data, Norm@# &] Output: {{2, 2}} When applying numerically : ...
lesobrod's user avatar
  • 1,904
7 votes
1 answer
125 views

DuplicateFreeQ VS UnsameQ

What is the exact difference between DuplicateFreeQ @ arr and UnsameQ @@ arr ? I checked on many examples and found no ...
lesobrod's user avatar
  • 1,904
4 votes
3 answers
241 views

Converting to a scalar pure function without getting the warning messages

I am using this from the function repository for which I need to convert one of my functions into a unique form. A simple example is like this: Suppose I have, ...
codebpr's user avatar
  • 2,553
9 votes
2 answers
509 views

What's the difference between With and ReplaceAll?

A wolfram Tutorial mentions that ReplaceAll and With are similar: The way ...
ions me's user avatar
  • 1,055
7 votes
1 answer
501 views

How does this code work?

I saw this thread and upvoted many answers there. Below is the answer by kglr (not my most favorite answer there, but it looks fun). I wonder if anyone could help ...
internet's user avatar
  • 723
3 votes
1 answer
99 views

BlankNullSequence (___) when input variable is Null

f[x___] := Plus[x, -x] f[Null] gives output as 0 f[] ...
metroidman's user avatar
  • 1,003
4 votes
5 answers
497 views

How to check if multiplication requires carries?

For some purposes I need to know if there are there any carries in the multiplication of two numbers, especially in base-2. How can we do this in Mathematica? Thanks to all, very interesting answers! ...
lesobrod's user avatar
  • 1,904
2 votes
1 answer
81 views

Problem with permutations

For a given binary array like {0, 1, 1, 0,..}, I need to find the shortest permutation, sorting it in standard order ...
lesobrod's user avatar
  • 1,904
6 votes
1 answer
142 views

Want Map function to apply over sum of terms but not product

For a given function F, if I use Map[F,a+b+c d], Mathematica returns, as desired: F[a]+F[b]+F[c d] ; However, for ...
user160385's user avatar
1 vote
0 answers
35 views

Monitor inside core function

I like DistanceMatrix: its performance is surprisingly high, even for a big data. However, for a huge arrays and custom ...
lesobrod's user avatar
  • 1,904
0 votes
0 answers
55 views

MinimalBy with argument and value

I need to find element of some list arr which is minimal by some function f. But I need to get result in form ...
lesobrod's user avatar
  • 1,904
0 votes
0 answers
31 views

MapApply not converting numbers as strings to numbers

I have large vectors that were imported and came in as strings. I try to convert these to numbers using MapApply of ToExpression (and the "@@@" form of this). There must be some subtle ...
Mark R's user avatar
  • 1,589
1 vote
0 answers
33 views

Can symbolic sums of indexed arrays be simplified?

As a simple example, is it possible to simplify say Sum[Indexed[x, i], {i, 1, n}] == Indexed[x, n] + Sum[Indexed[x, i], {i, 1, n - 1}] If not, please explain ...
Alan's user avatar
  • 13.8k
4 votes
1 answer
104 views

Function[0], Function[,0], and Function[{},0]: Is there any inherent distinction in the "academic" sense?

Note that Function[,0] is by default interpreted as Function[Null,0]. The following three calls all give ...
user688486's user avatar
3 votes
2 answers
84 views

Problem with Association in DynamicModule

How can I understand the success of the first append but the failure of the second, here? (Mma 13.3.) Is there a ready work around? ...
Alan's user avatar
  • 13.8k
-6 votes
1 answer
72 views

How to test if the input is a positive fraction?

I would like to check if a fraction is positive. The difficulty arises when there are symbols. I would like to make the assumption that all symbols, variables, and indeterminates are positive real ...
Peter Burbery's user avatar
-2 votes
1 answer
54 views

How can I list the heads of an expression?

How can I check that a fraction contains only multiplication and power? I would like to check if it contains only the heads of Power and Times. I am wondering how to get a list of heads for a fraction....
Peter Burbery's user avatar
5 votes
1 answer
129 views

Condition inside pure function

Why condition /; not work inside pure function? Suppose we have: ...
lesobrod's user avatar
  • 1,904
1 vote
0 answers
53 views

Why do rules not default to local scope? [closed]

Consider the following: 80 //. a_?EvenQ -> a/2 a = 3 80 //. a_?EvenQ -> a/2 which outputs: 5 3 3/2 I think I understand ...
Jonah's user avatar
  • 121
6 votes
0 answers
99 views

Using Cases to select expressions from a list

I am using v12.2.0 on Win7-x64. I want to use Cases to select the Times and Plus cases from ...
Syed's user avatar
  • 56.2k
2 votes
1 answer
124 views

Why does using a variable name as pattern name determine its context?

Checking the context of a fresh variable inside Begin-End, it gives the enclosing context. ...
Jineon Baek's user avatar
11 votes
2 answers
1k views

What is a function?

Regarding: Map[#[{2, b}] &, {Reverse}] The above works, but it makes my head spin. The documentation for Map says that the ...
Chris 's user avatar
  • 467
2 votes
0 answers
79 views

With[{a=1},{b=a},b] in 13.2 does evaluate to 1 [duplicate]

This isn't documented, and the front end highlights the second comma and third argument in red, but it's used in DownValues[Once][[3]] and is very convenient. Anyone know more?
Edward Huff's user avatar
1 vote
1 answer
130 views

How to convert a function with named arguments to a pure function?

A function is defined with named arguments. How can this function be converted to a pure function that uses slots (#). As a simple example, how can the following: <...
feynman's user avatar
  • 239
1 vote
1 answer
119 views

Where does the result of thing["Properties"] come from?

Question I'll focus on the example stream=AudioStream@First@$AudioInputDevices I can do stream@"Properties" to get a ...
Adam's user avatar
  • 3,986
5 votes
2 answers
241 views

Do not understand evaluation order of ReplaceAll [duplicate]

{x, x^2, Length@x, Subsets[x]} /. x -> {1, 2, 3} (* {{1, 2, 3}, {1, 4, 9}, 0, {{}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}} *) with error What ...
lesobrod's user avatar
  • 1,904
6 votes
4 answers
330 views

Delete first case

How to delete just first occurrence of given value from a list? Without sorting etc. Something like this: ...
lesobrod's user avatar
  • 1,904
5 votes
1 answer
76 views

Assumptions about indexed variables

I am interested in the most efficient way to impose assumptions on indexed variables. In the following stylized problem, the following code ...
oyy's user avatar
  • 187
0 votes
1 answer
77 views

Using Unevaluated to get a list of symbol names

The official documentation of Unevaluated contains the following example: ...
Shredderroy's user avatar
  • 5,331
5 votes
2 answers
209 views

Slots inside nested pure functions

I'd like /@ instead of Table or Map. But let we have it inside pure function: ...
lesobrod's user avatar
  • 1,904
1 vote
1 answer
59 views

Get FullForm content

For this challenge I need to get FullForm as array, string or nested function. Especially for number expressions. The best I have achieved is: ...
lesobrod's user avatar
  • 1,904
2 votes
2 answers
243 views

How to implement Newton's Identities

I need to produce identities related to Newton's Identities of arbitrary order. More specifically, I need the identities in the following image for an arbitrary n: What I can't quite wrap my head ...
Wynne's user avatar
  • 1,536
4 votes
1 answer
194 views

How to enforce/specify the type of a module local variables similar to the module arguments?

In Mathematica, one can specify the type of a module argument by giving the Head name. I am using type loosely here since Mathematica does not have types. But this does basically the same thing. So ...
Nasser's user avatar
  • 149k

1
2 3 4 5
13