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

learn more… | top users | synonyms

10
votes
1answer
365 views

How to visualize pattern matching process?

I want a function that does the same job like ReplaceRepeated, and can make the matching process visible. I searched the Internet but didn't find any existing code ...
1
vote
1answer
118 views

Using FindMinimum with matrix input

I define the following function which spits out a number S when I feed it a dxd square matrix: ...
0
votes
0answers
56 views

Using NestList instead of Do [duplicate]

How can I express the following code using NestList: ...
10
votes
1answer
172 views

Copy Built-in function to new name

It is know that some built-in functions are system function and changing their properties may cause trouble. Suppose for example I want to change features of Cases: ...
4
votes
3answers
235 views

Manipulate: How to create custom reset Button automatically?

I have a complex Manipulate with more than 10 controls. Each one has its own default value. I'd like to add a custom button in the control area to reset all ...
14
votes
2answers
436 views

I define a variable as local to a module BUT then the module uses its global value! Why?

I have a question about modules and local variables. Here's my example: h = 5; Module[{a, h}, a[h_]= h^2; a[4]] (*Out[2] = 25*) I expected the module to ...
17
votes
1answer
382 views

Confused about how Partition works

I have a problem about the padding list about Partition command. For instance, ...
4
votes
1answer
120 views

ControlType -> None Vs. Module inside Manipulate (i.e. making everything local)

I'm building a program on another one made available in the Wolfram Demonstration Project. I've noticed that in the original code (working flawlessly) many variables were made local inside the ...
0
votes
1answer
267 views

How do I write nested for-loops?

Looking through the reference.wolfram, I couldn't see an example of how to write a multiple line "for" loop in Mathematica. I need to nest many for-loops in such a way I can do many things in the ...
5
votes
2answers
404 views

Code elegance and compactness. Help needed with Map, Apply

I need some help with code optimization and compactness. I have a set of two-dimensional points and I can use the Mathematica function FindClusters to find 4 clusters. I'd like to plot the points ...
2
votes
0answers
67 views

What was the thought behind the parallel versions of Table, Map, etc..?

There separately named versions of the parallel analogues of Map[] and friends: ...
1
vote
1answer
84 views

Computing a Sequence using Recurrence

I posted a similar question earlier today, but unfortunately I realized after several hours that I over-simplified the problem for this forum. There is a very good answer to the Computing a sequence ...
2
votes
3answers
122 views

Computing a sequence by recurrence

I am trying to create a list where each element of the list is calculated using the sum of all previous elements of the list and also uses the $N$th element of another list. The initial value of the ...
21
votes
3answers
526 views

Real Numbers in the Wolfram Language

Epilog: Much of the discussion in the answers below revolves around the distinction between Real as a data type and real numbers as a domain or class of numbers (irrespective of the form in which ...
2
votes
2answers
103 views

DictionaryLoopkup - pattern specification

I would like to find all Italian words that have a specific pattern of letter repetitions. Actually I'm looking for 6-letters words that have 1 letter repeated 3 times, a second letter repeated two ...
3
votes
1answer
196 views

How can I trans-compile Mathematica into another language?

I'm looking for an exhaustive list of source-to-source compilers to all other languages, if any exist that is.
5
votes
1answer
103 views

Changing the definition of N: unexpected $RecursionLimit::reclim error

I have some objects represented as follows: Object[data, param] data is a list of numbers, ...
14
votes
3answers
212 views

How do I understand ListCorrelate(contains $\{k_L,k_R\}$) when it works for 2-dimentional data?

Two months ago, I asked a question here And @nikie give me a solution: The intuitive way to understand ListCorrelate is that the kernel is "moved" to every ...
4
votes
1answer
41 views

How to find out which definitions use Temporary symbol?

According to the Documentation, Symbols with attribute Temporary are automatically removed when they are no longer needed. For example: ...
1
vote
0answers
73 views

Concise way to express Table[FactorInteger[300][[n, 2]], {n, 1, Length @ FactorInteger[300]}]

I can get the exponent part of FactorInteger[300] with Table[FactorInteger[300][[n, 2]], {n, 1, Length @ FactorInteger[300]}] ...
19
votes
1answer
355 views

Why some built-in functions are slow

I just wonder why some built-in functions are slower compared to some other ways using more than one built-in functions for doing same job. consider this example: ...
3
votes
2answers
103 views

MapThread problem

I would like to do the following: ...
4
votes
0answers
83 views

Unexpected behavior from Indexed

I was going to include Indexed in this answer, thinking that it operated much as a List-only ...
0
votes
1answer
63 views

What does this Append expression do? [closed]

I have to understand some code. A part of it is written below. Can someone explain to me what it does: ...
9
votes
2answers
124 views

DownValue assignment using Apply

Why does assigning a DownValue using Apply, e.g., ...
9
votes
6answers
375 views

Product of elements of a list

Sum is for functions; Total is for a list. Product is for a function; what is the command ...
2
votes
0answers
31 views

How exactly does ReplaceAll work? [duplicate]

I am not sure if this question has been asked before but anyway, Consider these two examples: ...
0
votes
0answers
94 views

Solution of a set of quadratic congruences (Chinese remainder)

Edit: Please remove this question. I think there are mathematics error in what I am asking. You are welcome to edit the question if you can state the problem correctly. I have a set of quadratic ...
5
votes
4answers
199 views

Signed power set of a list

Given {a, b, c, ...} with $n$ elements generate a list with $2^n$ elements. For example, if the list were {a, b, c}, then the ...
5
votes
2answers
152 views

Non sequitur in documentation of MemberQ

Mr.Wizard's question about MemberQ and FreeQ got me to re-read the documentation for those functions. I find I don't understand ...
16
votes
1answer
181 views

A bug in the overloading of MemberQ and FreeQ for Association?

Bug introduced in 10.0.0 and fixed in 10.1.0. While answering Pattern match for nested Association I came across behavior of MemberQ and ...
0
votes
1answer
78 views

Association of pure functions [duplicate]

I've encountered confusing behavior of Association when I try to use it for storing pure functions. For example: as = <|"1" -> # + 1 &|> ...
10
votes
5answers
556 views

Postfix Double Slash Notation with Multiple Parameters [duplicate]

Examples A convenient shorthand that I use frequently is the "double slash" notation to string commands together. For example, I can write: ...
2
votes
1answer
314 views

Dynamic graph construction and visualization (Watts' “Small Worlds” α-model)

I need some help in creating a Mathematica program for building and visualizing Watts' "Small Worlds" α-model. This is a variant of the more known (and much more simple) β-model (also known as ...
12
votes
2answers
247 views

How to restore function attributes to default

Adding an attribute to a function is easy and clearing attribute is easy also. But I don't know really how to restore the attributes of a function to its defaults. All I do is quit the kernel or close ...
3
votes
1answer
317 views

How to use Mathematica for traditional programming

I am new to the structure of Mathematica. I understand that in the notebooks, one enters the symbolic expressions and evaluates them. But I need to generate some simulated data and do that a few ...
7
votes
1answer
215 views

Why can't a string be formed by head String?

Since everything is an expression in Mathematica, why must a string object be formed by "abc" but not by a String[abc] ...
2
votes
3answers
179 views

How to test for Indeterminate values?

I need something like this a = 101010/0; If[a == ComplexInfinity, True, False] But if I use ToString, I get what I want. ...
6
votes
1answer
194 views

Taking the derivative of a function with indexed variables

I have a number of functions that depend on a variable x. I am using a second, integer variable to index these functions, i.e. something like ...
1
vote
1answer
47 views

Strange behaviour of Set and Part when given a sequence

Consider this example: lis1 = {a, b, c}; lis1[[2]] = Sequence[e, f]; lis1 (*{a, e, f, c}*) lis1[[2]] (*e*) lis1[[2]] = Sequence[g, h]; lis1 (*{a, g, h, c}*) It ...
3
votes
3answers
144 views

Pick bug? level 0 matching

A previous discussion of this issue (Is there a bug in Pick?) accepted that matching at level 0 is not a bug in Pick. Was that correct? I am not yet persuaded. ...
4
votes
1answer
100 views

How to define a formula in FormulaData?

I am looking for a way to manage frequently used formulas in my research, in a organized way in Mathematica. It appears to me that using FormulaData would be a ...
7
votes
6answers
442 views

How to build a list of functions

Having said that I'm no expert, I have some problems in generating a list of functions inside a loop. The functions in the list should depend on the elements of a parameters list, that are read in ...
14
votes
1answer
210 views

Why won't SparseArray let me store values with the head List?

When you attempt to define a SparseArray with elements that have the head List it complains: ...
1
vote
1answer
63 views

Why does WordData fail to find “PartsOfSpeech” when given a list of two words?

I have the following sample code. StringSplit["a test string", " "] Thread[WordData[%, "PartsOfSpeech"]] The output I get is: ...
4
votes
1answer
204 views

How to see abstract syntax tree of Wolfram Language expression

I mean, suppose I have this expression: 2 + 2 I want to get something like this: Plus[2, 2] as an output. I've tried FullForm, but this just evaluates 2+2 and returns 4. Is this even possible?
10
votes
2answers
346 views

When must I use the Return function?

In a comment to my answer to this question, QuantumDot asks, "Where can I find more information on when I must use the 'Return' function?". I found this too deep a question to be answered by leaving a ...
47
votes
1answer
1k views

Incompatible Changes since Mathematica Version 7?

There is documentation of the incompatible changes made to Mathematica with each major release: Incompatible Changes since Mathematica Version 1 Unfortunately that documentation simply stopped ...
23
votes
2answers
502 views

Why is Query so much slower than Part?

Time for another of these(1),(2) as yet another new-in-10 function appears to have poor performance compared to older alternatives. This time: Query appears to be ...