Student Support Forum > General > > "About counting elements"

 Post Reply: Name: Email Address: Please send email when my message is replied to. Url (optional): Subject: Message: view original message? Attachment (optional): Please answer this: 6+1 =

 Original Message (ID '277092') By yehuda: In Response To 'Re: Re: About counting elements' --------- This brings up the old question - 1. to count or not to count the missing elements 2. Another problems in the proposed solution is the use of minimal and maximal values known in advance 3. Third (maybe), the counting results are missing the value they counts So, if one decides in favor of counting also missing elements answering 2 for a predetermined range is as proposed before otherwise With[{l = {-6, 0, 0, 1, 1, 1, 2, 4, 4, 4, 4, 4, 5}}, Map[Count[l, #] &, Range[Min[l], Max[l]]]] answering 3 is rather simple too With[{l = {-6, 0, 0, 1, 1, 1, 2, 4, 4, 4, 4, 4, 5}}, Map[{#, Count[l, #]} &, Range[Min[l], Max[l]]]] and deciding to count only elements that do appear (guess what happens if the list is {-1,0,1,1000000} for example, generating a rather too long list as an answer Tally[{-6, 0, 0, 1, 1, 1, 2, 4, 4, 4, 4, 4, 5}] I hope this broadens (a little bit) the scope of both the question and the answer yehuda