ninetynine-1.3.0: Ninety-Nine Haskell Problems
CopyrightCopyright (C) 2021 Yoo Chung
LicenseGPL-3.0-or-later
Maintainerdev@chungyc.org
Safe HaskellSafe-Inferred
LanguageGHC2021

Problems.P62

Description

Part of Ninety-Nine Haskell Problems. Some solutions are in Solutions.P62.

Synopsis

Documentation

atLevel :: Tree a -> Int -> [a] Source #

Collect the nodes at a given level in a list

A node of a binary tree is at level \(n\) if the path from the root to the node has length \(n-1\). The root node is at level 1.

Examples

>>> atLevel tree4 2
[2,2]

Notes

Expand

In the original list, this was problem 62B, and internals was problem 62, but the latter was grouped with problem 61 because the grouping was more natural.