5 ms·
ds = CreateDataStructure["LinkedList"] String keys to access types is kind of yucky, to be honest :( Couldn't there be a better way to represent this than havi
by saagarjha 7y ago
ds = CreateDataStructure["LinkedList"]
String keys to access types is kind of yucky, to be honest :( Couldn't there be a better way to represent this than having to look up the documentation (https://reference.wolfram.com/language/ref/$DataStructures.html https://reference.wolfram.com/language/ref/$DataStructures.h...) to see what would work?
- carry_bit 7y agoIn these cases the notebook interface will normally show you all of the choices via autocomplete.
- lonelappde 7y agoEven for string? Why not define a LinkedList constant?
- carry_bit 7y agoYes, in WL strings are commonly used in a matter similar to enums in other languages. The thing to keep in mind is that WL is based on symbolic replacement. You normally wouldn't define that kind of function as taking in a parameter (i.e., CreateDataStructure[x_] := ...), rather you'd define it for each case separately (i.e., CreateDataStructure["LinkedList"] := ...).
- jxy 7y agoFor interpreted languages, it doesn't matter semantically whether you use strings or not. It's always a run-time value that needs to get resolved when the interpreter gets there.