From: gnuist006
Subject: How to implement line sorting, uniquifying and counting function in emacs?
Date: 
Message-ID: <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

From: Marc Spitzer
Subject: Re: How to implement line sorting, uniquifying and counting function in emacs?
Date: 
Message-ID: <Xns929920512C859mspitze1optonlinenet@167.206.3.3>
·········@hotmail.com (gnuist006) wrote in 
·································@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
From: Kaz Kylheku
Subject: Re: How to implement line sorting, uniquifying and counting function in emacs?
Date: 
Message-ID: <cf333042.0209300814.62235d0b@posting.google.com>
·········@hotmail.com (gnuist006) wrote in message news:<····························@posting.google.com>... 
> Lisp has sort-lines, but no uniq -u or uniq -d available. Also I do not
> know the equivalent to wc.

Lisp does not have sort-lines. *Emacs* Lisp has sort-lines. Please do
not include the comp.lang.lisp newsgroup in Emacs Lisp discussions.

Think before you crosspost; your question ought to have been directed
to the Emacs newsgroup only.
From: Steven M. Haflich
Subject: Re: How to implement line sorting, uniquifying and counting function in emacs?
Date: 
Message-ID: <3D9950FA.8050007@alum.mit.edu>
gnuist006 wrote:

> Lisp has sort-lines, but no uniq -u or uniq -d available. Also I do not
> know the equivalent to wc.

A pure Common Lisp equivalent is the following, reading standard-input:

(loop with last-line
     for line in (sort (loop as x = (read-line *standard-input* nil nil)
			  while x collect x)
		      #'string<)
     unless (equal last-line line)
     count 1
     do (setf last-line line))

Probably not want you wanted.  Probably meaningless to you.