Created
April 28, 2015 14:32
-
-
Save as-cii/ea76e04a352b19713a2e to your computer and use it in GitHub Desktop.
Remove temp with functional
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
### First approach | |
### | |
[class_months(es, class_name)].flat_map { |range| [range.count.to_f, month_range(range.first, upto_date).count] } | |
.reduce(:/) * 100 | |
### | |
### Second Approach | |
### | |
# define operator `?` as `memoize function` | |
?class_months(es, class_name).count.to_f / month_range(?class_months(es, class_name).first, upto_date).count * 100.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment