![]() |
Хвостовая рекурсия Простая задачка поиска глубины двоичного дерева, как ее в подхвост загнать не пойму. Есть идеи? [code] case class BTree(left: BTree, right: BTree) def length(btree: BTree): Int = btree match ** case BTree(left, right) => math.max(length(left), length(right)) + 1 case _ => 0 ** [/code] |
[url]http://stackoverflow.com/questions/9323036/tail-recursive-function-to-find-depth-of-a-tree-in-ocaml?lq=1[/url] |
Текущее время: 10:14. Часовой пояс GMT +3. |