Another quick update: I've added an implementation of persisten hash tables to my emacs library. These are built on top of random access persistent lists and are similar to Clojure's persistent table datatype.
They are like hash tables (with similar performance) except that set
operations return a new table - the old table persists unmodified.
You use them like so:
(require 'persistent-hash-tables)
(setq tbl ({} 'a 10 'b 11 'c 12))
(setq tbl2 (ptbl-set tbl 'c 100))
(ptbl-get tbl 'c) ;-> 12
(ptbl-get tbl2 'c) ;-> 100
Such tables allow functional programming over table abstractions. These might be a better fit than association lists if you have a large number of associations and/or you are doing a lot of functional updates.
No comments:
Post a Comment