Created
August 15, 2014 19:42
-
-
Save mPastuszko/a5bf1b99b10a4ecdb5db to your computer and use it in GitHub Desktop.
Ruby looks like LISP sometimes
This file contains hidden or 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
.map { |subject_answers| | |
subject_answers.merge( | |
summary: (subject_answers[:summary_r] || subject_answers[:summary_w]) | |
.keys | |
.inject({}) { |memo, material| | |
memo.merge( | |
material => subject_answers[:summary_r][material] | |
.keys | |
.inject({}) { |memo, probe| | |
memo.merge( | |
probe => subject_answers[:summary_r][material][probe] | |
.keys | |
.inject({}) { |memo, stat| | |
memo.merge( | |
stat => | |
(subject_answers[:summary_r][material][probe][stat] rescue 0) + | |
(subject_answers[:summary_w][material][probe][stat] rescue 0) | |
) | |
} | |
) | |
} | |
) | |
} | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment