guix-devel
[Top][All Lists]
Advanced

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

Re: Merging guix.el


From: Ludovic Courtès
Subject: Re: Merging guix.el
Date: Mon, 01 Sep 2014 14:10:47 +0200
User-agent: Gnus/5.130011 (Ma Gnus v0.11) Emacs/24.3 (gnu/linux)

Alex Kost <address@hidden> skribis:

> Ludovic Courtès (2014-08-31 18:59 +0400) wrote:

[...]

>> The key is ‘vhash-fold*’ (info "(guile) VHashes").  It allows you to
>> traverse all the entries associated with a given key:
>>
>> scheme@(guile-user)> (vhash-cons '("guile" "2.0") 'foo
>>                               (vhash-cons '("guile" "2.0") 'bar
>>                                           vlist-null))
>> $12 = #<vhash 39240a0 2 pairs>
>> scheme@(guile-user)> (vhash-fold* cons '() '("guile" "2.0") $12)
>> $13 = (bar foo)
>>
>> I think that answers your question, right?
>
> Absolutely; sorry for missing that feature.  But will it be a real
> optimization?  If I want to get information for all packages, I have to
> perform ‘vhash-fold*’ on ‘manifest-name->entry’ vhash for each package
> (to get installed outputs).  With hash-table, I just need to use
> ‘hash-ref’ for each package.

‘vhash-fold*’ iterates only on the values associated with the given key;
it has time complexity linear in the number of values associated with
that key.  So no worries here (and again, 90% of the time there’ll be
exactly one package corresponding to a name/version pair.)

> Also I need to fold over unique names (I use ‘fold-manifest-entries’
> from “guix-main.scm” for that) and I have no idea how vhash can help
> there.

Would ‘vlist-fold’ work?

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (vhash-cons 'a 1 (vhash-cons 'b 2 (vhash-cons 'a 3 
vlist-null)))
$2 = #<vhash 26fd3a0 3 pairs>
scheme@(guile-user)> (vlist-fold cons '() $2)
$3 = ((a . 3) (b . 2) (a . 1))
--8<---------------cut here---------------end--------------->8---

> Yes, I think dealing with ‘set-current-manifest-maybe!’ is not so
> important, it may wait for better times, thanks :)

Yes.  :-)

I’ll check the doc later today, but it seems this is essentially ready
for merging, no?

When we merge, would you like to rewrite history and make the whole
thing appear as a single “perfect” commit, or just merge ‘emacs-ui’ into
‘master’?  (I often do the former, but I’m fine with the latter here.)

Thanks,
Ludo’.



reply via email to

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