32 votes
Accepted

How to use the iterator in Mathematica

Such functions set up a one-time iterator, i.e. a GeneralUtilities`Iterator. Its functionality may be inspected with ...
Michael E2's user avatar
  • 236k
29 votes

Difference between HashTable datastructure and Association datastructure

Summary Important differences between Association and CreateDataStructure["HashTable"] include: associations are ...
WReach's user avatar
  • 68.9k
21 votes

Error changing Dataset using Part

I have implemented the underlying kernel functionality that is needed to make this possible. However it is not yet implemented on the Dataset side. I don't think this will happen in the immediate ...
Taliesin Beynon's user avatar
18 votes
Accepted

Data re-structuring by Thread

A level specification can help (we have to specify the head to thread over, too): Thread[{{a, b}, {{x, y}, {z, w}, {u, v}}}, List, {2}] {{{a, b}, {x, y}}, {{a, ...
Henrik Schumacher's user avatar
18 votes
Accepted

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

This way of comparison is not directly exposed in top-level at the moment. However, it could be done through the compiler, for example ...
ilian's user avatar
  • 25.5k
16 votes
Accepted

How to implement a discrete data representation?

Making discrete Data an abstract data type I would try to do something like the following: ...
gwr's user avatar
  • 13.5k
16 votes

Substitute for Association inside Compile?

For what it's worth, you can work with a HashTable as long as you're willing to put in a bit of effort ...
b3m2a1's user avatar
  • 46.9k
15 votes
Accepted

Pascal records and Mathematica programming

Update 2 Per request, I extended this to handle arbitrary sizes and rotations. It was a huge hassle to figure out how to get the appropriate permutations for the individual rotations for arbitrary ...
b3m2a1's user avatar
  • 46.9k
15 votes
Accepted

COVID-19 Wolfram Data Repository Retrieval

It never updates for me properly. This is what I do: ...
Szabolcs's user avatar
  • 235k
14 votes
Accepted

Most efficient method for export/import of non-traditional tensor-style dimensions of matrices/tables/lists-of-lists-of-lists(-of lists)?

You might want to give the HDF5 format a try. It seems to be very efficient, even faster than MX in the example below. One has only to be careful to use the option ...
Henrik Schumacher's user avatar
14 votes

Using DataStructures in FunctionCompile

This is a bit too long for a comment, but below is a slightly modified version that uses the "DynamicArray" approach. The basic issue is that all the ...
ilian's user avatar
  • 25.5k
13 votes

How to implement a discrete data representation?

General A late-to-the party post. To complement other answers, which already show most important ingredients for constructing data types with overloaded system functions, I'd like to show an approach ...
Leonid Shifrin's user avatar
12 votes
Accepted

How to use classical data structure in Mathematica

Here'a quad-tree index (trie) illustrating the compact codes and efficiency enabled by nested Associations and recursive Queries - no looping, no NestWhile or Fold is used. Compare to earlier ...
alancalvitti's user avatar
  • 15.1k
12 votes

How to implement a discrete data representation?

I'm just throwing a different idea in the room. Let's say you have a dataset of such structures: ...
halirutan's user avatar
  • 113k
11 votes

How can I add a column into a existing Dataset?

Update 2018. In fact Join[ds,ds[All, <|"col3"-> (#col1+#col2&)|>],2] is working in Mathematica 11.0.0.0
Diego Restrepo's user avatar
11 votes

count the pairs in a set of Data

Given: f = Counts /* AllTrue[EvenQ]; Then: f[list1] (* False *) f[list2] (* True *)
WReach's user avatar
  • 68.9k
10 votes
Accepted

Tree-like data sets with efficient storage and retrieval

Simple memoization There are few places where we can optimize code from OP. Let's start with already mentioned in OP simplest memoization. ...
jkuczm's user avatar
  • 15.1k
10 votes
Accepted

Implement abstract algebraic structure

I decided it was worth giving another example of modern OOP in Mathematica. There will be a small amount of code, but almost all of it is boiler-plate. I use a package to handle most of the boiler ...
b3m2a1's user avatar
  • 46.9k
10 votes

How to use DataStructure in FunctionCompile?

The quoted sentence from the guide does seem a bit forward-looking. As evidenced by all the documentation examples given for any of the new data structures, the current emphasis is on working with ...
ilian's user avatar
  • 25.5k
10 votes
Accepted

How to use DataStructure in FunctionCompile?

Note that this code works in 12.2 (did not work in 12.1): ...
Arnoud Buzing's user avatar
9 votes

Efficient priority queues?

As of Mathematica 12.1, you can use CreateDataStructure to, well, create data structures, and priority queues are one of them. ...
Pillsy's user avatar
  • 18.5k
9 votes
Accepted

count the pairs in a set of Data

Using Counts f = And @@ EvenQ[Values[Counts[#]]] & {f[list1], f[list2]} {False, True}
Anjan Kumar's user avatar
  • 4,979
9 votes

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

If you have v12.1, there's no need to ever call Sort if you can incrementally add your values to a "PriorityQueue" ...
flinty's user avatar
  • 25.3k
8 votes
Accepted

Immutability, Association and typing

My understanding is that you want to wrap an association into an inert wrapper representing the type. Immutable version Then, you should do just that: ...
Leonid Shifrin's user avatar
7 votes
Accepted

Is *.dat file suitable for storing high (>2) dimensional matrix?

Use Put and Get. Having l1 = {{a1, {a, b, c, d, e}}, {a2, {f, g, h, i}}} one exports ...
corey979's user avatar
  • 23.9k
7 votes

How can I add a column into a existing Dataset?

I recently ran into this problem as well, especially when the need arises to append a whole new column with data from an entirely different source. Suppose, for example, that we have: ...
Sjoerd Smit's user avatar
  • 23.5k
7 votes

Can a Trie be implemented efficiently?

The Markdown document "Tries with frequencies in Java" (and this blog post) describe the installation and use in Mathematica of Tries with frequencies implemented in Java through a corresponding ...
Anton Antonov's user avatar
7 votes
Accepted

List structure transformation

Flatten /@ Thread[data, List, {2}] {{x, y, a}, {x, y, b}, {x, y, c}, {x, y, d}, {x, y, e}} Also: ...
kglr's user avatar
  • 395k
7 votes
Accepted

Get the dimensions from the SparseArray properties

"Properties" The listed "Properties" does not include dimensions ...
rhermans's user avatar
  • 36.5k

Only top scored, non community-wiki answers of a minimum length are eligible