From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao Newsgroups: gmane.emacs.help Subject: Re: Find the longest word in the word list file. Date: Thu, 12 Aug 2021 10:10:47 +0800 Message-ID: References: <87a6loarpi.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24115"; mail-complaints-to="usenet@ciao.gmane.io" To: Emanuel Berg , help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 12 04:11:50 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 1mE0CD-00065h-Qv for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 12 Aug 2021 04:11:49 +0200 Original-Received: from localhost ([::1]:60380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mE0CB-00015e-RK for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 11 Aug 2021 22:11:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mE0BT-00015U-6h for help-gnu-emacs@gnu.org; Wed, 11 Aug 2021 22:11:04 -0400 Original-Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]:36717) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mE0BR-0003UD-0j for help-gnu-emacs@gnu.org; Wed, 11 Aug 2021 22:11:02 -0400 Original-Received: by mail-lj1-x232.google.com with SMTP id y7so8057375ljp.3 for ; Wed, 11 Aug 2021 19:11:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=gYXV2thkXj2JoTUIifUijjfj9yUkJZ7YD13Qhx2GFoU=; b=oYeDOdTeuSmYgxE+Oi/nJjLRpms6dUraXEH8m0RkJ9HIuftRNxfTwJsE+UjWeX9I/X eG1R5/gE5K6q1cOPR8BThOBfoBVyCl64bigjNPg0oI8jQRnozkpN6GWmY20JcCdbsKX+ 5B6ikyNDXRG0Ght+e/zPIr7mh1CGA9dU1IvAdjjeVTxll37SLpE5hDj9kud73H66bYTd j+IOSbLQS1iZNLoMcLMq43iivxABCCo9SijeyN5RAonPyJHOLqNMq5rwXw5h73fpJyyJ PETW4A7+hb3mR9YFFG0Dj5rEFB6BAbttbHYYPrQvS7V0GnthIJXS+uUk6LTCfyW4L5yi fCYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=gYXV2thkXj2JoTUIifUijjfj9yUkJZ7YD13Qhx2GFoU=; b=pRK/c8v8PWad2ClVQJs2JJr+q278PXG2uxlDF80mII02b2u/Tl5muoJ6Sehhi3c4lz DBQ89X+LJAA84S3xzuJJLSnBOnUP0ZGtcQuXANixeUun/OCIZLm8+hdB3YLh1LoJI4Li aAjxjQPR86Tsb4/ITEaQJAjMCS4QQ99AOD9qDF5YJv9OGFzicp9NmWUdA3XXsrajbHU7 YY7EHqVxElMBMxjp0Et9DpTWIGoIeYE0ZSVEfZMpdOhSXaAcpKYWyZHeOsotKF/8Yo/K WPt7HuJbLdT3zBvnZgn0AranovGeT457sJVLl8+DxJo6NmbmsPSY9GGngNO2Mvcq9mpx ApyA== X-Gm-Message-State: AOAM5324/nyPiGH5OA8bz7pXk1riQyXRyIj70jRAUMGqNNjJYJ7ZofLQ Gil8ywgzFv8G2hew4pQ2tB/x4n7CT+n/VQJXQuY= X-Google-Smtp-Source: ABdhPJxKUntDVDD1PIxLz69OKCX2kNBXzf+BO2PBgWrIm74GjHTybx4GAoksEYIR6hbTBUBBOR6Ciuy3SWKnyEHQIEU= X-Received: by 2002:a05:651c:12c4:: with SMTP id 4mr1136263lje.320.1628734258763; Wed, 11 Aug 2021 19:10:58 -0700 (PDT) In-Reply-To: <87a6loarpi.fsf@zoho.eu> Received-SPF: pass client-ip=2a00:1450:4864:20::232; envelope-from=hongyi.zhao@gmail.com; helo=mail-lj1-x232.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, 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:132462 Archived-At: On Thu, Aug 12, 2021 at 12:09 AM Emanuel Berg via Users list for the GNU Emacs text editor 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