help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Find the longest word in the word list file.


From: Kevin Vigouroux
Subject: Re: Find the longest word in the word list file.
Date: Thu, 12 Aug 2021 16:47:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> Hongyi Zhao wrote:
>
>> I don't think so. Whether you start completely from scratch,
>> with elisp, there are so many selections for doing such
>> a thing. This way can give us a deeper understanding of
>> algorithms and how computers work.
>
> Here you go,
>
> (defun sort-lines-length (beg end)
>   (interactive (if (use-region-p)
>                    (list (region-beginning) (region-end))
>                  (list (point-min) (point-max)) ))
>   (save-excursion
>     (save-restriction
>       (narrow-to-region beg end)
>       (goto-char (point-min))
>       (sort-subr nil
>                  #'forward-line
>                  #'end-of-line
>                  nil nil
>                  (lambda (a b) (> (- (cdr a) (car a))
>                                   (- (cdr b) (car b)) ))))))
> (defalias 'sll #'sort-lines-length)
>
> https://dataswamp.org/~incal/emacs-init/sort-incal.el lines 18-32

How do we know that the “sort key” is a cons cell?

-- 
Best regards,
Kevin Vigouroux



reply via email to

[Prev in Thread] Current Thread [Next in Thread]