<?xml version="1.0" encoding="utf-8" ?> <!-- for emacs: -*- coding: utf-8 -*- --> <!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head><title>tally(VisibleList) -- tally the elements of a list, sequence, or array</title> <link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/> </head> <body> <table class="buttons"> <tr> <td><div><a href="_tan.html">next</a> | <a href="___Tally_sp_us_sp__Thing.html">previous</a> | <a href="_tan.html">forward</a> | <a href="___Tally_sp_us_sp__Thing.html">backward</a> | up | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div> </td> </tr> </table> <hr/> <div><h1>tally(VisibleList) -- tally the elements of a list, sequence, or array</h1> <div class="single"><h2>Synopsis</h2> <ul><li><div class="list"><dl class="element"><dt class="heading">Usage: </dt><dd class="value"><div><tt>y = tally x</tt></div> </dd></dl> </div> </li> <li><span>Function: <a href="_tally.html" title="tally the elements of a list or sequence">tally</a></span></li> <li><div class="single">Inputs:<ul><li><span><tt>x</tt>, <span>a <a href="___Visible__List.html">visible list</a></span>, </span></li> </ul> </div> </li> <li><div class="single">Outputs:<ul><li><span><tt>y</tt>, <span>a <a href="___Tally.html">tally</a></span>, a listing of tallied results</span></li> </ul> </div> </li> </ul> </div> <div class="single"><h2>Description</h2> <div>It produces an hash table (multiset) <tt>y</tt> which tallies the frequencies of occurrences of items in the list <tt>x</tt>, i.e., <tt>y_i</tt> is the number of times <tt>i</tt> appears in <tt>x</tt>, or is <tt>0</tt> if <tt>i</tt> doesn't appear in the list.<table class="examples"><tr><td><pre>i1 : y = tally {1,2,3,a,b,1,2,a,1,2,{a,b},{a,b},a} o1 = Tally{{a, b} => 2} 1 => 3 2 => 3 3 => 1 a => 3 b => 1 o1 : Tally</pre> </td></tr> <tr><td><pre>i2 : y_2 o2 = 3</pre> </td></tr> <tr><td><pre>i3 : y_5 o3 = 0</pre> </td></tr> <tr><td><pre>i4 : y_{a,b} o4 = 2</pre> </td></tr> </table> </div> </div> </div> </body> </html>