From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: cond* Date: Fri, 26 Jan 2024 22:37:45 -0500 Message-ID: References: <87frzuae9n.fsf@posteo.net> <871qbatqc8.fsf@posteo.net> <87wmsz7lzn.fsf@posteo.net> <87edf1m7lq.fsf@localhost> <87cyui76l9.fsf@localhost> <871qauy1io.fsf@localhost> <87wmsjyi2h.fsf@localhost> Reply-To: rms@gnu.org Content-Type: text/plain; charset=Utf-8 Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25145"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Ihor Radchenko Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jan 27 04:37:57 2024 Return-path: Envelope-to: ged-emacs-devel@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 1rTZW0-0006Kd-Mc for ged-emacs-devel@m.gmane-mx.org; Sat, 27 Jan 2024 04:37:56 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rTZVs-0000kc-71; Fri, 26 Jan 2024 22:37:48 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rTZVq-0000jr-9y for emacs-devel@gnu.org; Fri, 26 Jan 2024 22:37:46 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rTZVp-0004y6-F1; Fri, 26 Jan 2024 22:37:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=Date:References:Subject:In-Reply-To:To:From: mime-version; bh=dBujG8soTrG6avJfSpqrAq8UtNqn5nDxT0vOpaJ/V4U=; b=MfSpkUtcsSmY b0tMpXBBuoojDzcMiaVSy6zSiLwCXJqT9SmoUQ3XruQ7izh7ZcERLGJYckMMNrHujAnIYFox+tJvm 0v8tqC/XqEYNPZbqjGnQ0utAZqirLhKpdQBPfdrSAleF8U7QS5kh0tWbpvGJO33RqE4IyEvXx+Lvw ZowhtwBbgESI4YitlqpOuO9FsEqCyPmwsot4Ecieq6uYUhSCPRxpOtS/iL3NPG702c1HwNz/GYqH2 qLq3G081teMZ1OI2cxjfBieJ+8m5axUp4gyDoxO9MTMyq7Az2SaltFncem6NIcrA/FiBEBc2m+1IE NH+tliSOg/9ceX7mRCe1iw==; Original-Received: from rms by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1rTZVp-0007yh-6z; Fri, 26 Jan 2024 22:37:45 -0500 In-Reply-To: <87wmsjyi2h.fsf@localhost> (message from Ihor Radchenko on Mon, 08 Jan 2024 15:13:10 +0000) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:315456 Archived-At: [[[ To any NSA and FBI agents reading my email: please consider ]]] [[[ whether defending the US Constitution against all enemies, ]]] [[[ foreign or domestic, requires you to follow Snowden's example. ]]] > Other than rx, one missing feature is an ability to match against > multiple values in a single condition: > (defun yant/list-sum (list) > (apply #'+ list)) > (pcase '(1 2 3) > ((and `(,x ,y ,z) (app yant/list-sum (and sum (guard (< 2 sum))))) > (format "%d + %d + %d = %d; 2 is < %d" x y z sum sum))) > ; => "1 + 2 + 3 = 6; 2 is < 6" Understanding this was a struggle, but I think it can be done with (cond* ((match* `(,x ,y ,z) list-of-three)) ((< 2 (+ x y z)) success))) It is not the one condition which is the goal you specified, but given the flexibility of cond* it doesn't need to be one condition. And it is much clearer than the pcase code to do the same job. -- Dr Richard Stallman (https://stallman.org) Chief GNUisance of the GNU Project (https://gnu.org) Founder, Free Software Foundation (https://fsf.org) Internet Hall-of-Famer (https://internethalloffame.org)