File:  [CSRG BSD Unix] / 43BSD / contrib / icon / book / f / btree.icn
Revision 1.1: download - view: text, annotated - select for diffs
Tue Apr 24 16:12:55 2018 UTC (8 years, 1 month ago) by root
CVS tags: MAIN, HEAD
Initial revision

record bnode(value,left,right)

procedure btree(stree)
   local x
   stree ? if x := bnode(tab(upto('('))) then {
      move(1)
      x.left := btree(tab(bal(',')))
      move(1)
      x.right := btree(tab(bal(')')))
      }
      else x := bnode(tab(0))
   return x
end

procedure stree(btree)
   local s
   if /btree.left then return btree.value
   s := btree.value || "(" ||
      stree(btree.left) || "," || stree(btree.right) || ")"
   return s
end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.