emacs/var/elfeed/db/data/aa/aa2a1b5dcb80e5ad2b53fb47201c855611535baf
2022-01-03 12:49:32 -06:00

16 lines
2.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>John Kitchin has another video up on his <a href="https://www.youtube.com/playlist?list=PL0sMmOaE_gs3E0OjExoI7vlCAVygj6S4I">Scimax Channel</a>. This time, its about <a href="https://www.youtube.com/watch?v=HyFbIWvmV0A">elementary Elisp data structures</a> and their manipulation. He considers</p>
<ul class="org-ul">
<li>Strings</li>
<li>Lists</li>
<li>Vectors</li>
<li>Alists</li>
<li>Plists</li>
<li>Hash tables</li>
</ul>
<p>Strings arent really a data structure in the sense of the others but they are, in effect, character arrays and its possible to extract or insert data into a string.</p>
<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. Im not really a Lisp old-timer but Ive 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, Ill 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>
<p>Like me, Kitchin doesnt use vectors very often and doesnt have much to say about them but they are simple and easy to use.</p>
<p>Alists and plists are two variations on the same theme. Theyre both lists of key/value pairs differing in their representation and access means. A good argument can be made that we dont 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>
<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 doesnt 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>
<p>Even if youre familiar with using hash tables in Elisp, you may not be familiar with using “reader notation” for initializing a hash table. It really makes sense only for small hash tables—or for writing out and then later reading in a hash table.</p>
<p>The video is just short of 26 minutes so plan accordingly. As usual with Kitchins videos, its well worth the time to watch it even if youre an experienced Elisper.</p>