1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
List deepSum := method( total := 0 self foreach(e, if(e type == "List") then( total = total + e deepSum ) else( total = total + e ) ) return total ) a := list(1,2,3) b := list(4,5,6) c := list(7,8,9) a deepSum println b deepSum println c deepSum println c := list(a,b,c) c deepSum println