unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: Hongyi Zhao <hongyi.zhao@gmail.com>
Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Re: Find the longest word in the word list file.
Date: Wed, 11 Aug 2021 15:58:25 +0200	[thread overview]
Message-ID: <875ywc9j7i.fsf@gmx.net> (raw)
In-Reply-To: <CAGP6POKgSxB8vi9K7Vs7Ge0DpFdMQKC9s5ijba4GeP-EpdGdhw@mail.gmail.com> (Hongyi Zhao's message of "Wed, 11 Aug 2021 07:14:05 +0800")

On Wed, 11 Aug 2021 07:14:05 +0800 Hongyi Zhao <hongyi.zhao@gmail.com> wrote:

> I have an English word list file that stores words in a
> one-word-per-line format. Now I want to find the longest word in the
> word list file. For example, I can use standard UNIX tools to
> accomplish this with the following simple commands:
>
> $ awk '$0 ~ /^[[:alpha:]]+$/ { print $0, length($0) }'
> american-english-exhaustive | \
> sort -k2n | tail -1
> Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch 58
>
> But in Emacs, what is the elisp implementation for the above task?

Here's another way.  Say e.g. the following is the buffer with your list
of words:

Theory
and
Simulation
of
Materials

First do this:

(setq l
'(Theory
and
Simulation
of
Materials))

Evaluate the preceding sexp, then evaluate the following sexp:

(car (sort l (lambda (a b)
	       (> (length (symbol-name a)) (length (symbol-name b))))))
=>
Simulation

Steve Berman



  parent reply	other threads:[~2021-08-11 13:58 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-10 23:14 Find the longest word in the word list file Hongyi Zhao
2021-08-11  1:51 ` [External] : " Drew Adams
2021-08-11  3:00   ` Hongyi Zhao
2021-08-11  6:46     ` tomas
2021-08-11  8:58       ` Hongyi Zhao
2021-08-11 10:03         ` tomas
2021-08-11  9:52       ` Arthur Miller
2021-08-11 10:06         ` tomas
2021-08-11 13:32           ` Hongyi Zhao
2021-08-11 13:58 ` Stephen Berman [this message]
2021-08-11 14:17   ` Hongyi Zhao
2021-08-11 14:27     ` Stephen Berman
2021-08-11 16:09 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12  2:10   ` Hongyi Zhao
2021-08-12  2:29     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12  3:13       ` Hongyi Zhao
2021-08-12  3:17         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12  3:34           ` Hongyi Zhao
2021-08-12  3:41             ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12  3:52               ` Hongyi Zhao
2021-08-12  4:05                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12  4:25                   ` Hongyi Zhao
2021-08-12  4:38                     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12  4:53                       ` Hongyi Zhao
2021-08-12  5:27                         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12  6:25                           ` Hongyi Zhao
2021-08-12  6:46                             ` Hongyi Zhao
2021-08-12  6:51                             ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12  6:59                               ` Hongyi Zhao
2021-08-12  2:53     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12 14:47       ` Kevin Vigouroux via Users list for the GNU Emacs text editor
2021-08-12 15:45         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12 15:53           ` Kevin Vigouroux via Users list for the GNU Emacs text editor
2021-08-12 16:10             ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12 16:24               ` Kevin Vigouroux via Users list for the GNU Emacs text editor

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=875ywc9j7i.fsf@gmx.net \
    --to=stephen.berman@gmx.net \
    --cc=help-gnu-emacs@gnu.org \
    --cc=hongyi.zhao@gmail.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).