Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Favorites infavorites:mine
infavorites:1234
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with Search options user 5

Questions on the manipulation of List objects in Mathematica, and the functions used for these manipulations.

19
votes
If you're going to do several lookups repeatedly in a single set, using Associations in version 10 is orders of magnitude faster than BinarySearch. You can try it out if you have Mathematica 10 for Ra …
answered Feb 5 '14 by rm -rf
6
votes
If you wish to get rid of the {}, then Mike's answer using DeleteCases works in this particular case, but will fail in general, because it will not remove {} that's nested deeper (such as {{}}). Using …
answered Jul 28 '12 by rm -rf
3
votes
Here's a straightforward way using Cases: list = {{1, 2}, {2, 2}, {3, 1}, {4, 1}, {2, 4}}; (* example list *) With[{min = Min@#[[All, 2]]}, Cases[#, {x_, min} :> x]] &@list (* {3, 4} *) You can als …
answered Sep 3 '12 by rm -rf
7
votes
It's a floating point issue. The article "What every computer scientist should know about floating point arithmetic" by David Goldberg, is a very good introduction to the topic. In your case, look at …
answered Nov 5 '12 by rm -rf
5
votes
You can create your triangular table in a far simpler manner as follows: Table[{i, j}, {i, 10}, {j, i + 1, 10}] (* { {{1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8}, {1, 9}, {1, 10}}, {{2, …
answered Aug 27 '12 by rm -rf
2
votes
Here's a direct list-manipulation approach using a variation of Heike's answer for combining subsets with similar terms: Cases[list1, {___, Alternatives @@ #, ___}, 2] & /@ list2 //. x_ :> Union …
answered Mar 5 '14 by rm -rf
2
votes
The simplest solution would be: #[[Ordering[#, -1]]] &@ tuples
answered Oct 9 '12 by rm -rf
10
votes
You could just do: f[list__] := Plus[list]/Length@{list} or simpler, using the built-in Mean: f[list__] := Mean[{list}] Using this with your example: f[list1, list2, list3] (* {{0, 4/3}, {0.1, …
answered Sep 18 '12 by rm -rf
5
votes
One can use MapIndexed to access the next (or previous or any arbitrary offset) element of the currently mapped element. However, you also need to make checks so that you don't index it beyond its bou …
answered Oct 22 '13 by rm -rf
7
votes
You can use rules to replace rules! Here's an example: {x -> 1, y -> 2, z -> 2} /. HoldPattern[z -> _] :> (z -> 3) (* {x -> 1, y -> 2, z -> 3} *) Now when there isn't a rule involving z and you wan …
answered May 23 '12 by rm -rf
8
votes
In version 10, the GeneralUtilities context provides a MapIf function that does exactly this: <<GeneralUtilities` MapIf[f, EvenQ, Range@10] (* {1, f[2], 3, f[4], 5, f[6], 7, f[8], 9, f[10]} *) As w …
answered Jul 15 '14 by rm -rf
1
vote
Here's another one, for fun: lst = {3, 5.6, 8.19, 2, 5.6, 4, 3, 8.5, 4.137, 7., 1.165}; Pick[lst, Mod[lst, 1], 0] (* {3, 2, 4, 3} *)
answered Apr 14 '13 by rm -rf
13
votes
Since Yves beat me narrowly to my first solution, here's another one using Select: Select[list1, FreeQ[list2, #] &] Out[2]= {b, a, d} This does not sort your result. You can also use Complement, …
answered Feb 4 '12 by rm -rf
4
votes
I'll join in with my own version: splitList[list_] := Pick[list, IntegerDigits[1/6 (-3 - (-1)^#1 + 2^(2 + #1)) &@Length@list, 2], #] & /@ {1, 0} splitList[{a, b, c, d, e, f, g}] (* {{a, c, e, g …
answered Mar 16 '13 by rm -rf
6
votes
Leonid's answer is very straightforward and I doubt it can be beat. Nevertheless, here's another approach using pattern matching and rule replacements to get the same result: consecutiveValues[l_List …
answered Jun 11 '12 by rm -rf

15 30 50 per page