Questions tagged [lazy-computations]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
52 views

Cutting digits of a number without approximation:

I am evaluating an exponential and I end up with the following result: $1.4497788553129478854329$ Is there a command on Mathematica that allows me to cut my result without approximating it? I would ...
15
votes
1answer
248 views

How to use Streaming package in v11.1?

I am trying to use the streaming package for lazy list operations demonstrated in this post. But I found that the package was significantly changed in version 11. After some observations, I found that ...
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 ...
2
votes
0answers
220 views

Does Mathematica has any operators to program like writing lisp macros? [closed]

Lisps use read/eval, quote/syntax-quote, unquote/unquote-splicing and so on to make writing ...
18
votes
7answers
2k views

How to map and sum a list fast?

The following takes a lot of memory and is slow: AbsoluteTiming[Total[Map[#^2 &, Range[1, 100000000]]]] I suspect this is because it first calculates and ...
11
votes
4answers
441 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 ...
1
vote
0answers
50 views

Save a Mathematica notebook evaluated [duplicate]

My notebooks can take some time to evaluate and by quitting Mathematica, I have to reevaluate every definition I've made once I restart Mathematica. Is there a way to tell Mathematica to save the ...
30
votes
1answer
947 views

Efficient lazy weak compositions

In Mathematica all weak k-compositions of integer n can be generated using permutations of integer partitions: ...
10
votes
1answer
819 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 ...
34
votes
2answers
2k views

Is there a built-in equivalent to Python's enumerate?

Python's built-in function enumerate takes an iterable over $(a_0, a_1, \dots )$ as argument and returns an iterable over the sequence of pairs $((0, a_0), (1, a_1),...
17
votes
1answer
1k views

How to Fold over lazy lists and over tasks, just as with Lists?

Many modern languages, such as Haskell, feature lazy lists, which can model infinite sequences of values, albeit synchronously. Lately, the reactive programming movement has shown that asynchronous ...
20
votes
1answer
962 views

Lazy lists of Tuples and Subsets

I'm trying to build a lazy list that evaluates the n'th m-tuple or subset of a given list using Mathematicas ordering without calculating all the Tuples. The purpose is to allow for example the ...
18
votes
6answers
2k views

Permutations[Range[12]] produces an error instead of a list

This input: Permutations[Range[12]] Results in this (error) output: ...
104
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 ...
115
votes
1answer
7k views

File-backed lists/variables for handling large data

Background Currently I am working with some large data (most of it generated by Mathematica itself). I usually find it a hassle to do this. For example, I just exported a large amount of data to ...