Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.lisp
Re: Quick Sort in LISP?
William James
5/2/2015 12:57:00 PM
Cyber Surfer wrote:
> barmar@nic.near.net "Barry Margolin" writes:
>
> > (defun sort-file (filename)
> > (let ((lines
> > (with-open-file (s filename)
> > (loop for line = (read-line s nil nil)
> > while line collect line))))
> > (setq lines (sort lines #'string-<))
> > (mapc #'write-line lines)))
>
> It could also be done using the series functions:
>
> (defun sort-file (filename)
> (let ((lines (collect (scan-file filename #'read-line))))
> (mapc #'write-line (sort lines #'string-<))))
>
> The series functions aren't a part of CL, of course, but they
> can be found in the Lisp Repository.
Gauche Scheme:
(use file.util)
(define (sort-file filename)
(for-each
print
(sort (file->string-list filename) string<?)))
--
The figures on Muslim rape of Western women in Europe are astounding. In
Denmark and Norway, between 65% and 70% of all rapes are committed by Muslims,
who as yet still less than 5% of the population. One local judge in Norway
actually exonerated one rapist by accepting his defense that the victim's dress
was taken by him to mean that she was egging him on.
http://fjordman.blogspot.com/2005/08/rape-nothing-to-do-with-...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Quick Sort in LISP?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password