aboutsummaryrefslogtreecommitdiff
path: root/clojurescript/hashtopology.js
diff options
context:
space:
mode:
authorChouser <chouser@n01se.net>2008-09-27 16:04:16 +0000
committerChouser <chouser@n01se.net>2008-09-27 16:04:16 +0000
commit0dd11ec2d6d20b5272deba4436c65db661e93e74 (patch)
treedf1aa98b3e8ba7c1cf79ef3f42a99ba8050622f8 /clojurescript/hashtopology.js
parentaf98c8231c19fef92164602220ca158cb98cc82f (diff)
ClojureScript: add classes Keyword, PersistentHashMap, PersistentHashSet, MultiFn; mutlimethod print now works; add many functions to clojure runtime; support calling keywords and collections; fixed several small bugs including extra null arg on some variadic calls
Diffstat (limited to 'clojurescript/hashtopology.js')
-rw-r--r--clojurescript/hashtopology.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/clojurescript/hashtopology.js b/clojurescript/hashtopology.js
new file mode 100644
index 00000000..d9633a94
--- /dev/null
+++ b/clojurescript/hashtopology.js
@@ -0,0 +1,28 @@
+// display topology of hashmaps, for debugging
+function maptop(x,d) {
+ d = d || "";
+ var d2 = d + " ";
+ var c = x.constructor.classname;
+ print(d+c);
+ switch(c) {
+ case "PersistentHashMap": maptop(x._root,d2); break;
+ case "BitmapIndexedNode":
+ case "FullNode":
+ for( var i = 0; i < x.nodes.length; ++i ) {
+ maptop(x.nodes[i],d2);
+ }
+ break;
+ case "HashCollisionNode":
+ for( var i = 0; i < x.leaves.length; ++i ) {
+ maptop(x.leaves[i],d2);
+ }
+ break;
+ case "LeafNode": print( d2 + x.key() + " : " + x.val() ); break;
+ }
+}
+
+y = clojure.lang.PersistentHashMap.EMPTY;
+for( var i = 0; i < 10; ++i ) {
+ y = y.assoc( "a" + String.fromCharCode( 48 + i ), i );
+ maptop( y );
+}