Associative array/Creation: Difference between revisions

Line 4,284:
{{libheader|srfi-151}}
 
Most implementations of associative arrays—including those for Scheme—are for ‘''mutable''’ arrays, whose previous values are effectively lost whenever an insertion is done. Here instead is a ''persistent'' (‘''immutable''’) implementation, using code from [[AVL_tree#Scheme|the AVL Tree task]]. (So performance will be on average logarithmic. Just be aware of that.)
 
(That there are so many implementations of associative arrays for Scheme is partly because making an implementation from scratch is fairly easy. But many approaches are difficult to use if the goal is ''persistent'' associative arrays. For instance, if you use a classical hash table, inserting an association would require copying an entire array.)
 
Associate arrays are not part of the Scheme language itself, but are compiler/interpreter or library add-ons. So I feel justified in presenting this sketch of yet another library add-on.
 
<lang scheme>(cond-expand
1,448

edits