From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.help Subject: Re: Find the longest word in the word list file. Date: Wed, 11 Aug 2021 15:58:25 +0200 Message-ID: <875ywc9j7i.fsf@gmx.net> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34810"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: help-gnu-emacs To: Hongyi Zhao Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 11 16:00:57 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mDomu-0008qm-Md for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 11 Aug 2021 16:00:56 +0200 Original-Received: from localhost ([::1]:43412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDomt-0002Uk-Jo for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 11 Aug 2021 10:00:55 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58644) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDokb-0007W7-Bv for help-gnu-emacs@gnu.org; Wed, 11 Aug 2021 09:58:33 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:36635) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDokZ-0000LD-3K for help-gnu-emacs@gnu.org; Wed, 11 Aug 2021 09:58:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1628690307; bh=kBHv3MeIMGmVWdWBwnsex41SiATvLneFKWu4Jk2Of/o=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=AySJ0jOwwl1bS1BUoj+bEN1J7qSAbl8ljUa9PgAi32A87+X1OzQGQuD76bFSrf1G4 ldbIWHYpTE2oUXC/zRmJ6hX4vW+FBl0mRCoHNVt44a2XH0u6wlR/dVrvFeTX2dRtjK 7yqLQeYgPo2ivRgyGKkYReY2CTeauOAano7FJLyI= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from strobelfs ([92.73.76.192]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MwQT9-1n5E9O0KA9-00sPDm; Wed, 11 Aug 2021 15:58:27 +0200 In-Reply-To: (Hongyi Zhao's message of "Wed, 11 Aug 2021 07:14:05 +0800") X-Provags-ID: V03:K1:2PYrmHQ8bo3pqjPcIQnnG3x5J8ytJ8sJ/4BcGn7oVFVwrGU6l2q 3QBxuRg0akPa1vYCs8Paa348xawaEJ4xYX9UEtPqgxjvvSEDORAPBD2VbcfbjIcQ5d8NALs 4R7yac8FSQ56/Clu/29leEgjzKDJQ0BsPNumZHU0SVGrVipGIBGi+cW0c1DttJBhi/0VUjZ 1ImyLH6mQFbk590KZjEXw== X-UI-Out-Filterresults: notjunk:1;V03:K0:g5JPlOlEVmg=:KUlNXI5Laj+JZSt1XlUWUZ XZNqcg5S68gR9xtd9p/KVTOmjPr6kZBMAAXPduLW4L9nQpV0oRl7Gkx0TJymFtAgDBwjfua+u alDc451i2Coh9cr0yQANlIkBkz7jsYIOXalOmNLo9DinkfSLlI+r4VE4g+uZ2vFM0ZBVJRUnR wFgC1BfoXbOb4sIqRdTjGr3iOFD3o+j0UahRyMRb1AsbehaTkanTfzgAQcCtq42gX6uw4nFy3 7dg90MSoxVg+k2ZuPP0F5evEKyXvJW8mcRC4UROkqvbiUcBjNPz2BDdqEOFPdAhGBVyr1buyU +bD3oSoQ9PSRzt/9N7fuTht1KEn6kynQ1EmZ9SC/Osiet82kzU7YZQcXEyyk8CoIcdRSVYcU+ MtVvlObQauRyZCs1oLlOtuCb6aMw0Pwdw7kYc5yPaEoceD+gFJNGRE/o6k6VE0ZnUwnHIjKBS rSfUXmu5O2nPqyRTm05amkfS+4aCca1vzIliMfKkVncX3ebhU88OspoavKPkPiksKuXo2rsNi Jj5SflZbCnSuQaMlHA0eycDG6W+xnMu51FZPOerJ1zg+vx++1mihnd8YM9ur1seO5RexmA+3p m2YodtV42JSMaeegipgg8e+QETlEqcAY9w9LwQaAVLvjpEGKIpGPQHRaelzcrbRt/d2ZwvUa3 hEBvE2rorFcaOd9AJQr8UVJLvdNIofo77FCDKy+FiZlxIgoSP9si2cMltEELPSTUciS8rMI7w UcNjq59xZsv66F7mq3dPm7EX1xn4+2v48hHvHEs1pPyhyNQej72HuJlQJm/redJ+6TPU6Kg7 Received-SPF: pass client-ip=212.227.15.18; envelope-from=stephen.berman@gmx.net; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:132453 Archived-At: On Wed, 11 Aug 2021 07:14:05 +0800 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 > > 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