Linked Questions

5
votes
2answers
342 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 ...
0
votes
1answer
132 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 ...
112
votes
9answers
5k 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 ...
51
votes
2answers
7k views

Scan vs. Map vs. Apply

I cannot understand the difference between Apply, Scan, and Map. I have tried to play with ...
11
votes
5answers
760 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 ...
7
votes
9answers
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 ...
15
votes
2answers
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 ...
5
votes
2answers
619 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 ...
6
votes
5answers
282 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 ...
3
votes
2answers
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 ...
2
votes
3answers
209 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 ...
3
votes
1answer
223 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 ...
2
votes
2answers
236 views

The i-th element of a permutation [duplicate]

I am trying to run something of the form ...
3
votes
1answer
308 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 ...
3
votes
2answers
127 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 ...