English
O(log n). Take the first i elements of the tree; if i is larger than the size, return the whole tree.
Русский
O(log n). Возьмем первые i элементов дерева; если i больше размера, вернем все дерево.
LaTeX
$$$$ \mathrm{take}: \mathbb{N} \to \mathrm{Ordnode}\; \alpha \to \mathrm{Ordnode}\; \alpha, \\ \mathrm{take}(i,t) = \begin{cases} t & |t| \le i \\ \mathrm{takeAux}(t,i) & \text{иначе} \end{cases} $$$$
Lean4
/-- O(log n). Get the first `i` elements of the set, counted from the left.
take 2 {a, b, c, d} = {a, b}
take 5 {a, b, c, d} = {a, b, c, d} -/
def take (i : ℕ) (t : Ordnode α) : Ordnode α :=
if size t ≤ i then t else takeAux t i