3 ms·
I think I'm in between somewhere. I do love named intermediate results as documentation. I love that functional code composes so well that you don't have to g
by dkarl 6y ago
I think I'm in between somewhere. I do love named intermediate results as documentation. I love that functional code composes so well that you don't have to give names to every value... but I hate when people abuse it to eliminate all names.
Oftentimes, if I have a one or two line function that is only used in one place, I prefer to have it inline and use a named intermediate value to document its meaning.
grades_with_end_of_semester_adjustment = grades.map(x =>
code code code
code code code code code
)
odd_adjusted_grades = grades_with_end_of_semester_adjustment.filter(x =>
x % 2 != 0
)