From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id mAiPL3b+VWE34AAAgWs5BA (envelope-from ) for ; Thu, 30 Sep 2021 20:14:14 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id kFVOK3b+VWH5SwAA1q6Kng (envelope-from ) for ; Thu, 30 Sep 2021 18:14:14 +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 553B1289CF for ; Thu, 30 Sep 2021 20:14:14 +0200 (CEST) Received: from localhost ([::1]:58378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mW0ZR-0006ze-2K for larch@yhetil.org; Thu, 30 Sep 2021 14:14:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mW0ZG-0006xg-OI for guix-patches@gnu.org; Thu, 30 Sep 2021 14:14:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42414) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mW0ZG-0005Sd-BU for guix-patches@gnu.org; Thu, 30 Sep 2021 14:14:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mW0ZG-0001q2-74 for guix-patches@gnu.org; Thu, 30 Sep 2021 14:14:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50878] [PATCH] union: Resolve collisions by stable-sort'ing them. Resent-From: Liliana Marie Prikler Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 30 Sep 2021 18:14:02 +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: Maxime Devos , Attila Lendvai Cc: 50878@debbugs.gnu.org Received: via spool by 50878-submit@debbugs.gnu.org id=B50878.16330256397050 (code B ref 50878); Thu, 30 Sep 2021 18:14:02 +0000 Received: (at 50878) by debbugs.gnu.org; 30 Sep 2021 18:13:59 +0000 Received: from localhost ([127.0.0.1]:53960 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mW0ZC-0001pe-Sp for submit@debbugs.gnu.org; Thu, 30 Sep 2021 14:13:59 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:55241) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mW0ZB-0001pR-IW for 50878@debbugs.gnu.org; Thu, 30 Sep 2021 14:13:57 -0400 Received: by mail-wm1-f66.google.com with SMTP id s24so5367955wmh.4 for <50878@debbugs.gnu.org>; Thu, 30 Sep 2021 11:13:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=OLYKcBGpQ+I5WRTfS04SBFonATGzEi/IQ+vs8raiO7w=; b=L7waezu5rB4TUEQZ6GpshImvqoo3fv2h58hmYDjb7F8/FLK/VZHKeuL7s4FaosAzia vYRWeldYrpcYXfZCZfOIYMimtGQcN6tneyQ0ohJORXLT+Hp5/dWtLyR7P4qp7H48UhhU MglzbX2uHyCaTo6cWo9m4grH5BD9XMv9FBf96ei2YxtkOIF/GUMza434znELZReK2ju4 KmHEKG54x3kQP0hjnHyIj5W+2hcNDczZOmetx9Ou2uFQ+uj4TR/t8U2s9AXnPwQomw6j 0hzGtDKmbyj5fbapQGFpwuyj5QDE1Mz+ffXyKisA//OFHqNe7Www6Fa/ODs+2XpduOSw A/RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=OLYKcBGpQ+I5WRTfS04SBFonATGzEi/IQ+vs8raiO7w=; b=pWTJ4MKVatoN2jmsFLNbctmQJwbWY/9pWURm5itwhOLuBdE6wNQqfwZDp9Hi4QzIC9 sbo2euqNic+VGohgH9a1u5xe/Kb/0tTtMazIuelC5pHqs/t4u9eoqWjmTA08BV3tImMk /ZsLEJeduZPGbL2TotM9JB6XQl18LdqnASsHMsWDpQCIpZi0/mO/fGamemunDAshfwau EhNMka5eLmOtthod7tI7Pj+12KsFCgntCz0zNSuXzCVLbqEwjrSeas7/ojKTBwVvqskq N6ZAFjeK8IoyIwXx9LYuv2Cf60cPaF7hHSbYUdd9+qx5bXohYPbv4/oUlPKPdI5paN/z 3qMw== X-Gm-Message-State: AOAM531Fr6e315kojlcrL4BQm+0GEptFNAh7s5VIlajFfh4k745WmK8E KE6PWVKv+piECUm6Mj+ZmOg= X-Google-Smtp-Source: ABdhPJxMzw/1WjFiUBB3QDbJl4guGhovw8dH+nHMb3k96C+azT/3u2hiOxhaaAXsKfxjReRJ8r+JUQ== X-Received: by 2002:a7b:c1d2:: with SMTP id a18mr666737wmj.28.1633025631774; Thu, 30 Sep 2021 11:13:51 -0700 (PDT) Received: from nijino.fritz.box (85-127-52-93.dsl.dynamic.surfer.at. [85.127.52.93]) by smtp.gmail.com with ESMTPSA id a18sm2088934wrw.0.2021.09.30.11.13.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 11:13:51 -0700 (PDT) Message-ID: From: Liliana Marie Prikler Date: Thu, 30 Sep 2021 20:13:49 +0200 In-Reply-To: <9ab183637e8cd645267a37ba0f05319f8b3c72ff.camel@telenet.be> References: <20210928214044.437-1-attila@lendvai.name> <57f1435fd83da8c0e0acaef64d5f08e4ca7b3404.camel@gmail.com> <9ab183637e8cd645267a37ba0f05319f8b3c72ff.camel@telenet.be> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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=1633025654; 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: content-transfer-encoding:content-transfer-encoding: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=OLYKcBGpQ+I5WRTfS04SBFonATGzEi/IQ+vs8raiO7w=; b=RSxV2qU+3x6WnSV74zCWjdgE3RA5M94HR2lfaggXMGTvwkSG7Zy0DQ86NCK/LnmYVpjvqj CviIZ3zKbNEem6RCxz2SZDdPCoUarDB7eCuH23LPK2wk8DWnLgihXzmT/5yYpeuoihydMR x8fWGu0eq53ciGtkECLiXsw3I+C6pqw8Wj8DwOf9Uv191awijnWRuk8srNLT+z0XOq0x66 BRpAmQgkZaBONEGGRPGdvMwF15kU2phHKdJwb+RoLIhzmahgDioZTcbBnX8ZRYJtUdq0V2 ElUfBTmHR88q1EiZ1rbIiXeIMoBTaM731z+SHfXa6ywvG2IlM2EWjscR4Zd5BQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633025654; a=rsa-sha256; cv=none; b=V2QhdeC5d/hE0zcRmtzgvyUZVHJSYsDpggQwikhbuUvIzDIUJpf3HD7CYRkDHwhw6he/wL 6z2fBN2qtNqrD42qbUM4fgv5PlEHAoS8tl02XDMPGkW42+vUe5g69n1VRJl7sQT5Q4v6d/ 8dwgOEhlIGFFGAhpvTxAEtyxNwPdspU+hbYJ98oxgqQlc/KGZNIcsoMOZ0/p4kkXTIpBeD I7tfWs9UYAO+uQhNJgwsvhN0BX6XCHbLifxQ203fcwu/0SQCLsPeTeZIHor1Fy//BqjP/a LLWkVEpaK+AGju0MYh+di1Q8rJU/e8O5ZsU0QMnif8xRd4oCh4AUiCsfC052TA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=L7waezu5; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (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: -1.30 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=L7waezu5; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (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: 553B1289CF X-Spam-Score: -1.30 X-Migadu-Scanner: scn0.migadu.com X-TUID: VNGS9JQDpSO7 Am Donnerstag, den 30.09.2021, 10:42 +0200 schrieb Maxime Devos: > 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))) > > > > > > > > - (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)))) > > > > > > 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? > > > > 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. You could also store a mapping of long file name to stripped file name in a hash table for fast lookup, so as to not compute (strip-store- file-name) over and over. That way you can stable-sort! the long names, but don't forget to list-copy them at least for functional purity. Greetings, Liliana