recursive algorithms from rubyList