documentcloud/underscore — pull request #420 by adleyeskridge (2011-12-27 06:30:27+00:00)
Title: Add ratio method for collections

I believe it might be helpful to include a `ratio` method (for collections) in everyone's favorite utility-belt.

The best description I can provide is the one I put in the docs:

### _.ratio(list, iterator, [context])

Returns the ratio of values in the **list** that pass the **iterator** truth test. Returns _0_, if the list is empty.

```javascript
_.ratio([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
=> 0.5
```

I've had to implement my own `ratio` method than once, and I'm probably not alone in that. I'd be totally thrilled if you wanted to include this!