[Date Index]
[Thread Index]
[Author Index]
Re: Sorting point-arrays by rows and columns, cont.
*To*: mathgroup at smc.vnet.net
*Subject*: [mg124091] Re: Sorting point-arrays by rows and columns, cont.
*From*: Chris Young <cy56 at comcast.net>
*Date*: Sun, 8 Jan 2012 04:28:19 -0500 (EST)
*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com
*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}}
}
Prev by Date:
**Re: find data**
Next by Date:
**Re: SortBy for multiple key sorts**
Previous by thread:
**Re: Sorting point-arrays by rows and columns, cont.**
Next by thread:
**Re: Sorting point-arrays by rows and columns, cont.**
| |