# Tagged Questions

Questions on writing non-trivial programs in Mathematica. Do not use this tag for questions on plotting/graphics or for questions on doing mathematics with Mathematica, where the focus is more on the math than the program.

4answers
1k views

### Question about collections of custom GUI controls for Mathematica

Background: I have only recently begun programming GUIs in Mathematica, so I have a continuous need for custom controls. I needed a scrollable list control and with the help of Google I found a ...
1answer
355 views

### Using Apply inside Compile

In this great answer a compiled version of the Nelder-Mead algorithm is presented. Since it works on arbitrary dimensions (i.e. arbitrary number of arguments), it has to use apply on the objective ...
1answer
257 views

### How to avoid conflicts between local variable names and symbolic arguments in Block constructs?

I am using Block inside the definition of some recursive functions. If the Block definitions use short variable names, like ...
1answer
1k views

### Iteration of a function

I have a function $f(x)=x^7+k$ I want to iterate $xn+1=g(xn)$, 50 times starting with $x0=1$ and keep the last 10 values I want to assign these values to a function ...
3answers
611 views

### How can I suppress Print in parallel evaluation?

When using a function that includes Print statements, one can suppress the output by ...
1answer
376 views

### Is pure pattern matching without PatternTest and Condition Turing-complete?

Note that this question is not a duplicate of that one. It is specifically about the pattern-matching engine, and explicitly excluding those patterns which call back into the full evaluation (i.e. ...
2answers
1k views

### Is Mathematica a Turing-complete language?

Is Mathematica a Turing-complete language? If so, how can that be proved? If not, why?
2answers
417 views

### What is the equivalent of a prototypical Manipulate in lower level functions?

Background: In the Mathematica tutorial 'Dynamic Interactivity' I read that there is a way of developing GUIs in Mathematica that do not use Manipulate. I want to ...
1answer
335 views

### How can I add row and column header images to my TableForm output?

I am experimenting with the Eigenfaces algorithm and have my notes and experimental data collected in a Mathematica notebook. The result of an experimental run is a table of scores, where the smallest ...
2answers
212 views

### Speed up Fourier for Booleans

I'm calculating a bit of the power spectrum of a two color cellular automaton using: ...
3answers
524 views

### Dealing with nested options

OptionValue allows for recent versions of Mathematica (I think as from 7) to easily access optional parameters if they are explicitely given to a function or their default values otherwise. For big ...
3answers
901 views

### Mathematica usage (success stories) for financial back-ends

I've been working for about 5 years in Java, developing financial back-offices (web-services, business logic, report generation etc.). I think Mathematica is very suitable for such calculations and ...
2answers
777 views

### Developing domain specific languages and computational knowledge engines using Mathematica

In one of Leonid Shifrin's excellent summaries, he mentioned that MMA capabilities include developing Domain Specific Languages (DSL). I'd like to develop a Health care IT application that can ...
5answers
12k views

### How to use Mathematica functions in Python programs?

I'd like to know how can I call Mathematica functions from Python. I appreciate a example, for example, using the Mathematica function Prime. I had search about MathLink but how to use it in Python ...
1answer
442 views

### How to solve a problem in relative motion?

I have a project due tomorrow that I have been struggling with for a month. I am utterly stumped, any help would be appreciated. The problem is: There is a ferris wheel, 30m in radius, set 80m ...
2answers
2k views

### Open Excel file with Mathematica

I would like to open an Excel file and manipulate it as a COM object. While I'm able to open an instance of excel with ...
1answer
185 views

### Figuring out how AbsoluteOptions works with Graphs

I am puzzled by how AbsoluteOptions works with Graph objects. I would have expected that one could use it to obtain all the ...
1answer
99 views

### How to take several values out of a large expression?

Background: Consider the following graphics directive. ...
2answers
15k views

### Is there an open source implementation of Mathematica-the-language?

I've seen questions before such as "What is the best open-source equivalent for Mathematica?", but that specific question (and that line of inquiry in general) cares more about the computer algebra ...
2answers
97 views

### How do Forms affect the interpretation of Expressions?

Below are three formats for representing an undirected edge between vertices a and b: ...
1answer
530 views

### Can a Table iterator “leak” into a Module?

I want to repeatedly call a module by using a Table statement. When I use an i iterator in the Table command calling the module, I receive the error message ...
1answer
325 views

### Why does Mathematica choose the second function definition?

While working on a solution to this question I've come across a case where I simply don't understand Mathematica's behaviour. I've got the following definitions: ...
1answer
840 views

### What is the proper method to load a Mathematica package inside a DynamicModule

I have a DynamicModule that requires loading of Mathematica packages. The usual methods do not seem to apply (...
4answers
1k views

### Is there a Mathematica/Lisp link?

I'd like to start learning Lisp as it sometimes leads to interesting answers on this site with concepts borrowed from this language, so I'm curious. As I already spend most of my programming time in ...
2answers
471 views

### When should I, and when should I not, set the HoldAll attribute on a function I define?

I have seen a number of examples on this site (such as in syntax highlighting and checking evaluation status) in which functions definitions are preceded with ...
4answers
1k views

### Finding a “not-shortest” path between two vertices

In designing a routine for making a simple three dimensional (5x5x5) labyrinth, I realized that my solutions (a solution is a labyrinth includes a single path from {1, 1, 1} to {5, 5, 5} in a 5 x5x5 ...
1answer
507 views

### GeoDirection and GeoDistance Memory Leaks: How to Recover the Memory?

Bug introduced in 7.0 and fixed in 9.0.0 The functions GeoDirection and GeoDistance have memory leaks. To see this, run the example functions below and watch as the Physical Memory Available in ...
1answer
479 views

### Mathematica implementation of Earth Movers Distance?

Has anyone implemented in Mathematica the Earth Mover's Distance (EMD)? A concept dating back to Monge 1871, used to compare histograms and images, e.g., the CIEDE2000 Color Difference algorithm. ...
2answers
304 views

### Cases[data,Colon[key,_]] vs. Cases[data,key:_] toward XPath, XQuery

Exploring methods to index and search tree-structured key:value pairs via named-entity index (key paths) as opposed to Position-based indexing. Using Rule as ...
2answers
268 views

### Repeatedly randomly redrawing part of a random sample that matches a certain criterion

I would need some (a lot of) help to improve/rewrite some code. Since my real problem is a bit too complicated to explain, I'll try to show a simplified scheme of what I want to achieve. I create ...
2answers
545 views

### Abort not aborting

I have a relatively simple bit of code that looks like the following: ---some code here--- If[statement, Abort[]]; ---more code following--- However, while ...
1answer
793 views

### Modifying a List in a function in place [duplicate]

An example will be most specific: func[list_, column_] := list[[All, column]] = Map[#*2 &, list[[All, column]]]; This throws errors. I want to avoid doing ...
3answers
3k views

### What is a Mathematica packed array?

A simple sounding question with a few sub questions: What is the difference between unpacked vs packed array? Are packed arrays more space efficent, how much so? Are packed arrays more time ...
3answers
1k views

### Does every Symbol in Mathematica induce a monad?

From my question about types in Mathematica, I assume that every Symbol in Mathematica is a type if it appears as a Head of some ...
4answers
2k views

### What is a type in Wolfram Mathematica programming language?

"Everything is an expression" is a popular citation from many Mathematica guidebooks. So, what is type in Mathematica? How does it relate to common types from Haskell, for example? I did some ...
5answers
804 views

### How do I generate the upper triangular indices from a list?

I have some list {1,2,3}. How do I generate nested pairs such that I get {{1,2},{1,3},{2,3}}? That is I'd like a way to ...
3answers
1k views

### Reading from STDIN, or: how to pipe data into Mathematica

Today I tried using Mathematica's plotting capabilities to display the output of a C++ program. This made me wonder whether it is possible to somehow tell a Mathematica script to read from STDIN and ...
3answers
882 views

### Is there a convenient way to copy/paste text-interspersed SE code snippets into Mathematica?

Is there a way to copy and paste code snippets from SE to Mathematica if these snippets are interspersed with text? Like e.g. in Morphing Graphics, color and location in both the question and answer, ...
1answer
329 views

### Path queries for tree-structured data

Can anyone suggest documentation or tutorials for developing path queries and indices for (XML-like) tree-structured data? Suppose data is organized hierarchically in key->value pairs, eg: ...
1answer
1k views

### Handling failed FindRoot calls

I want to handle FindRoot calls which did not converge (e.g "thrown" error message FindRoot::cvmit) ...
2answers
1k views

### Using a list of tuples in a pure function

I want to use a list of tuples within a function to make assignments. Say I want to make assignments of the form value[i,j] = val What I have is a list of ...
3answers
3k views

### Basic questions about running Mathematica

Is there a command window and an editor in Mathematica 8 similar to those in Matlab? In Mathematica GUI mode, all I saw is write code and run it in the same notebook. In my Ubuntu terminal, I ...
1answer
511 views

### Importing Zip files

Mathematica can import zipped files automatically, but when the content of the zip file it's another zipped file, I just get the list of files in the second zip: ...
1answer
3k views

### Programmatic formatting for Mathematica code - possible?

It seems to be both an interesting programming challenge and a very useful practical application to have a Mathematica program which would allow one to pretty-print Mathematica code, so that it is ...
2answers
522 views

### Listing subgraphs of G isomorphic to SubG

If I have an undirected graph G, how could I write a function in Mathematica to obtain a list of subgraphs of G that are isomorphic to some other undirected graph SubG? I'd like to learn how to ...
1answer
402 views

### Are there advantages to using additional arguments of common functions rather than alternative ways of calculating with lists?

(Apologies for the long question title.) One of the interesting, if sometimes confusing, things about Mathematica is that there is always more than one way to do things. Even intermediate users can ...
3answers
2k views

### Cycles of length N in a graph

If I have an undirected graph represented with an adjacency matrix, how can I find all the subgraphs which are a cycle of length N? I don't really know the math nor the programming language well, so ...
1answer
402 views

### How to match two sets of data over 1 or more identifier, of unequal length?

Brief Question about how to best match lists with Criteria from Identifiers (thus for me: translate SQL to Mathematica ;) ). If I have two sets: ...
7answers
423 views

### How to efficiently Append a result of an operation on each element of a list to itself

I'm looking for the best function to apply the product of the last two elements of sublist elements to each element: Example: ...
5answers
5k views

### What does the construct f[x_] := f[x] = … mean?

This question mentions "x := x = trickery". What does defining a function as f[x_] := f[x] = ... do and what is it good for?