guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 3/7] import cran: description->package: Also return package d


From: Ludovic Courtès
Subject: Re: [PATCH 3/7] import cran: description->package: Also return package dependencies.
Date: Thu, 01 Sep 2016 13:50:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Ricardo Wurmus <address@hidden> skribis:

> Ludovic Courtès <address@hidden> writes:

[...]

>> In theory it would be possible to do something like:
>>
>>   (define (description->package repo meta)
>>     (stream-cons `(package …)
>>                  (stream-unfold (lambda (state)
>>                                   (description->package
>>                                    repo
>>                                    (first-dependency state)))
>>                                 (lambda (state)
>>                                   (done? state))
>>                                 (lambda (state)
>>                                   (next-dependency state))
>>                                 (make-state propagate (setq)))))
>>
>> … where the state is roughly a pair containing the list of next
>> dependencies and the set of already visited dependencies (to avoid
>> duplicates).
>
> That’s a good hint.  “stream-unfold” makes my head spin, to be honest.

I had that feeling when I first met ‘unfold’, but my head has kept
spinning since then so I’m fine.  ;-)

Here’s an example that should probably be added to the Guile manual:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,use(srfi srfi-1)
scheme@(guile-user)> (unfold (lambda (x) (> x 10))
                             (lambda (x) (* 2 x))
                             1+
                             0)
$2 = (0 2 4 6 8 10 12 14 16 18 20)
--8<---------------cut here---------------end--------------->8---

Ludo’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]