Skip to content

Instantly share code, notes, and snippets.

@Yasushi
Created July 16, 2014 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yasushi/257a7b78fdbabadabb4e to your computer and use it in GitHub Desktop.
Save Yasushi/257a7b78fdbabadabb4e to your computer and use it in GitHub Desktop.
class Ex
def sum(l, s)
@c = (@c||0) + 1
(not l or l.empty?) ? s : sum(l[1..-1],s+l[0])
end
def count ; @c end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment