From ea17de02ec4fa72147b5e321af5a9fad3ed96703 Mon Sep 17 00:00:00 2001 From: MahadShahid8 <93673498+MahadShahid8@users.noreply.github.com> Date: Sun, 3 Sep 2023 09:02:24 +0500 Subject: [PATCH] Update nest.py (#22590) --- ivy/functional/ivy/nest.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/ivy/functional/ivy/nest.py b/ivy/functional/ivy/nest.py index 05e47e2358582..5965c48416e08 100644 --- a/ivy/functional/ivy/nest.py +++ b/ivy/functional/ivy/nest.py @@ -217,7 +217,35 @@ def set_nest_at_index( @handle_exceptions -def insert_into_nest_at_index(nest: Iterable, index: Tuple, value, /) -> None: +def insert_into_nest_at_index(nest: Iterable, index: Tuple, value) -> None: + """ + Recursively inserts a value into a nested data structure at a specified index. + + This function traverses a nested data structure and inserts the provided `value` + at the specified `index`. + + Parameters + ---------- + nest : Iterable + The nested data structure. + index : Tuple + The index specifying the location where the `value` should be inserted. + value : object + The value to be inserted. + + Returns + ------- + None + + Examples + -------- + >>> nest = [[1, 2], [3, 4]] + >>> index = (1, 1) + >>> value = 99 + >>> insert_into_nest_at_index(nest, index, value) + >>> print(nest) + [[1, 2], [3, 99, 4]] + """ if len(index) == 1: idx = index[0] if isinstance(nest, list):