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.
6
votes
How do I extract the middle element(s) of a given list?
Here's a short alternative (44 characters):
f = Union@{#[[p = Ceiling[Length@#/2]]], #[[-p]]} & ;
Now apply your function
f@yourinputlist
So for these sample input lists:
evenlist = CharacterRa …
4
votes
How can I create a list containing the normalized element-by-element product of two given li...
Given a set of lists:
h = Table[RandomReal[{0, 30}], {7}]
g = Table[RandomReal[{17000, 20000}], {7}]
(* {22.7964, 26.9984, 0.971047, 4.21998, 21.7333, 20.8884, 14.155} *)
(* {18409.6, 17870.2, 19297 …
1
vote
Accepted
Table yields unexpected result
This is due to the HoldAll Attribute of Function. This can be demonstrated by temporarily clearing this attribute as follows:
Internal`InheritedBlock[
{Function},
ClearAttributes[Function, HoldAl …
0
votes
How do I get a list of all the variable present in an algebraic expression?
Adapting the answer provided here:
varslist = Select[Intersection@
Flatten[Cases[#, _?AtomQ, {0, Infinity}] & /@ Variables[orig]],
Not@NumberQ[#] &]
{d, dd, du, u, ud, uu}
where orig is yo …
2
votes
Create table with function values from other table?
I'm not certain I've understood your question. However, if you intend to use the data (which I've cleaned up for you)
TEg0 = {{4.493410, 7.725252, 10.904120, 14.066190, 17.220750, 20.371300}, {5.7634 …
0
votes
Turning Pascal's Triangle 90 degrees counter clockwise
pascal[depth_] :=
Module[
{},
Row[#, Spacer[2]] &@
(Column[#, Center] & /@
Table[
Take[#1[[#2]], #2] & @@ {Array[Binomial, {depth, depth}, 0], i},
{i, 1, depth}
…
5
votes
How to replace Do loops by Inner
One option is to use MapThread, which gets you there:
List /@ MapThread[Plus, u v f]
But the infix notation for the Dot product is more elegant (as J.M. proposed in the comment above):
List /@ (f. …
1
vote
How can I create a list of functions?
Not sure exactly what you're looking for, but perhaps one of these steps will help.
(1) Create a list of functions you wish to apply:
fcnlist = {Sin, Cos, Tan}
(2) Now define myfunc using a pure f …
1
vote
Lists and Matrices
A clean way to do this is to define a pure function and then Apply it to your list:
{{#1, #2}, {10 #1, 10 #2}} & @@@ list
{{{1, 2}, {10, 20}}, {{3, 4}, {30, 40}}, {{5, 6}, {50, 60}}, {{7,
…
5
votes
Complex numbers from two arrays with Real and Imaginary parts
Perhaps I'm missing something, but why not do
Most[leftREAL] + I leftIMAGINARY
rightREAL + I rightIMAGINARY
These could then be put into a single array if desired.
Alternatively
Flatten[fullREAL …
1
vote
Accepted
Perform operation on part of a table / create a reference
I'm not quite sure what you're after yet, but if you're looking to Map a function to a submatrix, try MapAt
matrix = Array[# &, {3, 3}]
MapAt[E^# &, matrix, {2 ;; 3, 2 ;; 3}] // MatrixForm
Yo …
10
votes
Accepted
How make f[{x,y}] evaluate as f[x,y]?
Why not define a pure function and then Apply that to the list?
f[#1, #2] & @@ p
Apply is straightforward to explain to beginners because it simply replaces the head of an expression.
If you want …
3
votes
Convert coefficients of polynomials into a matrix
This seems to do the trick:
qmatrix = # /. {Plus -> List, Times[const_Real, x_] -> const,
n_Real -> n} & /@ vectorA
I've assumed that your coefficients are Real numbers, and it appears to pass th …
1
vote
Match patterns on list of Strings
Here's a solution which may add flexibility if one is working with more complicated strings or required patterns
Select[ data, StringMatchQ[#, "A" ~~ WordCharacter] & ]
If, for example, one would w …
1
vote
2
answers
120
views
Table of ParametricPlots crashes Kernel
I can usually crash the Mathematica Kernel by using Table to generate a List of ParametricPlots, as follows:
testpara[α_] :=
ParametricPlot[
{
{Cos[θ], Sin[θ]},
{2 Cos[α] + Cos[θ],
2 S …