Arc Cross Reference

counts

[procedure] counts seq (o c (table))

Counts each kind of elements in seq. Returns a table that maps an element to a number of it appearing in seq. If you pass a table, the count is accumulated into that table.

(def counts (seq (o c (table)))
  (if (no seq)
      c
      (do (zap [if _ (+ _ 1) 1] (c (car seq)))
          (counts (cdr seq) c))))

Categorys:sequence