Skip to content

Instantly share code, notes, and snippets.

@devnoo
Created November 27, 2011 10:07
Show Gist options
  • Save devnoo/1397339 to your computer and use it in GitHub Desktop.
Save devnoo/1397339 to your computer and use it in GitHub Desktop.
Seven languages in seven weeks : Solutions IO Day2 sum multidimensional
List deepSum := method(
total := 0
self foreach(i, element, (if (element type == "List", total = total + element deepSum , total = total + element)))
total
)
array := list(list(1,2), list(3,4), 5)
array deepSum println
array2 := list(list(1,list(2,3)), list(3,4), 5)
array2 deepSum println
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment