<jupyter_start><jupyter_text>3.27<jupyter_code>def getMaxDepth[A](t:Tree[A],maxDepth:Int):Int = t match {
    case Leaf(v) => maxDepth
    case Branch(l,r) => (getMaxDepth(l,maxDepth) max getMaxDepth(r,maxDepth)) +1
}
val x = Branch(Branch(Leaf(1),Leaf(2)),Branch(Leaf(1),Branch(Leaf(17),Leaf(3))))
getMaxDepth(x,0)<jupyter_output><empty_output><jupyter_text>3-28<jupyter_code>def map[A,B](t:Tree[A])(f: A => B): Tree[B] = t match {
    case Leaf(v) => Leaf(f(v))
    case Branch(l,r) => Branch(map(l)(f),map(r)(f))
}
val x = Branch(Branch(Leaf(1),Leaf(2)),Branch(Leaf(1),Branch(Leaf(17),Leaf(3))))
map(x)(t => t*2)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.23255813953488372, 'fraction_numerical': 0.03255813953488372, 'mean_word_length': 8.787878787878787, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '126427', 'license': 'MIT', 'n_tokens_mistral': 305, 'n_tokens_neox': 301, 'n_words': 34, 'path': 'step3_Tree_custom.ipynb', 'repo_name': 'HoeYeon/fpinscala-exercise', 'size': '645'}