Linked Questions

5 votes
2 answers
438 views

Short circuit logical operators [duplicate]

Suppose I want to compute $f(1)\vee f(2) \vee \ldots \vee f(10^{10})$, but I know a priori that $f(n)$ is True for some $n \ll 10^{10}$ with high probability. For ...
Kevin's user avatar
  • 267
0 votes
1 answer
140 views

Selecting 1st $n$ elements meeting criterion from very long list [duplicate]

I need to select n elements from a list, which satisfy a condition. I need something like ...
32seph's user avatar
  • 35
118 votes
9 answers
6k views

Functional style using lazy lists?

Let's say I want to answer the question "what are the first 400 palindromic prime numbers?" The first approach that comes to my mind from the set of languages that I know is to use some sort ...
sblom's user avatar
  • 6,483
52 votes
2 answers
8k views

Scan vs. Map vs. Apply

I cannot understand the difference between Apply, Scan, and Map. I have tried to play with ...
MOON's user avatar
  • 3,886
11 votes
5 answers
804 views

How to find first list element that differs from average of N previous elements by more than a given amount?

Given a list of real numbers, I need to write a function that returns the value of the first element in the list that differs from the mean of the previous $N$ elements by greater than $P$ standard ...
Tom Dickens's user avatar
7 votes
9 answers
1k views

Find the smallest positive integer that satisfies a certain condition

I know Mathematica is really powerful when it comes to functional operations like applying a list of tasks to a list of variables. Sometimes I feel like it isn't the most powerful tool when it comes ...
cartonn's user avatar
  • 1,005
15 votes
2 answers
3k views

Is there a Break[] equivalent for short-circuiting in Table?

I am running Mathematica 7. The following is admittedly a silly example, but suppose that I have a list list whose entries are either ...
Andrew's user avatar
  • 10.5k
5 votes
2 answers
678 views

Storing result from nested Table in a File for further computations

Consider the following: Table[Table[x = 20; y = 30; 2 i x + 3 j y , {i, 10}], {j, 3}] Suppose I want the result of this nested Table to be stored to an ...
RunnyKine's user avatar
  • 33.3k
6 votes
5 answers
295 views

On reimplementing the Select function [duplicate]

I am working through the course Programming Paradigms via Mathematica. One of the exercises asks that you construct a function that mimics Select,even with three ...
Clif's user avatar
  • 687
3 votes
2 answers
2k views

Need to create a function to generate all permutations of Range[$n$] [duplicate]

Basically I need a function that takes a list and gives all the possible permutations of it. The reason I can't use Permutations is that I have to apply another ...
Ryan Summers's user avatar
2 votes
3 answers
239 views

Finding primes that have certain property

Let S[p] denote the sum of digits of p. A prime p is said to be stubborn if none of ...
user116988's user avatar
3 votes
1 answer
272 views

Finding pairs where the intersection of them is empty set from a nested list

It would be better to give an example first. Suppose I have a nested list of the form list = {{ 1,2,3,6}, { 3,6,10,20}, { 4,7,11}, { 10,20}}; where each element ...
Sungmin's user avatar
  • 2,305
2 votes
2 answers
244 views

The i-th element of a permutation [duplicate]

I am trying to run something of the form ...
Heterotic's user avatar
  • 306
3 votes
2 answers
167 views

How to generate a list from an iterator and some arbitrary function

Suppose I'd like to generate a table of integers: Table[i, {i, 10}] Great; now suppose I want only the integers that are even ...
Noon Silk's user avatar
  • 523
3 votes
1 answer
333 views

Writing this loop in Mathematica

OK, so I've never had to write a line of Mathematica code (except for using it interactively as a calculator), but for this it looks like I have to. If someone could provide me with the code for the ...
eof's user avatar
  • 65