I'm looking for a functional library with persistent data structures. I only need nested arrays and dictionaries. There are some functional javascript libraries, but they are not geared towards immutability. I want to be able to write
var dict = makeDictionary({
'foo': 1;
'bar': {
'ely': 2;
}
});
var newDict = dict.assoc('foo', 42).assoc('bar', 'tender', 30).dissoc('bar', 'ely');
assert.eq dict.bar.ely, 2; // unchanged
assert.eq newDict.bar.tender, 30; // added
assert.eq newDict.bar.ely, undefined; // removed
While underscore comes close in some cases, especially with arrays, it modifies dictionary arguments. I could also use clojurescript, but I'd prefer a more light-weight approach.