Skip to content

Instantly share code, notes, and snippets.

@as-cii
Created April 28, 2015 14:32
Show Gist options
  • Save as-cii/ea76e04a352b19713a2e to your computer and use it in GitHub Desktop.
Save as-cii/ea76e04a352b19713a2e to your computer and use it in GitHub Desktop.
Remove temp with functional
###
### 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