Alex Kost <[email protected]> skribis:

> Ludovic Courtès (2016-04-16 01:23 +0300) wrote:

[...]

>> If you choose to take the ‘define-values’ approach above, I think you
>> can just list they keys already in the vhash:
>>
>>   (define-values (package-by-something-file package-something-files)
>>     (let* ((table (delay …))
>>            (files (delay
>>                     (delete-duplicates
>>                       (vhash-fold (lambda (file _ result)
>>                                     (cons file result))
>>                                   '()
>>                                   (force table))))))
>>       (values …
>>               (lambda () (force files)))))
>
> Great, thanks!  I'm going to use this variant.  Is there a preference
> for 'delete-duplicates' over this?:
>
>   (vhash-fold (lambda (file _ result)
>                 (if (member file result)
>                     result
>                   (cons file result)))
>               '()
>               (force table))

Both are O(n²) and have similar readability, so both are fine with me!

Ludo’.

Reply via email to