Linked Questions

5 votes
2 answers

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

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
  • 25
116 votes
9 answers

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,413
52 votes
2 answers

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,834
11 votes
5 answers

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

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
14 votes
2 answers

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.4k
5 votes
2 answers

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
  • 32.9k
6 votes
5 answers

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

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

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

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,285
2 votes
2 answers

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

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

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