Search Results
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 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
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 |
Questions on the manipulation of List objects in Mathematica, and the functions used for these manipulations.
13
votes
Accepted
On generalizing Partition[] (with offsets) to sublists of unequal length
This is a complete re-write
This is the original solution which was done in haste but i will leave here. It works in limited cases:
multisegment[lst_List, scts_List, offset_List] :=
Module[{acc, o …
4
votes
Accepted
Selecting elements from a list one by one
You want to take the first number if sublist #1 and add a random number between 1 and 10 to it (not specified whether this should be an integer or real), then take the first element of sublist #2 and …
2
votes
Dealing with Empty Brackets in a List
Why not delete the {} before carrying out any further analysis?
newgraphlist =
DeleteCases[{{}, {{0, 0.00342769}}, {{0, 0.00503465}}, {}, {{0,
0.000187}}, {}, {}, {}, {}, {}, {}, {}, {}, {}}, …
2
votes
Combining two lists
the answers to this question will work for you. Just Flatten the final lists
processList[list1_, list2_] :=
Module[{intersection, tmp1, tmp2},
intersection = Intersection[list1[[All, 1]], list2[[ …
2
votes
Accepted
Efficiently adding a fixed real numbered value to a set of elements in an array
Take advantage of listability -- meaning that you do not have to loop through the list, just add r to the list.
Timing[L1 = Table[L[[q]] + r, {q, 1, Length[L]}];]
(* {1.288042, Null} *)
faster list …
9
votes
Accepted
How can I use Pick to select items in one list when a value in a corresponding list is $\leq...
Several ways to create the stencil. Perhaps most intuitive is just to run a test:
stencil = # <= 0.5 & /@ List1
Pick[List2, stencil]
(* {"a", "d", "f"} *)
Edit
To answer the comment below, Pick …
2
votes
Change sublist based on position
I presume your starting list will never contain duplicates. Therefore:
1.
sublist1 = sublist /. MapIndexed[#1 -> First[#2] &, list]
(* {{2, 2, 3}, {1, 1, 1, 4, 5}} *)
2.
sublist2 = BinCounts[#, { …
3
votes
Refer to next element of list when iterating using Map
Use Partition to produce {{a, b}, {b, c}, {c, d}, {d}} then for the operation in your example total the sublists at the second level and + 1:
1 + Total[Partition[{a, b, c, d}, 2, 1, {1, 1}, {}], {2}] …
2
votes
Accepted
Quickly pruning elements in one structured array that exist in a separate unordered array
This method assumes modifiedTestList is a given.
rules = Dispatch@Thread[Rule[modifiedTestList, Sequence[]]]
tmp1=Replace[testList, rules, {2}]
Also
tmp2=DeleteCases[testList, Alternatives @@ modi …
0
votes
Looking for mismatches between two lists
It seems from the comments that it is the first 3 positions that need to match (i.e. the strings)
If[epiDB[[All, 1 ;; 3]] === epiExcel[[All, 1 ;; 3]],
Print["Match"],
(* else find the positions tha …
4
votes
Accepted
getting at the right parts of a list
Map[Flatten, GatherBy[x, #[[1, 2 ;;]] &], {2}][[All, All, 2 ;;]]
1
vote
Inverse of Times->Sequence
with this as your starting list
list = {{a, b, c}}
you could also do this
list[[1, 0]] = Times; list
2
votes
Reflect manipulations on one list in a second list
Maybe start with a basic test:
test=NumericQ /@ l1
This can be used with Pick
Pick[l2, test, False]
If you want positions you could always use Position directly
pos=Position[l1, _?NumericQ]
Del …
3
votes
Sum the first element of a list
list[[All, 1]] = list[[All, 1]] + Range[0, Length[list] - 1];
list
2
votes
How to do this job without creating a new list?
Since you do not want to make new lists, and looking for something different to the other answers:
ls[[All, 2]] = Transpose[{ls[[All, 2]], v}] /. {{x_, y_} /; x < y :>0.5, {_, _} -> -0.5}
ls