Skip to content

Instantly share code, notes, and snippets.

@draftcode
Created August 14, 2011 09:38
Show Gist options
  • Select an option

  • Save draftcode/1144742 to your computer and use it in GitHub Desktop.

Select an option

Save draftcode/1144742 to your computer and use it in GitHub Desktop.
sum_two_dim := method(ll,
ll map(l, l sum) sum
)
sum_two_dim(list(list(1,2,3), list(4,5,6), list(7,8,9,10))) println
sum_dim_flat := method(ll,
ll map(l, if(l isKindOf(List), sum_dim_flat(l), l)) sum
)
sum_dim_flat(list(list(1,2,3), list(4,5,6), list(7,8,9, list(10, 0)))) println
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment