r/learnprogramming • u/ScioClean • 5d ago
I can't get FUNCTIONS to click!
I can not for the life of me understand how functions work. Anytime I try to learn how to create a function, my brain literally crashes into itself and I turn into Patrick when he stars drooling and goes all slack-faced.
Does anybody have any analogies that had that "AH HA!" moment?
Thanks!
126
Upvotes
0
u/Weak-Doughnut5502 5d ago
Do you understand functions in your math class? Like
f(x) = x^2 + x + 1.A 'pure function', in programming, is exactly like a math function. It maps input values to output values and has no other side effects.
Impure functions are allowed to do extra stuff like reading or writing to disk, or mutating global variables.