Questions on using or implementing more or less common data structures such as linked lists, structs, trees, tries, heaps etc. in Mathematica.

learn more… | top users | synonyms

0
votes
0answers
37 views

Data structures in mathematica for choosing permutations

I am trying to classify permutations of n, in this case n=6, elements depending on the cycles that contian the points 1 and 2, since these are considered to be special points. So for example, I will ...
3
votes
1answer
67 views

Dealing with a large number of optimizations performed with parameters read in from a CSV file

I have a large CSV file (1.5M rows), with each row containing a set of parameters that I need for an optimization routine in Mathematica. I'm hoping to import the data, run the computation, and then ...
0
votes
1answer
55 views

Manipulation of imported Datafile

Since I am solving a differential equation in a for loop with NDSolve ...
21
votes
2answers
799 views

Efficient priority queues?

I'm trying to figure out how to transfer the concept of a priority queue to the functional world. Searches have turned up some implementations that use Append and other expense list copying techniques....
2
votes
0answers
39 views

How to implement shared data structures?

If I have a shared data structure like you would find in nested C structs, how would I best implement that in Mathematica? I have some "object-oriented" code I would like to port to Mathematica. It's ...
7
votes
1answer
50 views

KaryTree of Text .csv and Correlation

How can I make a KaryTree of this raw-data (raw-data at the end of the question): This is is data from a political survey in which I ask 5 questions with the following possible answers: Q1: 'Y'= ...
42
votes
3answers
3k views

How can I add a column into a existing Dataset?

I'm very excited about the brand new Dataset function. I have played with it in Wolfram Cloud, and haven't figured out how can I add a new column into an existing <...
2
votes
0answers
45 views

How to use a picture to store some data [duplicate]

As we know.The values of the types is "Real" defaultly in Mathematica.In the Image documentation's detail we can see Image[...
3
votes
1answer
107 views

Immutability, Association and typing

I have read the article by Leonid on the question. I am still struggling. I am trying to use Association to inject some pseudo-typing in my code. Here is my ...
1
vote
2answers
62 views

Creating Association [duplicate]

I have provided a dataset bellow and I would like to store the data as an Association that I can query. Such that e.g. ...
0
votes
0answers
23 views
10
votes
2answers
262 views

Is there a method to enumerate the keys/values of System`Utilities`HashTable

Lacking from the simple API of System`Utilities`HashTable is a method to enumerate the keys/values. ...
110
votes
3answers
6k views

How to make use of Associations?

I have been curious about it for long. Now that Mathematica 10 arrives, I think it's time to ask the question: How the new Association data structure would be used ...
2
votes
2answers
85 views

Merge two trees into a rectangular matrix in Mathematica

How can I merge two trees, t and s, so as to form a square matrix below, where both trees starts from top-left (as shown), and ...
10
votes
7answers
267 views

Extract left-upper triangular data from a square matrix-form list

Hopefully, this question is not too basic or obscure. I'd like an idea on how to extract this {{1}, {5, 2}, {9, 6, 3}, {13, 10, 7, 4}} from ...
4
votes
0answers
53 views

How to transform a tree-form list to matrix-form list in Mathematica? [closed]

Excuse my naive question. Is there a quick/efficient way to transform {{1}, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}} to a lower-triangular matrix-form ...
1
vote
1answer
116 views

Fitting multiple peaks

I am using the code found here to fit multiple peaks of a large dataset which I don't know anything about. This was the only code I could find on the internet to do such a thing. So this is my attempt ...
14
votes
3answers
5k views

Implementing a dictionary data structure

As one learns from a course on data structures, hash maps or dictionaries can be efficient when applied to appropriate tasks. I need a hash map in Mathematica and I've never found it. I'm scratching ...
0
votes
1answer
158 views

How to fit multiple Gaussian peaks to data [duplicate]

How would I fit this data with Gaussian Peaks? I have tried various codes but none have even worked. Note: If I do Log[data], the peaks are more visible (I have tried the method from here but it got ...
0
votes
0answers
21 views

Remove background from multipeak data [duplicate]

Let's say I have a a very large list of data in the format {{n,f[n]}} so something like {{1,600},{2,700},{3,1100}...} and if this data is plotted, then it will look like a sum of Gaussian functions+a ...
1
vote
0answers
33 views

Repeat code segment from certain cell [closed]

If I have a lot of code and wish to repeat it in a different cell, but with some variables changed, how do I do it? (without copying and pasting) I tried using GoTo and Label but it did not recognize ...
73
votes
3answers
3k views

What is a Mathematica packed array?

A simple sounding question with a few sub questions: What is the difference between unpacked vs packed array? Are packed arrays more space efficent, how much so? Are packed arrays more time ...
1
vote
1answer
141 views

Resampling Data using Temporal Data

I am having a problem using TemporalData. I am simulating a two state system, and every time the system goes into a new state (which happens randomly), then I put ...
2
votes
0answers
56 views

Arrays with two different types of indices

Is there a way of having arrays which have, so to speak, two different depths $m,n$? From the point of view of memory usage, it would be the same as an array of depth $m+n$, but I would like to ...
1
vote
1answer
118 views

Turning table into association for Classify

I have the following sample data for 20 users. I know their sex, and the response for three yes/no questions. I am trying to building a classifier to guess their response to the third question, based ...
1
vote
2answers
139 views

Short way to query Dataset by the value of several columns

I learned how to query Dataset for rows that contain a certain value, but now I need to query for a long series of And in chain ...
24
votes
4answers
589 views

How to get complete Documentation Center graph of guide pages?

On the very last image below you can see a typical path of walking through Documentation Center guide pages. What is the best way to get the graph data and visualize the whole structure of these ...
5
votes
3answers
353 views

Selecting numbers from a list

If I wish to select numbers which are greater than 2 or less than 1, I use the following codes respectively: ...
94
votes
1answer
5k 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 ...
27
votes
3answers
1k views

Error changing Dataset using Part

Update It was a bug in the documentation of V10.0, this functionality was not implemented yet, and V10.1 changed the documentation, removing it. It's a pity, because it's a very useful operations, ...
25
votes
2answers
770 views

Dataset vs an association of associations

Associations with a record structure (e.g., a flat table) can be organised in one of two main ways. First as a list of associations, which is also used in the case of Mathematica's data set ...
15
votes
3answers
901 views

Converting hierarchies of rules to associations

The impossibility of MatchQ-ing inside and Association MatchQ-ing Associations (MMA 10) explains a problem I have. I would like ...
1
vote
0answers
109 views

Custom Head for Encapsulation

Often when I'm writing a project in Mathematica, the number of arguments I must provide to functions spins out of control. I need a sort of object-oriented encapsulation approach. I've already had a ...
1
vote
0answers
239 views

Integration of graphs with datasets

Mathematica has a rich family of graph algorithms. I would like to leverage some of these for a very large tree structure. Because of the size of the structure, I would like to store it in a Dataset ...
2
votes
0answers
106 views

AVL binary search tree implementation

Is there any text-book implementation of self-balancing binary search trees such as AVL or red-black in Mathematica?
17
votes
1answer
277 views

Why do lookup times in Dataset and Association differ by orders of magnitude?

Consider the following three data structures: a list of rules, an association, and a dataset: ...
0
votes
1answer
129 views

Import and export without changing number format

I have a complex file that is the output of a program. The file contains multiple columns with data in different number formats. For example: ...
3
votes
0answers
119 views

Does Mathematica support an unordered set (e.g. hashset) data structure?

Does Mathematica support any data structure representing an unordered set (without multiplicity) of Mathematica expressions? I would like this data structure to support $O(1)$ insertion, deletion, and ...
2
votes
0answers
58 views

Does Mathematica support out-of-core Associations?

I often find myself collecting data in an Association[] which outgrows my computer's main memory. Does Mathematica support any out-of-core equivalent? Ideally, I ...
3
votes
2answers
198 views

Entropy of the elements of a general data set

I have the following data set, and wish to track the evolution of the entropy of each element within the set. I have evaluated the entropy for some elements, but how does one evaluate the entropy of ...
15
votes
1answer
277 views

Why won't SparseArray let me store values with the head List?

When you attempt to define a SparseArray with elements that have the head List it complains: ...
23
votes
5answers
718 views

How can a big table be treated as a database?

I often work with big tables that I want to treat kind of like a database. Here's an example table. ...
91
votes
7answers
10k views

Struct equivalent in Mathematica?

I really miss having something like a struct in Mathematica. I know of (and regularly use) a couple of programming techniques which feel like a ...
2
votes
1answer
152 views

ordered tree data structure

I have a map $f:X\to \mathbb{N}$ and I wish to find $x,x'\in X$ such that $f(x)=f(x')$. Since such elements are rare, I will have to check very many elements and perform many comparisons, so I suspect ...
4
votes
1answer
145 views

Parsing string with nested information

I am trying to parse a string, but I have no idea how to solve the following problem ...
5
votes
2answers
476 views

How would I programmatically add a row to a Dataset?

I would like to use a Dataset to track the process of a lengthy calculation over a large volume of material. Dataset appeals to me because of the power of the queries and it also looks like it may ...
5
votes
1answer
165 views

Filtering Query Nested Data (Dataset and Association)

I am trying to filter a nested Dataset. I have some data that looks like this (curated for this example): ...
30
votes
2answers
1k views

Can a Trie be implemented efficiently?

What is the most space and time efficient way to implement a Trie in Mathematica? Will it be practically faster than what is natively available in appropriate cases?