2017年4月19日足协杯第2轮大连博阳vs丽江飞虎直播
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 |
Results tagged with list-manipulation
Search options not deleted
user 10397
百度 但一些守旧派反对这种改革,依然按照旧的历法在这天送新年礼,庆祝新年。
Questions on the manipulation of List objects in Mathematica, and the functions used for these manipulations.
10
votes
How to count number of observations/rows within each group
Without a Do loop
Tally[First /@ data]
{{AA, 2}, {CC, 5}, {DD, 3}}
or for speed
Tally[data[[All, 1]]]
{{AA, 2}, {CC, 5}, {DD, 3}}
EDIT:
Testing for a bigger set of data:
data2 = Ta …
1
vote
The minima for a list
If you are looking for a running minima, then the answer already exists here. If you need it by chunks, then
Some data as an example (you use your own)
data = RandomReal[1, 795000];
The function
…
13
votes
Accepted
Prepending a constant value to sublists of a list
Rewriting other's using operator forms
I like @eldo's solution, but it can be shorter!
Map[Prepend[-1], list, {2}]
Same for @aardvark2012's
Map[Insert[-1, 1], list, {2}]
Solutions of my own
l …
1
vote
Quick way to form a list
You should avoid uppercase variables and function names, see this answer.
Also, look at the documentation for Thread as an alternative to the other solutions.
list1 = {{2, 10}, {4, 12}, {6, 17}, {8, …
0
votes
Extracting a 2 x 2 matrix from a 9 x 9 matrix
If you insist in For and something similar to Print then
With[{prnt = WriteString[$Output, ##] &},
For[i = 1, i <= 9, i = i + 8,
For[j = 1, j <= 9, j = j + 8,
prnt[k[[i, j]], " "]
];
prnt[ …
8
votes
Accepted
Removing last element of each sublist
Most
You are after Most, Mapped over the list. Notice that f/@l is just a short form for Map[f,l].
Most /@ {{1, 4}, {1, 3, 8}, {7, 12}, {2, 4, 9, 12}, {5, 7, 18,
19, 22}, {3, 5}}
(* {{1}, {1, 3} …
1
vote
Import Log file and transform
SetDirectory@$TemporaryDirectory;
file = Export["test.log", "{\"a\":19,\"c\":12}\n{\"x\":17,\"y\":15}",
"String"];
Flatten[
ReplaceAll[
ImportString[#, "JSON"] & /@ Import[file, "List"]
, R …
4
votes
How to obtain a subset (of a 2-d set of points with random coordinates) having monotonically...
benchmark = {{4, 4}, {8, 8}, {14, 12}, {16, 16}, {22, 20}, {26,
24}, {32, 32}, {38, 36}, {44, 40}, {46, 44}, {52, 48}, {58,
56}, {62, 60}, {64, 64}, {74, 72}, {82, 80}, {86, 84}, {92,
88}, …
3
votes
Gathering a List efficiently
I suggest that instead of {L0, L2, L4, L6, L8} you use {lq[0], lq[2], lq[4], lq[6], lq[8]}.
My approcach
lq = GroupBy[
MapIndexed[{##} &, L]
, Q@*First -> Last@*Last
]
But I have to admit that …
5
votes
Accepted
Merging two lists as a twisted comb
There is a built in function for that Riffle
Riffle[list1, list2]
A more general version of this question is here
Is there a way to riffle more than two lists?
Where the general solutions for …
2
votes
Accepted
Deleting elements of a list with a condition
From the documentation, DeleteCases[expr,pattern] removes all elements of expr that match pattern. The second argument is a pattern, not a function. Your second argument is a function that working as …
8
votes
Select sub-sequences in lists?
Other solutions
MapAt[Last, list, {All, 2}]
(* {{a1, c1}, {a2, c2}, {a3, c3}} *)
list /. {x_, {y_, z_}} -> {x, z}
(* {{a1, c1}, {a2, c2}, {a3, c3}} *)
Benchmark
Large data, 10^7 lines.
largeList …
5
votes
Swapping two points in a list of points
All these will take {0.8,0.4} and transform it into {0.4,0.8}
Reverse[{0.8,0.4}]
(* {0.4,0.8} *)
{0.8,0.4}/.{x_,y_}->{y,x}
(* {0.4,0.8} *)
RotateLeft@{0.8,0.4}
(* {0.4,0.8} *)
RotateRight@{0.8,0.4 …
7
votes
Creating new lists
Using belisarius/J.M. but with the new operator form of Cases
Cases[{x_, _, _, y_?Positive, _} :> {x, Log10[y]} ] @ data
5
votes
Deleting specific elements in a list when they come together
A different solution using SubsetQ and Select. I also prefer ti limit the scope of the variable definitions using With or Module.
With[
{
l = {{"x", "b", "c"}, {"y", "a", "d"}, {"x", "b", "y"}, {" …