chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Alist versus Hash-table


From: Christian Kellermann
Subject: Re: [Chicken-users] Alist versus Hash-table
Date: Tue, 12 Nov 2013 11:40:46 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Hi!

* Loïc Faure-Lacroix <address@hidden> [131112 11:33]:

> To do the same job, it takes 650s for the non destructive function
> and 0.014s for the use of destructive ???alist-update!???. Anyone
> can explain why is this so slow? 

The non-destructive version creates a new list:

#;1> (define l '((a . foo) (b . bar)))
#;2> (alist-update 'c 'baz l)
((a . foo) (b . bar) (c . baz))
#;3> (alist-update 'c 'baz l)
((a . foo) (b . bar) (c . baz))
#;4> (eq? #2 #3)
#f

> Also what is the big difference between alist and a hash-table
> other than alist doesn???t seem to hash objects. After testing
> again, I realize that ???alist-update!??? isn???t even adding new
> element to the current list.

alist-update! updates the *element* destructively. It does not set
the list itself. This may be a bit confusing. I think alist-update!
is a misnomer really but I cannot think of a shorter name that's
better suited.

Does this help?

Kind regards,

Christian


-- 
In the world, there is nothing more submissive and weak than
water. Yet for attacking that which is hard and strong, nothing can
surpass it. --- Lao Tzu



reply via email to

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