Sobes.tech
Junior — Senior

Function to calculate the sum of all numbers in nested lists

livecode

Task condition

Write a function total_sum that calculates the sum of all numbers in the given lists, regardless of nesting level. The function accepts an arbitrary number of lists and should correctly handle both simple elements and nested lists of arbitrary depth.

Examples of calls:

total_sum([10, 21, 33], [14, 52], [7, 81, [9, 100]]) → 327

total_sum([3, [5, 6], 15, [5, 51]], [7, 81, [9, 100]]) → 282

total_sum([3, [5, [10, 15, [5, 6], 6], 61, [5, 5], 8]]) → 129