From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 7odNK/WWP2CbbQAA0tVLHw (envelope-from ) for ; Wed, 03 Mar 2021 14:02:29 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id AHCqJvWWP2CPcAAA1q6Kng (envelope-from ) for ; Wed, 03 Mar 2021 14:02:29 +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 1FB2D25A06 for ; Wed, 3 Mar 2021 15:02:29 +0100 (CET) Received: from localhost ([::1]:32788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHS56-0006aG-57 for larch@yhetil.org; Wed, 03 Mar 2021 09:02:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHS3E-0005ti-Hg for guix-devel@gnu.org; Wed, 03 Mar 2021 09:00:33 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36288) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHS3D-0004Qv-KS; Wed, 03 Mar 2021 09:00:32 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=36112 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lHS3B-0006Nl-Bh; Wed, 03 Mar 2021 09:00:30 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Magali Lemes Subject: Re: [Outreachy] Use of impure functional programming and use of vlists References: X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 13 =?utf-8?Q?Vent=C3=B4se?= an 229 de la =?utf-8?Q?R?= =?utf-8?Q?=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Wed, 03 Mar 2021 15:00:27 +0100 In-Reply-To: (Magali Lemes's message of "Sat, 27 Feb 2021 00:10:05 -0300") Message-ID: <87a6rks5fo.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: guix-devel@gnu.org Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1614780149; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sxOCHDg62NYqtZFjp0vNep8cfapiWCrU9eKt4DBQb20=; b=neb1/EYs1gw0+12iEH0h7M0nJoG7hoLSJJ74s9Ch1/WvdwJItlKtn3Z/u5AoJtGo4JqNt7 FU1dauCOtN8imyhA8ea2aroBEu+PNOtscKOErzT0L/5hsG9I+A6ggwUN+hmJg/to4LF+7x 3C1tA8Olqvwgzk4P+PVbt0vDgcYrGVMQfoXuZwfPGE6tR6kiHH3zVNIEZZbbNBww2TCEfW Siwzd3wbzN7K6lO3P3rhkS+Wehk3EgAiLvNXDUJr1EjSCjiHQHlB8M+dgD62sf8rVAj3tN GJbSJv2achsM1KXjGxqqipyfjmmvYbTD7pDcUmKNyVDk16F7z4xzYosnvcpCGA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1614780149; a=rsa-sha256; cv=none; b=MwlBnv/F9iuZPnJ6fql9elWyc5ZWHa4bqzqmS3pWmjZtPQXi9VVA3G2L650cgW4liyLkrl jfAKhopodSvwkdZWWuNoKm6Zl0KC7m4mRfMekLBQ8MgwxKqJ69gIicDMQyvglqy+xfZW8O JBeZ7liRswr5mO69y3OwIQNsfc3Jjj6bAiXVXMGn5RHIhwXsENKINcbjaOSna8LNS51+rs 6SZZQTM75IOG7ImhN2CELZv52ORffhj3k0xzmPw2tozAHBBYjA79elR1hcsgFgprjnxZS3 JpNq0GHsSAHFSu6+WyunotO5JFPLcHpCyz6Zvdd6GYd1p+BS9OEim5WK7w7QVw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Spam-Score: -2.86 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Queue-Id: 1FB2D25A06 X-Spam-Score: -2.86 X-Migadu-Scanner: scn1.migadu.com X-TUID: n2FE6iEmYPc/ Hi Magali, Magali Lemes skribis: > As my Outreachy internship approaches an end, I'd like to know which > of the following options is better for walking and displaying the Git=20 > commit history: > 1) having a list and then using for-each it to display the commit > information; > 2) display the list while building it. In addition to Arun=E2=80=99s suggestion, an option would be to achieve #2 = while keeping a functional approach; this can be done using SRFI-41 =E2=80=9Cstre= ams=E2=80=9D. Streams are lazy lists, meaning that the elements of a stream are computed on demand. If you do: (use-modules (srfi srfi-41)) (stream-for-each (lambda (n) (pk (car (gettimeofday)) n)) (stream-cons 1 (stream-cons (begin (sleep 2) 2) stream-null))) You=E2=80=99ll see that the first element is printed before we sleep for two seconds. I don=E2=80=99t know if this could work in your case; the Guile-Git API is = eager (as opposed to lazy), so maybe it=E2=80=99s not directly applicable. > Another question is, could vlists be used? Since it would be fast to > have the commits in a hash table implemented with vlists, we could use=20 > 'vlist-for-each' to display the commits. I haven't seen vlist-for-each > being used anywhere in Guix, so I wondered if there's a special reason=20 > for it not being used, or if it hasn't really been necessary at all > thus far. Vlists are a sort of immutable data structures for vectors; for a regular list, the cost of random access is linear in the size of the list, whereas for vlists random access is =E2=80=9Ctypically=E2=80=9D const= ant-time, almost like a vector. The graph of commits is usually traversed linearly, so the complexity of random access doesn=E2=80=99t matter much. Likewise, in Guix proper, there= are probably few or no occasions where we need vector-like structures, which is why vlists are not used. HTH! Ludo=E2=80=99.