Tag Info

New answers tagged

1

There were (are) many methods faster than your Cases code for earlier versions. Two of the best are simple DownValues assignments, e.g. fn[key] = {val1, val2, ...} and Rules optimized with Dispatch. I believe the latter is usually slightly faster so I will illustrate that one. dsp = Dispatch[ #[[1, 1]] -> #[[All, 2]] & /@ GatherBy[data, First] ]; ...


6

In response to a), you can write Merge[Rule @@@ data, Identity], which is slightly simpler. In response to b), there are two different ways to do this nicely. One of which works in 10.0.0, the other will have to wait for 10.0.1. In 10.0.0 we can use GroupBy to associate each unique key with the set of corresponding values: grouped = GroupBy[data, First ...


0

In Mathematica 10 you could use Composition and the new operator form of Select: Mathematica 10.0 for Linux x86 (64-bit) Copyright 1988-2014 Wolfram Research, Inc. In[1]:= Select[Not@*DirectoryQ]@FileNames["*Preferences*",{".Mathematica"},Infinity] Out[1]= {.Mathematica/ApplicationData/Parallel/Preferences/Preferences.m} In Mathematica 9 this will do, ...


5

All three of parameters for FileNames can affect the depth at which Mathematica searches for results. It seems like your confusion is a result of interaction among these parameters. This is easily understandable as the documentation for FileNames is not very illustrative. (Indeed my first attempt at answering this question was faulty for the same reason.) ...



Top 50 recent answers are included