[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Find the longest word in the word list file.
From: |
Hongyi Zhao |
Subject: |
Re: Find the longest word in the word list file. |
Date: |
Thu, 12 Aug 2021 10:10:47 +0800 |
On Thu, Aug 12, 2021 at 12:09 AM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao 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
>
> #! /bin/zsh
> longest-line () {
> local f=$1
> awk '{ print length($0) " " $0; }' $f | sort -n | tail -1
> }
>
> $ longest-line american-english-insane
> 60 Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch's
>
> > But in Emacs, what is the elisp implementation for the
> > above task?
>
> This is one better suited for the shell IMO.
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.
> Hm... is that really a word?
No idea.
Best, Hongyi
Re: Find the longest word in the word list file., Stephen Berman, 2021/08/11
Re: Find the longest word in the word list file., Emanuel Berg, 2021/08/11
- Re: Find the longest word in the word list file.,
Hongyi Zhao <=
- Re: Find the longest word in the word list file., Emanuel Berg, 2021/08/11
- Re: Find the longest word in the word list file., Hongyi Zhao, 2021/08/11
- Re: Find the longest word in the word list file., Emanuel Berg, 2021/08/11
- Re: Find the longest word in the word list file., Hongyi Zhao, 2021/08/11
- Re: Find the longest word in the word list file., Emanuel Berg, 2021/08/11
- Re: Find the longest word in the word list file., Hongyi Zhao, 2021/08/11
- Re: Find the longest word in the word list file., Emanuel Berg, 2021/08/12
- Re: Find the longest word in the word list file., Hongyi Zhao, 2021/08/12
- Re: Find the longest word in the word list file., Emanuel Berg, 2021/08/12
- Re: Find the longest word in the word list file., Hongyi Zhao, 2021/08/12