RBMap (Red-Black Map)
RBMap is a persistent, ordered map. It is often preferred in pure functional code because it doesn't rely on the IO or ST monads for performance.
#print RBMap
def myRBMap : RBMap Name Nat Name.quickCmp := {}
-- Inserting values
def rb1 := myRBMap.insert `apple 1
def rb2 := rb1.insert `banana 2
-- Accessing values (returns Option)
#eval rb2.find? `apple
#eval rb2.find? `cherry
-- Checking for existence
#eval rb2.contains "apple".toName
#eval rb2.contains `cherry
-- Converting to list
#eval rb2.toList
#eval rb2.toList.map (λ (k, v) => (k.toString, v * 10))