From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47787) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feM3l-0007Wi-16 for guix-patches@gnu.org; Sat, 14 Jul 2018 11:02:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feM3g-0005nq-5G for guix-patches@gnu.org; Sat, 14 Jul 2018 11:02:09 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:52294) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1feM3g-0005nb-05 for guix-patches@gnu.org; Sat, 14 Jul 2018 11:02:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1feM3e-0002iR-7s for guix-patches@gnu.org; Sat, 14 Jul 2018 11:02:03 -0400 Subject: [bug#32121] [PATCH 3/5] database: Add support for database upgrades. Resent-Message-ID: References: <20180710230247.16639-1-clement@lassieur.org> <20180710230247.16639-3-clement@lassieur.org> <87sh4nldxv.fsf@gnu.org> From: =?UTF-8?Q?Cl=C3=A9ment?= Lassieur In-reply-to: <87sh4nldxv.fsf@gnu.org> Date: Sat, 14 Jul 2018 17:00:58 +0200 Message-ID: <87in5hg8ut.fsf@lassieur.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 32121@debbugs.gnu.org Ludovic Court=C3=A8s writes: >> + (apply max >> + (map string->number >> + (map (cut match:substring <> 1) >> + (filter regexp-match? >> + (map (cut string-match >> + "^upgrade-([0-9]+)\\.sql$" <>) >> + (scandir (%package-sql-dir)))))))) > > I think you can write it along these lines: > > (reduce max 0 > (map (compose string->number (cut match:substring <> 1)) > (filter-map (cut string-match =E2=80=A6) (scandir =E2=80= =A6)))) Very nice! Now it returns 0 if the list is empty (which shouldn't happen) but it makes more sense. > I would rather avoid SRFI-42, not just because I can=E2=80=99t parse it ;= -), but > also to maintain consistency and make the code possibly more accessible. > > In this case I think we could use a simple loop or (for-each =E2=80=A6 (i= ota n)) > and that wouldn=E2=80=99t be bad. iota... Exactly what I was looking for! But for some reason I thought it would be named something like "range" :-) Thank you so much! Cl=C3=A9ment