{"id":10019,"date":"2021-10-04T13:16:05","date_gmt":"2021-10-04T17:16:05","guid":{"rendered":"https:\/\/irreal.org\/blog\/?p=10019"},"modified":"2021-10-04T13:16:05","modified_gmt":"2021-10-04T17:16:05","slug":"kitchin-on-elisp-data-structures","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=10019","title":{"rendered":"Kitchin on Elisp Data Structures"},"content":{"rendered":"<p>John Kitchin has another video up on his <a href=\"https:\/\/www.youtube.com\/playlist?list=PL0sMmOaE_gs3E0OjExoI7vlCAVygj6S4I\">Scimax Channel<\/a>. This time, it\u2019s about <a href=\"https:\/\/www.youtube.com\/watch?v=HyFbIWvmV0A\">elementary Elisp data structures<\/a> and their manipulation. He considers<\/p>\n<ul class=\"org-ul\">\n<li>Strings<\/li>\n<li>Lists<\/li>\n<li>Vectors<\/li>\n<li>Alists<\/li>\n<li>Plists<\/li>\n<li>Hash tables<\/li>\n<\/ul>\n<p>Strings aren\u2019t really a data structure in the sense of the others but they are, in effect, character arrays and it\u2019s possible to extract or insert data into a string.<\/p>\n<p>The premier Lisp data structure is, of course, the list. After all, its name appears on the marquee. Kitchin describes the need and use of quoting and quasiquoting and various ways of accessing list elements. I\u2019m not really a Lisp old-timer but I\u2019ve been at it long enough that I still prefer the <code>car<\/code> and <code>cdr<\/code> primitives to the newfangled inventions such as <code>first<\/code>, <code>tail<\/code>, <code>cl-first<\/code>, and all the rest. If I need an element after the third or fourth, I\u2019ll use <code>nth<\/code> or <code>elt<\/code>. Kitchin likes the <code>cl-*<\/code> constructs and as usual Emacs lets you have it your way.<\/p>\n<p>Like me, Kitchin doesn\u2019t use vectors very often and doesn\u2019t have much to say about them but they are simple and easy to use.<\/p>\n<p>Alists and plists are two variations on the same theme. They\u2019re both lists of key\/value pairs differing in their representation and access means. A good argument can be made that we don\u2019t need both but they exist for <a href=\"http:\/\/www.catb.org\/jargon\/html\/H\/hysterical-reasons.html\">hysterical raisons<\/a> and Lispers tend to use them both.<\/p>\n<p>Finally, there are hash tables. The idea is pretty well known by now although they are commonly called dictionaries in other languages. They are, again, key\/value pairs but have a generally \\(O(1)\\) lookup time while alists and plists are \\(O(n)\\). That doesn\u2019t matter for small lists but with hundreds or thousands of items the \\(O(n)\\) can add up so hash tables make sense for that case.<\/p>\n<p>Even if you\u2019re familiar with using hash tables in Elisp, you may not be familiar with using \u201creader notation\u201d for initializing a hash table. It really makes sense only for small hash tables\u2014or for writing out and then later reading in a hash table.<\/p>\n<p>The video is just short of 26 minutes so plan accordingly. As usual with Kitchin\u2019s videos, it\u2019s well worth the time to watch it even if you\u2019re an experienced Elisper.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>John Kitchin has another video up on his Scimax Channel. This time, it\u2019s about elementary Elisp data structures and their manipulation. He considers Strings Lists Vectors Alists Plists Hash tables Strings aren\u2019t really a data structure in the sense of &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=10019\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[26,18],"class_list":["post-10019","post","type-post","status-publish","format-standard","hentry","category-general","tag-elisp","tag-emacs"],"_links":{"self":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10019","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10019"}],"version-history":[{"count":1,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10019\/revisions"}],"predecessor-version":[{"id":10020,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10019\/revisions\/10020"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}