replace for loops with while loops to match Ramda style
Merge pull request #535 from davidchambers/loops

replace for loops with while loops to match Ramda style