On 24-09-2022 11:29, Ludovic Courtès wrote: > Hartmut Goebel skribis: > >> * guix/import/gnome.scm(latest-gnome-release): Rename >> to (import-gnome-release), add keyword-argument 'version'. If version is >> given, try to find the respective version >> [find-latest-release]: New function, based on former code. >> [find-version-release]: New function. > > [...] > >> + (define (find-latest-release releases) >> + (fold (match-lambda* >> + (((key . value) result) >> + (cond ((even-minor-version? key) >> + (match result >> + (#f >> + (cons key value)) >> + ((newest . _) >> + (if (version>? key newest) >> + (cons key value) >> + result)))) > > Please reindent ‘match’ as it was. "guix style" is IMO not usable here (: "guix style" puts closing parentheses on the wrong line"). >> + (define (find-version-release releases version) >> + (fold (match-lambda* >> + (((key . value) result) >> + (if (string=? key version) >> + (cons key value) >> + result))) >> + #f >> + releases)) > > I guess we could start at the first match instead of traversing all the > list, no? How about: > > (define (find-version-release releases version) > (find (match-lambda > ((key . value) > (string=? key version))) > releases)) > > ? (1) according to "guix style", this should be (define (find-version-release releases version) (find (match-lambda ((key . value) (string=? key version))) releases)) (2) Isn't this an inline definition of 'assoc' (except for replacing equal? by string=?)? (use-modules (srfi srfi-1)) ; the third argument is only documented in SRFI-1 Asosciation Lists (define (find-version-release releases version) (assoc version releases string=?) Some code duplication can be avoided here. Greetings, Maxime.