16

This way of comparison is not directly exposed in top-level at the moment. However, it could be done through the compiler, for example sameInstanceQ = FunctionCompile[Function[{Typed[e1, "Expression"], Typed[e2, "Expression"]}, Native`SameInstanceQ[e1, e2]]]; a = CreateDataStructure["Value", 1]; b = a["Copy"]; c = b; SameQ[a, b, c] (* True *) ...


14

It never updates for me properly. This is what I do: ro = ResourceObject["Epidemic Data for Novel Coronavirus COVID-19"]; DeleteObject[ro]; ro = ResourceObject["Epidemic Data for Novel Coronavirus COVID-19"]; Just delete and re-download. Wolfram basically just provides some minor convenience by re-formatting the data to a more Mathematica-compatible ...


9

If you have v12.1, there's no need to ever call Sort if you can incrementally add your values to a "PriorityQueue" data structure. It always stays sorted as you add/remove elements. SeedRandom[1234]; ds = CreateDataStructure["PriorityQueue"]; (* push a million random values in - use Scan for pushing many values. The slowest part here is ...


8

As of Mathematica 12.1, you can use CreateDataStructure to, well, create data structures, and priority queues are one of them. SeedRandom[1337]; stuff = RandomInteger[100, 10] (* {58, 91, 36, 72, 63, 16, 60, 13, 44, 18} *) pq = CreateDataStructure["PriorityQueue"] (* DataStructure["PriorityQueue", {"Data" -> {}}] *) Scan[pq["Push", #]&, stuff]; (* ...


7

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 plater, myself, but I find that links to packages make the code less-likely to be used. So here we go. First off, we'll define a constructor for your Algebra ...


7

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 them in top level (interpreted) Wolfram Language code. The goal is to eventually support also in FunctionCompile the same nice syntax shown in the question. ...


6

Note that this code works in 12.2 (did not work in 12.1): cf = FunctionCompile[Function[{Typed[ds, "BitVector"]}, ds["BitCount"]]]; ds = CreateDataStructure["BitVector", 32]; ds["BitSet", 1]; ds["BitSet", 2]; ds["BitSet", 3]; cf[ds] (Gives 3)


5

For the binary search idea, you could use Leonid Shifrin's fast, compiled binary search function here. It would look like this: sortedInsert[list_, el_] := Insert[ list, el, bsearchMax[list, el] ] sortedInsert[2 Range[10], 13] {2, 4, 6, 8, 10, 12, 13, 14, 16, 18, 20} list = Sort@RandomInteger[100000, 10000]; values = RandomInteger[100000, 1000]; ...


4

Use ResourceUpdate for this: data = ResourceData[ResourceUpdate["Epidemic Data for Novel Coronavirus COVID-19"]];


4

A new entry in the function repository, SameInstanceQ, can also be used here: In[31]:= a = CreateDataStructure["Value", 1]; b = a["Copy"]; c = b; In[34]:= ResourceFunction["SameInstanceQ"][a, b] Out[34]= False In[36]:= ResourceFunction["SameInstanceQ"][b, c] Out[36]= True It can also work with normal Wolfram ...


4

Not sure whether I got your right, but maybe this is ist: You can use StringCases in combination with Counts to get the corresponding results. Given your input as data (I don't have your textfile): data = "r&=3&a&=3&b&=4&c&=10\\ r&=3&a&=8&b&=15&c&=120\\ r&=3&a&=20&b&=55&c&...


4

Following the lead of your own workaround you might consider an abstraction like this: pqpat = PQ : DataStructure["PriorityQueue", ___]; orderQueue[pqpat, ofn_]["Push", val_] := PQ["Push", {ofn@val, val}] orderQueue[pqpat, ofn_]["Pop"] := PQ["Pop"][[2]] hp = CreateDataStructure["PriorityQueue"]; ...


3

I just found that, when Order compares two lists, if their first elements are already unequal, the result is in effect the Order between them. So here is a solution I can come up with: With[{f = 20 - # &}, Module[{hp = CreateDataStructure["PriorityQueue"]}, Scan[hp["Push", {f[#], #}] &, Range[20]]; Table[hp["Pop"][[...


2

Update Using the provided files. Since the Excel files have no header, importing as a Dataset is not possible. The easiest way is to add headers to the Excel file and use the code from the comments. If that is not possible then classGrades = Import["~/Downloads/GG.xlsx"] // First // MapAt[Round, #, {All, 1}] & // (* Change class id to ...


2

There is probably a better way of getting the relationships by constructing a graph. Here is a modification of your approach. dsMeetings2 = Dataset@{<|"id" -> 1, "date" -> "1/03/20", "name" -> "subject-1", "100" -> 1, "106" -> 1, "101" -> 1, "105" -> 1, "102" -> 1, "104" -> 0, "108" -> 0, "103" -> 0, "109" -&...


2

I think that the best match to what you are discussing is an association, e.g. personalinfo = Association["name" -> "Fred", "age" -> 90] (* <|"name" -> "Fred", "age" -> 90|> *) personalinfo["name"] (* "Fred" *)


1

You can just use Join (in version 12.1): eMap = Dataset[{<|"ModuleId" -> 0, "SegmentId" -> 0, "x1" -> 0, "y1" -> 0, "z1" -> 0, "x2" -> 0, "y2" -> 0, "z2" -> 0|>}] (* Dataset[{<|"ModuleId" -> 0, "SegmentId" -> 0, &...


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