# Questions tagged [data-structures]

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

197 questions
Filter by
Sorted by
Tagged with
92 views

### Need explanation on data[[i]][[1]]

I am trying to train a physics model and then check its profile. For this model, data for physics model is defined with: ...
487 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: ...
1k 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 ...
223 views

### List structure transformation

How to transform a list as {{x,y},{a,b,c,d,e}} into the form of {{x,y,a},{x,y,b},{x,y,c},{x,y,d},{x,y,e}} elegantly, ...
400 views

### Using DataStructures in FunctionCompile

This is a follow up to this StackExchange question I am trying to do the equivalent of Select on a "FixedArray" data structure. Here is what I have tried so far: ...
59 views

### Interpolation function for data with repeating independent variable

I want to find an interpolation function for data in which the x-variable is repeated (example below). The repetition in data is natural and cannot not be eliminated. Can I somehow use ...
146 views

### Building matrix from relational data

I'm new to Mathematica, coming from Python, and I'm having a hard time trying to build a matrix from relational data. The data looks like this: ...
109 views

### DataStructure's "DynamicArray" underperforms Association?

The documentation for DynamicArray states that it is "An extensible array is useful for continuously appending elements, as well as for efficient element extraction and updating." I tried a ...
1 vote
73 views

### Contour plot data extraction and replacing z slices with user defined function

Let's say we have a contour plot of the following, ContourPlot[Cos[x] + Cos[y], {x, 0, Pi}, {y, 0, Pi}, ContourLabels -> True] that gives, we can extract the ...
60 views

### Long associations of short associations or the inverse, which one should I use?

I don't have enough experiences of using Association or Dataset, and when operating with nested associations I meet the ...
85 views

### How can I join non-overlapping TimeSeries so that the gap between any two is considered to be Missing data?

I have a set of time series sampled at one second intervals. For example, ...
13k 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 ...
75 views

### List structure for plotting multiple y-values (with gaps on certain dates) using DateListPlot

I would like to set up a list like this data = {{Date1,y1,y2,y3,y4,y5,y6},{Date2,y1,y2,y3,y4,y5,y6},...} and then use DateListPlot to create various plots, e.g. y1 ...
165 views

### Customized priority function in DataStructure["PriorityQueue"]?

I'm using Mathematica 12.1. The documentation for DataStructure["PriorityQueue"] claims that, ... the highest-priority element is always returned. The ...
2k 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, ...
311 views

### Substitute for Association inside Compile?

Associations are not compilable, so I’m looking for a workaround to this. That is, I need a mutable hashtable-like data structure with fast key value lookups ...
71 views

### Question on splitting into individual cycle from a list of 30 cycles dataset

Hi I have a set of data and will like to find out I can split these 30 cycles into each individual cycle? Do I use the for loop function in this application. Thanks for the help in advance. ...
249 views

### How to rotate matrix? [closed]

Consider the matrix 'm1' : m1 = RandomReal[{0, 1}, {100, 100}]; The question is, how to rotate the 'm1' data 45 degrees and extract the matrix 'm2' from it (shown ...
1 vote
77 views

### selecting specific part of data set [closed]

I have data set in form {section, Arcangale ,X,Y, type}. Section is the number between 1 to 3 (1,2,3), Arcangale is number change from 0 to 1 something like this (0.0176575), x and y are coordinate (...
15k 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 <...
152 views

### How to convert a dataset into an alternative format

I have the following dataset: ...
67 views

### Heap.m data structure package in Mathematica (Book: Computer Science with Mathematica, CUP press)

The CUP press book Computer Science with Mathematica discusses heaps in section 8.4.3. The package Heap.m is mentioned (for import), containing functions such as HeapPlot. Can you advise where to find ...
692 views

### Difference between HashTable datastructure and Association datastructure

Is there a difference in the runtimes between CreateDataStructure["HashTable"] and <||> in terms of inserting, ...
231 views

### Mutable objects in Wolfram Language

I've seen some posts about mutable objects in WL and some implementations: Once more on object orientation in Mathematica: does it have to be so hard? Immutability, Association and typing Code ...
157 views

### Restrict kinds of heads when dealing with level concept

In[1] Map[(# + 7) &, {a, 3 b, {c, d}, e}, {2}] Out[1] {a, 10 (7 + b), {7 + c, 7 + d}, e} But I want feature like ListMap : ...
227 views

### Import structure from Matlab into Mathematica 12 and nested lookup

I use Matlab and generate data that I save in a structure in a MAT file. I want the results to be loaded into Mathematica, as several analysis and plots are best when done in the latter than in the ...
55 views

### Implementing array with partial cyclic data?

I'd like to construct an array where some columns are cyclic. As an illustrative example, take Table[Mod[k, 2^i], {k, 2^10}, {i, 0, 10}] //Grid, where the vast ...
1 vote
48 views

### Logarithmic steps inside a Do

I have trouble, i need to do several computations inside a loop using values in a logaritmic scale, is this possible? Inside of the cicle i create a several data sctructures, and it currently works ...
163 views

### Create list of functions, domains, and iterate over (compare to Python code)

In Mathematica, I want to do a mass export of many different animated plots of specific functions with different domains. Because I don't necessarily want the plots to always have exactly the same ...
1 vote
1k views

### How do I create a graph with randomly directed edges starting from a undirected graph?

I have an undirected graph $G$. How would I randomly assign directions to some fraction $p$ of the edges? How might I do this efficiently / quickly provided I have a large graph structure? For ...
63 views

### Handling lists indexed with integer partitions

I am trying to do some exploration around the multi-dimensional version of [truncated moment problem], where I work with various distributions (uni- or multi-variate), and use some truncated moment ...
540 views

### How to use DataStructure in FunctionCompile?

The official document said compile a function that can work with data structures but how to use it? There is no doubt that it is possible to use DataStructure as a function parameter: ...
67 views

### Finding the number of unique solutions in a .txt file

Well, my question is the following: I have a .txt file that consists of the following data: ...
130 views

### Exporting a multi excel files into one file

Suppose a list of students'grades in excel: "excel files" I want to write a program separate student grades to their respective classes and then write them in one excel file. What should I ...
2k 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 ...
1k views

### How to use the iterator in Mathematica

I find that Mathematica has the iterator data structure. We can build some iterators like this: Constant iterator GeneralUtilities`ConstantIterator[5] Key value ...
82 views

### Quick questions about a document example for Components and Data Structures

NDSolve can be broken into several basic steps for advanced usage according to Components and Data Structures. In the documentation, a simple example is given as ...
1 vote
52 views

### Problem of application of HashTable in Fibonacci

As we can see the example in ref/datastructure/HashTable This code show the usage of HashTable, Fib is the implement of Fibonacci Number with HashTable. If we ...
1 vote
51 views

### Going through all the cases in a rule list

So, I want to have explainable equations derived from replacement rules. I made a Mathematica function that does the following, it takes a list of rules, and it applies them (using ReplaceAll), then ...
394 views

### How to determine if two mutable data structures are the same?

How can I determine if two mutable data structures (DataStructure) are truly the same? I do not mean checking if they have the same value. I mean checking if they ...
2k views

### Best way to insert element into an ordered list at the correct position?

Suppose I have an ordered list orderedList and I want to write some code that will involve regularly inserting new elements into ...
1k views

### Learning Resources for Data Science in the Wolfram Language

I'm delivering an upcoming course on Data Science with the programming/analysis done predominantly in the Wolfram Language. I created the following table to leverage students' familiarity with Lists ...
168 views

### Is a tree structure possible in Mathematica?

Let's say I have a vector, vector={1,2,3,4,5,6,7}; and I want to use its items as leaf nodes in a tree datasctructure, then work with them as such, adding new ...
1 vote
81 views

### A more efficient way to interrogate data inside a Dataset: a generic relational map

I have a Dataset that stores the relationships between people IDs (in columns) and the events they attended (in rows). I want to produce a linear text report of those relationships. How can I do this ...
762 views

### COVID-19 Wolfram Data Repository Retrieval

I'm using this dataset to check out the data on new COVID-19 cases. But there are two issues: Two days ago it was working great and it had data up to March 13; 1 day lag. Now when I run the cell in ...
2k 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....
535 views

### How to use the new DataStructure in V 12.1 as is done in classical struct?

There is new DataStructure in V 12.1. I thought at first it is similar to classical struct or record found in other languages and discussed in Struct equivalent in Mathematica? How to use classical ...
18k 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 ...