I am reading a book about Common LISP and the author says : “An alist consists of key/value pairs stored in a list.”
So it made me think, is this the same thing as a Dictionnary in C# or not?
If so why?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is a distinction between abstract concepts and concrete data-structures.
A dictionary is an abstract concept – a mapping of keys to values. It can be implemented with several different approaches:
C#’s Dictionary is a data-structure that supports (amortized) constant lookup time, like CL’s hash-table. In this regard it is different from alist, that has linear lookup time. Also alists don’t depend on element’s hash-code in order to store/retrieve it. The API of alists is also different, than Dictionary’s. There’s
assocandrassocto lookup an element from the left side and right side respectively. (So, unlike in a conventional dictionary, there can be multiple mappings of the same key to different values in an alist). Also there areaconsandpairlisto construct analist.EDIT
And, finally, there’s no standard function to remove an item from alist.You can delete an element with
(remove key alist :key #'car). But note, that this operation leaves the original list intact and returns a modified list as a result.