all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Marc Spitzer <mspitze1@optonline.net>
Subject: Re: How to implement line sorting, uniquifying and counting function in emacs?
Date: Mon, 30 Sep 2002 07:04:51 GMT	[thread overview]
Message-ID: <Xns929920512C859mspitze1optonlinenet@167.206.3.3> (raw)
In-Reply-To: b00bb831.0209291813.72d27e23@posting.google.com

gnuist006@hotmail.com (gnuist006) wrote in 
news:b00bb831.0209291813.72d27e23@posting.google.com:

> In shell you can do this:
> 
>    cat file | sort | uniq -d | wc 
> 
> to count the repeated lines. You can also do
> 
>    cat file | sort | uniq -u | wc
> 
> to count the unique lines.
> 
> Sometimes I have to do this on windows platform where I do have emacs.
> This means that I cannot escape to shell and that route is not 
available.
> 
> Lisp has sort-lines, but no uniq -u or uniq -d available. Also I do not
> know the equivalent to wc.
> 
> This is where some help is requested. I think that this is not only a
> problem of lisp programming, but also algorithms. Which group has this
> kind of expertise?
> 
> Cheers!
> gnuist
> 

if elisp has hashes do the following:
1: open file
2: for each line set it as the key of the hash 
   and add 1 to the previous value, first time
   set it to 1
3a: for the uniq -u count the number of keys
3b: for the uniq -d for each value > 1 add it to 
    a total then print the total
3c: for the truely uniq lines, value == 1, count 
    the number of keys who have a value == 1 and 
    print

marc

  parent reply	other threads:[~2002-09-30  7:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-30  2:13 How to implement line sorting, uniquifying and counting function in emacs? gnuist006
2002-09-30  5:15 ` Evgeny Roubinchtein
2002-09-30  5:23 ` Evgeny Roubinchtein
2002-09-30  7:04 ` Marc Spitzer [this message]
2002-09-30  8:12 ` Jens Schmidt
2002-09-30 16:14 ` Kaz Kylheku
2002-10-01  8:00 ` Steven M. Haflich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Xns929920512C859mspitze1optonlinenet@167.206.3.3 \
    --to=mspitze1@optonline.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.