Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Captain's Log, star date 21:34.5...


devel / comp.lang.lisp / .Re: Quick Sort in LISP?

SubjectAuthor
o .Re: Quick Sort in LISP?Robert L.

1
.Re: Quick Sort in LISP?

<t22pjv$1iii$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17008&group=comp.lang.lisp#17008

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!aioe.org!ec7ScQ93rlyPxfPoFRs3vQ.user.46.165.242.75.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (Robert L.)
Newsgroups: comp.lang.lisp
Subject: .Re: Quick Sort in LISP?
Date: Wed, 30 Mar 2022 23:37:37 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <t22pjv$1iii$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Info: gioia.aioe.org; logging-data="51794"; posting-host="ec7ScQ93rlyPxfPoFRs3vQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: XanaNews/1.18.1.6
X-Notice: Filtered by postfilter v. 0.9.2
 by: Robert L. - Wed, 30 Mar 2022 23:37 UTC

> > (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.

Shorter (Racket):

(require threading)

(define (sort-file filename)
(~> filename
file->lines
(sort string<?)
(for-each displayln _)))

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor