From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id MEPMEKV4VWHSPQEAgWs5BA (envelope-from ) for ; Thu, 30 Sep 2021 10:43:17 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id mHpUDKV4VWGndAAAbx9fmQ (envelope-from ) for ; Thu, 30 Sep 2021 08:43:17 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id DC13D1AE13 for ; Thu, 30 Sep 2021 10:43:16 +0200 (CEST) Received: from localhost ([::1]:59720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVreu-0004XL-26 for larch@yhetil.org; Thu, 30 Sep 2021 04:43:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52708) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVreg-0004Vm-8N for guix-patches@gnu.org; Thu, 30 Sep 2021 04:43:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39885) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVref-0000nj-Lk for guix-patches@gnu.org; Thu, 30 Sep 2021 04:43:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mVref-0006cx-Jd for guix-patches@gnu.org; Thu, 30 Sep 2021 04:43:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50878] [PATCH] union: Resolve collisions by stable-sort'ing them. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 30 Sep 2021 08:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50878 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Attila Lendvai , Liliana Marie Prikler Cc: 50878@debbugs.gnu.org Received: via spool by 50878-submit@debbugs.gnu.org id=B50878.163299133725418 (code B ref 50878); Thu, 30 Sep 2021 08:43:01 +0000 Received: (at 50878) by debbugs.gnu.org; 30 Sep 2021 08:42:17 +0000 Received: from localhost ([127.0.0.1]:51430 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mVrdw-0006bu-Kn for submit@debbugs.gnu.org; Thu, 30 Sep 2021 04:42:16 -0400 Received: from andre.telenet-ops.be ([195.130.132.53]:40926) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mVrdv-0006bl-7p for 50878@debbugs.gnu.org; Thu, 30 Sep 2021 04:42:15 -0400 Received: from ptr-bvsjgyjmffd7q9timvx.18120a2.ip6.access.telenet.be ([IPv6:2a02:1811:8c09:9d00:aaf1:9810:a0b8:a55d]) by andre.telenet-ops.be with bizsmtp id 08iD2600b0mfAB4018iD1H; Thu, 30 Sep 2021 10:42:13 +0200 Message-ID: <9ab183637e8cd645267a37ba0f05319f8b3c72ff.camel@telenet.be> From: Maxime Devos Date: Thu, 30 Sep 2021 10:42:13 +0200 In-Reply-To: References: <20210928214044.437-1-attila@lendvai.name> <57f1435fd83da8c0e0acaef64d5f08e4ca7b3404.camel@gmail.com> Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-xAkXBPzk4Ga+/IzCabQk" User-Agent: Evolution 3.34.2 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1632991333; bh=Ini9LBTP75/Jt2IlI6aq3aUFrnHRvArVWYGm2CbcfQg=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=GEoDf3TEEEkwW/G/8Yxi7ENkDK7keVkjC72uRSRuEqfz5gtj9OOnXSZ3Mhqus+nq1 mI3sji6YJM7FI1L2S/lL0G7QI2uFI1FF2UHUPg9dbVH4MsACyMq3txnJsSK+YfEYU1 t7fpBXuL3ZbDo3B6tJT8DcScwg7VQZuqD2T+zwtGJJhgqj7isgCLSdSVI9xsbWF6s2 IRK3pPZPyrZvAPYh6gMf6J5g/2og2bSvdmsnuRinShocuyx9xVP/5OPutwS05EHv3G jncjq7S49L3/kN83J3ihFjTT80be7F9mPrjmJ6NEmuwsJ95EtJlo7GtuiDBslGds0k JZGdp6lfL8gjQ== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1632991396; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=Ini9LBTP75/Jt2IlI6aq3aUFrnHRvArVWYGm2CbcfQg=; b=DgK8FUtXSAlHLvBUHpd/ZFkW6cUfD+p7JI0oQoLPP0ZmUw/cwJ/ZntkHksRTH+cLKXOvai bYuwRqfCCknYK5ZQIVDgnhxNQo5mt6vso4LXXmpVwmB2Q3ENeyxH18vXTmlvXnK7QEfHKF NAtVXEzm9E1R4gVVQz0Cm5/gyGPLmdHcvzGTTyH8LOlUvWaPjdjdsdiuM7zJ/uVkkeMOZv JVmL2yJtcHbkvIgPAzwcNcGVFHo2km9sVwlObKgoj0BKTONZRrg4dvjH/9LwlLNGxkT4A/ 9k/EfPSVstZpQxDhBr/IlH/i2cTRl+7KZF9rs6uelh9YKL3FuL5Dtc+N+w0RRQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1632991396; a=rsa-sha256; cv=none; b=JMgxhJB1S1eDIREkuQw+xofRVyj8EDOphbmIJWjw3yBJF9Q++gKG6k4OH0ff3LwsGRjJT5 YhLoKuGvzVHc6XKXY16V0TfrDi8RvN/f017ye3lxQHHhTwymVAeoTDoo1OBibLSslJRbIQ 6jtLwwc6oyNwlCRTxbg9qfnEEP1F8W5wGwC1zsN6qqKAZ9bP2huZkm4TP3JZUlCOArJo4g TVI6GAAQsIR+5LusM5td9+7grJm9pm9sxI+oZOEaeQUNhYikVeGntKTPbbTpAY8RDJcYKe VZqL4zv0qy3HC2P8dUMY+6kE1fCEyz9lscY5sAo12P6NrYafOKp+m8FVRyjwOA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r21 header.b=GEoDf3TE; dmarc=fail reason="SPF not aligned (relaxed)" header.from=telenet.be (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -3.40 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r21 header.b=GEoDf3TE; dmarc=fail reason="SPF not aligned (relaxed)" header.from=telenet.be (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: DC13D1AE13 X-Spam-Score: -3.40 X-Migadu-Scanner: scn0.migadu.com X-TUID: SUTymgzH3UZa --=-xAkXBPzk4Ga+/IzCabQk Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attila Lendvai schreef op do 30-09-2021 om 08:10 [+0000]: > > > - (let* ((original-files (list->vector files)) > > > - (count (vector-length original-files)) > > > - (stripped-files (vector-map (lambda (_ el) > > > - (strip-store-file-name el)) > > > - original-files)) > > > - (indices (vector-unfold values count))) > > >=20 > > > - (stable-sort! indices > > > - (lambda (a b) > > > - (string> (vector-ref stripped-files a) > > > - (vector-ref stripped-files b)))) > > > - (vector-ref original-files (vector-ref indices 0)))) > >=20 > > Instead of stable-sort!-ing the indices of a vector, what about stable- > > sort!-ing (map strip-store-file-name original-files) in more or less > > one go? >=20 > the hash also needs to be dropped from the path for sorting to be > useful, but the return value must be the full path, hence the > complexity with sorting the indices, pointing both to the full paths > and the cut parts. You can replace the 'less' argument of 'stable-sort'. Example sorting by the second character of a string: (sort '("za" "yb" "xc") (lambda (x y) (char>? (string-ref x 1) (string-ref y 1))))) IIUC, you would need to replace char>? by string> and string-ref by strip-store-file-name. Greetings, Maxime. --=-xAkXBPzk4Ga+/IzCabQk Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYVV4ZRccbWF4aW1lZGV2 b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7vNkAQDAgk7tcyMnnpquDZroTaTWfQMD JhFccN39qFLYapM/UAD+MMzwqIvnbNtf/Qq88FMnBVURdP/RP3pIvMBpx77xmwE= =YJvu -----END PGP SIGNATURE----- --=-xAkXBPzk4Ga+/IzCabQk--