From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id YH8eOcMwFmNBZAAAbAwnHQ (envelope-from ) for ; Mon, 05 Sep 2022 19:24:20 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id kPUJOcMwFmOOywAA9RJhRA (envelope-from ) for ; Mon, 05 Sep 2022 19:24:19 +0200 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 A794439DD3 for ; Mon, 5 Sep 2022 19:24:19 +0200 (CEST) Received: from localhost ([::1]:34160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVFpa-0000c9-NA for larch@yhetil.org; Mon, 05 Sep 2022 13:24:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50876) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVFpF-0000bf-FZ for help-guix@gnu.org; Mon, 05 Sep 2022 13:23:57 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:37855) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oVFpB-0001s9-VB for help-guix@gnu.org; Mon, 05 Sep 2022 13:23:57 -0400 Received: by mail-wr1-x430.google.com with SMTP id n17so12185493wrm.4 for ; Mon, 05 Sep 2022 10:23:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:to:from:from:to:cc:subject:date; bh=Ev9DSrPZ3tGXqiv4gjN66HKXuXIOpRCZCZdz2VOfVPU=; b=UKETY7LqNb2Qdc63ERW777WQcpZxiSLj37AddOPrvg1tb2DYapAMyFMepsJKiC+7+u F6zNQ+XM3u4z0NM9l8BgRblfK121ekmZLMcPV8sdn2JvEjjzhFgfchx/IgSlDHiGsRDl ygYiiMHweNaOVJH3kqJb5hStyltaxqFt7hqohMTDPbuZ9vHnDaJX0gVAmRlBhayBoHqP i2YzpdDyjd0sggvmEWQVMKUDuRfXKvFK4Upjg/po1NJ/JAUvyrRBXOd2n5V6VvSHoewn yhcDig+OhE17a3UOq72hhKS25wbgi+BkNNuCf6WIT2a7FTxNTVLPPQvqtaRsHvugy5Fd 2GwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:to:from:x-gm-message-state:from:to:cc:subject :date; bh=Ev9DSrPZ3tGXqiv4gjN66HKXuXIOpRCZCZdz2VOfVPU=; b=bJqzFG03U7arNsdfwHUG/PZ/36tIqsHaSyzt+XoV9Biri6JJUjaz5Gj8jRcg61HKiD AAmIjgj0ENL4kdJ+RPSb9Bm+SKdJtD76Vb0U4KZkRQy0lNVQky93nJJ6tChBiz3GcEH0 kHUoljHnwBSIU9kUmS7ApJCqhs5NkSiyk0xat5vtb4yl1g96SaiKbqCJjjouG7Fji+kK 8nalY86r/PzCt9WuovkOb20NkIJD6ps1xoH98MTomxDZix/LnG6jqYjHU41TM+Mg8kGf sC3/3qmWrpLA6e35oPNFF5CsOwwLg3uHx5muMt/IMbpX24R1bWDS8WEQQT7ICSrDQEoJ bkBg== X-Gm-Message-State: ACgBeo1tvajFapf+dIBUDhl+5E6FOV/LLvLK1nUeYZTnm3pa2tiTge2Z F+9v4gC+FWXp7K1gAe/saLg3UNmF+6I= X-Google-Smtp-Source: AA6agR5ieNJrpIHASxihfkWFLbWAh+ssj2Ewc6M4KPj2UXIMYyvxEFQiDUE0K0qpH9oH9zILzDgioQ== X-Received: by 2002:a5d:6843:0:b0:228:8977:a6cb with SMTP id o3-20020a5d6843000000b002288977a6cbmr3226632wrw.605.1662398632574; Mon, 05 Sep 2022 10:23:52 -0700 (PDT) Received: from pfiuh07 ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id v10-20020a05600c15ca00b003a5dadcf1a8sm10996840wmf.19.2022.09.05.10.23.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 10:23:52 -0700 (PDT) From: zimoun To: jgart , Guix Help Subject: Re: a vector of colors In-Reply-To: <20220809205815.GB29308@gac> References: <20220809205815.GB29308@gac> Date: Mon, 05 Sep 2022 18:37:01 +0200 Message-ID: <87o7vtrd5e.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=zimon.toutoune@gmail.com; helo=mail-wr1-x430.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-guix@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+larch=yhetil.org@gnu.org Sender: "Help-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1662398659; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=Ev9DSrPZ3tGXqiv4gjN66HKXuXIOpRCZCZdz2VOfVPU=; b=Thzc2wz0AcmtQtprzqtupiAq3wu+xMCrqEMHcM+aIhm60kGFMP7E30n401muUxlMNwmR0B hgVQp1Wbol+DaNDDtMzm6KbViYM9eZa0+5We+sWIKGaL+wry1yejcUV66NJVjWCu7ObD3W vkE+qOf8zF/8MJ+ZFrKWF0lWKG12B6Ax0o8utUq6WRz/iJ4vbplElIcNQ76VuZqt2B2czb A62U18JWNix8y65kwD9s0DN9DMHge8BLMZxtOO90xRhYQwh9n6vBS8GGCVtMM1c2ASNYeF qctsGVh6rjiMva1IklGNcnCPXhw1K28T9YOc3HSX8mKJRfFmvdq5yiOULxNQ4A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1662398659; a=rsa-sha256; cv=none; b=A/EMftgpAZubrVRFQBhTjVgnX8v1ESYSZgSflnH8xNTC7B0Qqx/CJI+DE/pnTcE+2MZoPb JjjcPcsuI45kNBRIC3rv4RGVVibf4AqRQ5YqNCkWE1XRyeQLXTFanI7zi/SXaLd3gNi6eb NpsejuutihEIDT57fBkj3seiiJZpQU5sXDXG8jASOO3v/7hJpofqllJtxG6wa9RWGyc0k2 Zax7eGwidsECAYuvZp1mGsdJ7M5G0PqBW9LFmR90eSQBTo4kreozxaDVjCwYM/bB5zwbmV 3kJ5o9mEs7qRbFzqL9amRnmog9QD+X1z0ul+BLYcD2gGWh1xBWTCYJGJY1VSDw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=UKETY7Lq; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -4.07 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=UKETY7Lq; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: A794439DD3 X-Spam-Score: -4.07 X-Migadu-Scanner: scn0.migadu.com X-TUID: fH5VbzosHmqa Hi, A bit late. :-) On mar., 09 ao=C3=BBt 2022 at 20:58, jgart wrote: > Why was this defined as a vector instead of a list? > > (define %colors > ;; See colortbl.h in Graphviz. > #("red" "magenta" "blue" "cyan3" "darkseagreen" > "peachpuff4" "darkviolet" "dimgrey" "darkgoldenrod")) and you mean replace =E2=80=99pop-color=E2=80=99 by, --8<---------------cut here---------------start------------->8--- (define (pop-color hint) "Return a Graphviz color based on HINT, an arbitrary object." (let ((index (hash hint (length %colors)))) (list-ref %colors index))) --8<---------------cut here---------------end--------------->8--- but I guess =E2=80=99list-ref=E2=80=99 is slower than =E2=80=99vector-ref= =E2=80=99; as specified by the documentation: Vectors are sequences of Scheme objects. Unlike lists, the length of a vector, once the vector is created, cannot be changed. The advantage of vectors over lists is that the time required to access one element of a vector given its position (synonymous with index), a zero-origin number, is constant, whereas lists have an access time linear to the position of the accessed element in the list. However, the difference is probably not visible here. Cheers, simon