From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Darrington Subject: Re: [PATCH 1/1] Factor out a common pattern into a procedure. Date: Sun, 19 Oct 2014 09:40:36 +0200 Message-ID: <20141019074036.GA4382@jocasta.intra> References: <168a3c777e9011635e3a99fb042253e4d0ca324a.1413685080.git.ian@zenhack.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="3MwIy2ne0vdjdPXF" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58777) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xfl6d-00067i-IM for guix-devel@gnu.org; Sun, 19 Oct 2014 03:40:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xfl6Z-0002vY-92 for guix-devel@gnu.org; Sun, 19 Oct 2014 03:40:47 -0400 Received: from de.cellform.com ([88.217.224.109]:37229 helo=jocasta.intra) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xfl6Y-0002vO-RS for guix-devel@gnu.org; Sun, 19 Oct 2014 03:40:43 -0400 Content-Disposition: inline In-Reply-To: <168a3c777e9011635e3a99fb042253e4d0ca324a.1413685080.git.ian@zenhack.net> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Ian Denhardt Cc: guix-devel@gnu.org --3MwIy2ne0vdjdPXF Content-Type: text/plain; charset=unknown-8bit Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Oct 18, 2014 at 10:03:42PM -0400, Ian Denhardt wrote: The procedure version-take-api extracts the "major.minor" part of version strings; previously this was handled by an expression common to several packages. =20 diff --git a/guix/utils.scm b/guix/utils.scm index 6392914..a179f6b 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -2,6 +2,7 @@ ;;; Copyright =C2=A9 2012, 2013, 2014 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2013 Mark H Weaver ;;; Copyright =C2=A9 2014 Eric Bavier +;;; Copyright =C2=A9 2014 Ian Denhardt ;;; ;;; This file is part of GNU Guix. ;;; @@ -64,6 +65,7 @@ %current-system %current-target-system version-compare + version-take-api version>? guile-version>? package-name->name+version @@ -518,6 +520,11 @@ or '=3D when they denote equal versions." ((negative? result) '<) (else '=3D)))))) =20 +(define (version-take-api version-string) + "Return \".\", where major and minor are the major and +minor version numbers from version-string." + (string-join (take (string-split version-string #\.) 2) ".")) + (define (version>? a b) "Return #t when A denotes a newer version than B." (eq? '> (version-compare a b))) It seems likely to me, that sometime we'll need the number of fields to be = parameterised, instead of hard coded at 2 (for example lynx has a directory component wit= h 3 fields in its URL) Also I don't understand the significnace of the name version-take-api What = does API have to do with anything? How about something like (string-take-fields "1.22.3.04.5" 3) which would r= eturn "1.22.3" Possibly an optional argument specifying the separator might be useful too. J' --=20 PGP Public key ID: 1024D/2DE827B3=20 fingerprint =3D 8797 A26D 0854 2EAB 0285 A290 8A67 719C 2DE8 27B3 See http://sks-keyservers.net or any PGP keyserver for public key. --3MwIy2ne0vdjdPXF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlRDavQACgkQimdxnC3oJ7ONJwCffWEoN+ire0NkV/IqlkIqhwbm 9EsAmwVhVk9KBuY4za4cdhBoiO15sasL =dn/M -----END PGP SIGNATURE----- --3MwIy2ne0vdjdPXF--