From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: lexicographic list comparison Date: Mon, 12 Sep 2022 14:31:33 -0400 Message-ID: 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="30115"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: sds@gnu.org, emacs-devel To: mattiase@acm.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Sep 12 20:33:39 2022 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 1oXoFX-0007cO-HU for ged-emacs-devel@m.gmane-mx.org; Mon, 12 Sep 2022 20:33:39 +0200 Original-Received: from localhost ([::1]:47918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oXoFW-0003Yn-DP for ged-emacs-devel@m.gmane-mx.org; Mon, 12 Sep 2022 14:33:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXoDh-00028u-L1 for emacs-devel@gnu.org; Mon, 12 Sep 2022 14:31:46 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:36930) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXoDe-0008Ed-3q; Mon, 12 Sep 2022 14:31:44 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 4573D100129; Mon, 12 Sep 2022 14:31:40 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 836BF1000FF; Mon, 12 Sep 2022 14:31:34 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1663007494; bh=fTJDI1k9Ot3ROp/EFXvgY37QZTxYkrCLRRppSmekK24=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=fIgjnzvCoAe2/BORFkxJVproRw4k5ZGUuMgNPq7hDyKmNSjIPn0W9xm0mZ8lVv7PR Fskk4L6BCU5gGQZUHMZpbGZpDbwBKmFPZqRvmLS77YbEjThkQbLzx7KXbn+DOqkoFQ 4LUgwPfXnM9Ca9jdDpSqOO7RLhGPCkQOjZh+7pXBS5GUDDQzFK7aIHo+CaY+SLfn6v KkzXs+bsRSLTBrmdP+8xrJwuXcmUULpNhhFPHpGl3cYNQ1cOfyPtOc0pbeexTagWfM n6D1UEqynQyRPuCduxvKrt7ztC7UBunC5KgZwOw5QIRxcjixHFAWd83kLY/Rn8nuLR K3aVmswSB8mxw== Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 699BF1207FF; Mon, 12 Sep 2022 14:31:34 -0400 (EDT) In-Reply-To: (mattiase@acm.org's message of "Mon, 12 Sep 2022 19:53:42 +0200") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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" Xref: news.gmane.io gmane.emacs.devel:295216 Archived-At: >> I certainly have no intention of comparing strings with numbers &c. >> My question was about a list of _homogeneous_ lists, and comparing to, >> say, lists of numbers, is done lexicographically based on number >> comparison. > > We could certainly add comparison functions for lists, then ones for arrays, > then for hash tables, and so on. Or just write one that works for all > built-in types and impose an ordering between objects of distinct types. It > would be more useful (if harder to write). We could write a `cl-defgeneric` with a few basic instances. Another option is to provide combinators: e.g. provide a `list-compare` function which takes the comparison function to use for the elements and return a comparison function that works of lists of such elements, so you can do things like: (sort foo (list-compare (list-compare #'<))) [ Tho I suspect you'll want those comparison functions to return a -1/0/1 result rather than just a boolean, so you'd need an extra combinator to turn such a comparison function into the kind expected by `sort`. ] -- Stefan