Student Support Forum: 'list manipulation' topicStudent Support Forum > General > Archives > "list manipulation"

 Next Comment > Help | Reply To Topic
 Author Comment/Response Sharjeel Tahir 07/26/10 3:07pm in the attached notebook, if you look at output of the very last line, you will see that it is list that has some elements that have three sub-elements in them and others that have two sub-elements. I basically want to determine how many elements have three sub-elements in that list. What will be the command for that? A side question can anyone explain the following code also. I am having very hard time understanding the use of # and &. I want to merge the sublists which have the same SECOND element and at the same time SUM their first elements to produce a new sublist of the form: {SUM[first elements], common second element} ={a,b,c,d,e,f} I'll generate a sample to work on t=Table[{Random[Integer,20],Part[l,Random[Integer,{1,Length[l]}]]},{20}] then, one solution is Map[Total@(First/@#),#[[1,2]]}&,Split[t[[Ordering[Reverse/@t]]],#1[[2]]==#2[[2]]&]] and the other is Map[Total@(First/@#),#[[1,2]]}&,Map[Cases[t,{_,#}]&,l]] Attachment: 2d_ray_tracing_new.nb, URL: ,

 Subject (listing for 'list manipulation') Author Date Posted list manipulation Sharjeel Tahir 07/26/10 3:07pm Re: list manipulation Peter Pein 08/01/10 04:55am Re: Re: list manipulation Sharjeel Tahir 08/06/10 00:16am
 Next Comment > Help | Reply To Topic