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: Wed, 11 Aug 2021 22:17:02 +0800 Message-ID: References: <875ywc9j7i.fsf@gmx.net> 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="8428"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs To: Stephen Berman Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 11 16:18:16 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 1mDp3g-000233-F3 for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 11 Aug 2021 16:18:16 +0200 Original-Received: from localhost ([::1]:39350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDp3e-00071w-9u for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 11 Aug 2021 10:18:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDp2i-00070V-Rc for help-gnu-emacs@gnu.org; Wed, 11 Aug 2021 10:17:16 -0400 Original-Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]:40541) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDp2h-0004Ic-3y for help-gnu-emacs@gnu.org; Wed, 11 Aug 2021 10:17:16 -0400 Original-Received: by mail-lj1-x234.google.com with SMTP id m17so1087958ljp.7 for ; Wed, 11 Aug 2021 07:17:14 -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 :cc; bh=YKIrpB6a1NPYVoZo/OjmQkXPSRS4uTnt/yPkd0jAido=; b=f3718fqj+foEG0rVi7vMVUokKGqZj0de4UM8Odxnu6T63/9ndUp1f+RTCDM6DhpmQD 6BLhA0jajHIMfr2mWQUmKDsBSymhS4svqtFd9Heal3KQb5zFHR8DI3pdaHbgPt0DGW7A fEVoNxCFMvsahCJYuC086Q8mJT8lmj6U2r7ZDKK9AwlRnYVA4GnRZigaMIKtKfu4DFPL OieD/vQf2h3yreAePPp+lewk3Y5H6yqW+tb8pGC4nIDFp+z40c0Z1M/VY8iQepiToowa GojrT5tv2wCbP8uIrpn5eqYCmG2xv/oKq33xLd/n5JgEfyLnpKut5bATPKPorad9YehR HO9g== 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:cc; bh=YKIrpB6a1NPYVoZo/OjmQkXPSRS4uTnt/yPkd0jAido=; b=AtStEzXHSTMzMsWL1Ngmo3Dfrk3vCVZYOoZp4qfZ1V2OihMAcYrawPAhnPhutVILAf Eb0j+878B2rCPTJbxhCGHPRsdXA0QiCbN7zf6qf5dQa2gpAVXI+NVhBH0O7htswMMqgn 3O8Rh8WQnjBCbwejBu+Gk/sHDAYOWMpg1n0zbPkCH46cV2Vw7JS8HGXNoTQb3Zahg/PG P+xA7x32V4CVPORtkSSFjEoLe03SVzOnuusm/Uv6Bm9HUkZWN79axljUkp3561KkTkLl d43HNjY50/8XahbdVUiIzt8IQG6Qne3pKS3wjqLvaRl2xkI1AeV3P13kbXGvHxa5lhvo YzcA== X-Gm-Message-State: AOAM5331ZsaF3GxW9ptK21oKzz2+SsfRShBc9/eUfpc5h2ubqVhljqPN M5f6IvsPeK4vOy4nPF/uvXln4SuNLvYkcop0gRQ= X-Google-Smtp-Source: ABdhPJzPNavENXbytOhMlwlWN1Al9UkbrEqQGqLX2saplvFhJAMrlZR5C2i//QvFJi8L2z+y2+hPH58Sv59HxvhivTs= X-Received: by 2002:a2e:8618:: with SMTP id a24mr23101159lji.246.1628691433538; Wed, 11 Aug 2021 07:17:13 -0700 (PDT) In-Reply-To: <875ywc9j7i.fsf@gmx.net> Received-SPF: pass client-ip=2a00:1450:4864:20::234; envelope-from=hongyi.zhao@gmail.com; helo=mail-lj1-x234.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:132454 Archived-At: On Wed, Aug 11, 2021 at 9:58 PM Stephen Berman wrote: > > 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)))))) Good. A bubble sorting, IIRC. > => > Simulation > > Steve Berman Best, Hongyi