Re: Another question on lists
- To: mathgroup at smc.vnet.net
- Subject: [mg80671] Re: Another question on lists
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Tue, 28 Aug 2007 02:19:21 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <fatglk$2k6$1@smc.vnet.net>
Mauricio Esteban Cuak wrote:
> Hello again.Thank you very much for your previous help. However, I
> seem to stumble on another rock:
>
> I have a list of n sub-lists with different number of elements. I
> want to select the list with the highest number of elements.
> I tried to combine the Select function with Lenght but couldn't do it:
>
> Select[list, Length /@ list >= Max[Length /@ list] &]
You were almost there: you must take the length of the current element
(i.e. Length[#]) and compare it against the greatest length of of every
element (Length /@ lst). For instance,
In[1]:= lst = {{1, 2, 3, 4}, {5, 6}, {7, 8, 9, 10}, {11, 12, 13}};
Select[lst, Length[#] == Max[Length /@ lst] & ]
Out[2]= {{1, 2, 3, 4}, {7, 8, 9, 10}}
<snip>
> P.D.: Any tips,websites, books, on how to learn some basic programming
> on Mathematica?
> I'm slowly beginning to read "The Mathematica Book"...should I just
> concentrate on that?
An excellent book to start learning programming Mathematica is, _An
Introduction to Programming with Mathematica_, 3rd Edition, Paul R.
Wellin, Richard J. Gaylord, and Samuel N. Kamin, Cambridge University
Press, (ISBN-13: 9780521846783 | ISBN-10: 0521846781). See
http://www.cambridge.org/catalogue/catalogue.asp?isbn=9780521846783
Table of Contents:
1. An introduction to Mathematica;
2. The Mathematica language;
3. Lists;
4. Functional programming;
5. Procedural programming;
6. Rule-based programming;
7. Recursion;
8. Numerics;
9. Graphics programming;
10. Front-end programming;
11. Examples and applications;
12. Writing packages;
Appendix A: how expressions are evaluated;
Appendix B: debugging.
(Notebooks, code examples and solutions to some exercises, are available
on the publisher web site. See the above link.)
About free resources, a good start would be to search MathSource (part
of the Wolfram Library Archive) For instance, _Programming Paradigms via
Mathematica (A First Course)_ may be of interest. See
http://library.wolfram.com/infocenter/MathSource/1847/
Hope this helps,
--
Jean-Marc