Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #7668
| From | Chris Young <cy56@comcast.net> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Sorting point-arrays by rows and columns, cont. |
| Date | 2012-01-08 09:32 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jebnrf$1i9$1@smc.vnet.net> (permalink) |
| References | <je6e3j$q6k$1@smc.vnet.net> <je96m6$j6c$1@smc.vnet.net> |
It's a little hard to get used to the conventions about which slot gets
which argument in a lot of these functions. For example, in the Help
for FoldList, it just has an example, which doesn't even use the usual
sort order.
Fold to the right:
In[1]:= FoldList[g[#2, #1] &, x, {a, b, c, d}]
Out[1]= {x, g[a, x], g[b, g[a, x]], g[c, g[b, g[a, x]]],
g[d, g[c, g[b, g[a, x]]]]}
I wish the documentation would at least say what the slots are for. One
self-documenting way to write the code is with the tee-arrow notation
for funcitons (via Esc-fn-Esc). Then we can just put in "P" and "list"
for the arguments and everything is a lot clearer.
In[78]:= P = hexPts;
list = {1, 2};
FoldList[
{P, list} \[Function]
P[[Ordering[P[[All, list]], All, LessEqual]]],
P,
list
]
Out[80]=
{
{{0, 0}, {1, 0}, {1/2, Sqrt[3]/2}, {-(1/2), Sqrt[3]/2}, {-1, 0},
{-(1/2), -(Sqrt[3]/2)}, {1/2, -(Sqrt[3]/2)}},
{{-1, 0}, {-(1/2), Sqrt[3]/2}, {-(1/2), -(Sqrt[3]/2)}, {0, 0}, {1/2,
Sqrt[3]/2}, {1/2, -(Sqrt[3]/2)}, {1, 0}},
{{-(1/2), -(Sqrt[3]/2)}, {1/2, -(Sqrt[3]/2)}, {-1, 0}, {0, 0}, {1, 0},
{-(1/2), Sqrt[3]/2}, {1/2, Sqrt[3]/2}}
}
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread
Sorting point-arrays by rows and columns, cont. Chris Young <cy56@comcast.net> - 2012-01-06 09:15 +0000
Re: Sorting point-arrays by rows and columns, cont. Chris Young <cy56@comcast.net> - 2012-01-07 10:27 +0000
Re: Sorting point-arrays by rows and columns, cont. Chris Young <cy56@comcast.net> - 2012-01-08 09:27 +0000
Re: Sorting point-arrays by rows and columns, cont. Chris Young <cy56@comcast.net> - 2012-01-08 09:32 +0000
csiph-web