Tagged Questions
10
votes
4answers
481 views
How to write this without For loop
Suppose I have a few lists of numbers and want to exponentiate element-wise, then sum up everything into a polynomial.
For example, if I have
...
0
votes
1answer
187 views
How can I improve my code with efficient mathematica built-in functions?
I have written a module for my assignment like below.
V[n + 1] = rk[x[n], y[n] ,z[n], V[n]];
vs = V[n].V[n+1];
V[n + 1] =
I want to modify it with efficient ...
14
votes
3answers
407 views
How can I improve my code for drawing a tree?
This code draws a tree, but it's not in the functional style.
...
7
votes
3answers
321 views
Rewriting For loop to FoldList or similar
In CrossValidated, the answer to a question on prediction of number of viewers of Gangnam Style is given in R. I have mapped the answer directly to Mathematica:
...
12
votes
5answers
553 views
How to improve this code for solving the “Mr.S and Mr.P” puzzle?
Mr.S and Mr. P puzzle — "Formalization of two Puzzles Involving Knowledge", McCarthy, John (1987)
We pick two numbers $a$ and $b$, such that $a\geq b$ and both numbers are within
the range ...
4
votes
3answers
270 views
6
votes
0answers
110 views
What are some general strategies to avoid using For loops? [duplicate]
Possible Duplicate:
Iterating over lists in Mathematica
While there are some cases where a For loop might be reasonable, it's a general mantra – one I ...
2
votes
3answers
134 views
Using Nest inside NestList
I need results like this:
{Cos[Cos[x]], Sin[Cos[Cos[x]]],Cos[Cos[Sin[Cos[Cos[x]]]]],
Sin[Cos[Cos[Sin[Cos[Cos[x]]]]]], ... }
I've tried to use ...
13
votes
3answers
178 views
How to keep some of the results of the NestList
I'm using some iterative arithmetics to calculate wave propagation with the help of NestList. I have to use a small step size for iteration to guarantee the accuracy, which lead to too much data (e.g, ...
8
votes
2answers
173 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 ...
16
votes
2answers
561 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 ...
11
votes
2answers
378 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 ...
15
votes
1answer
216 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 ...
21
votes
6answers
854 views
Can this be written well, without loops?
Inspired by this question I would like to know if the following code can be written without explicit loops (For, While, etc.) in a clean, efficient and non-contrived way. I have been unable to do so.
...