Linked Questions

525
votes
19answers
130k views

Where can I find examples of good Mathematica programming practice?

I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't ...
105
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 of lazy ...
15
votes
5answers
986 views

Getting number of binary digits combinations without “forbidden” patterns

I need to get the number of all combinations of binary digits in an 8-digit binary number, but not including those that follow some "forbidden" patterns like these: ...
11
votes
4answers
445 views

Lazy form of Tuples/Outer to loop over list of lists

This is less a question and more asking if someone has implemented this already, with more skill. I need to perform the Outer-like generalized outer product of a ...
10
votes
1answer
830 views

Alternative to Subsets to generate k-combinations

I need to generare a huge number of k-combinations for a quite big set of numbers (more than 100), so I would avoid Subsets because it requires too much memory (it generates all subsets at once). I ...
5
votes
1answer
498 views

Problem with creating a large list of tuples

This is a follow-up question from Sum of Multinomial Coefficients I have thought about the meaning of the formula I mentioned and, with help, I implemented the following code: ...
3
votes
2answers
162 views

How to generate a limited number of tuples of a list and not all?

I have a question for which I couldn't find an answer: how can we generate only a given number of tuples of a list and not all of them? For instance, I want to have only the first two 3-tuples of <...
2
votes
1answer
133 views

Consecutive generation of subsets [duplicate]

It is well known that the array of subsets of even small set is very big. This leads to problems with machine memory. Is there an effective way to generate subsets sequentially?
3
votes
0answers
59 views

Lazy tuples made from arbitrary lists [duplicate]

I am dealing with Tuples of n lists each having potentially different length: longList = Tuples[list1, list2, ..., listn]: Since I have to iterate over the ...
1
vote
0answers
50 views

Mathematica breaks [closed]

I write the following command. After running for seconds (less than a minute), Mathematica breaks and nothing is displayed. Why? a = Tuples[{1, I, -I}, {1, 20}] ...
0
votes
0answers
49 views

How to get partial results from Subsets[]? [duplicate]

Oftentimes I am searching for the first item in a sequence that satisfies some property. For example, consider the subsets of prime numbers whose total is prime. To start generate them, we could ...
0
votes
0answers
46 views

Sequentially generate elements of Mathematica-generated list

Mathematica has a number of built-in functions that generate lists, such as Permutations. Is there is universal way to generate only portions of these lists at a ...