It took me a while to understand what you meant by f(f(x)) = f(x) because your example doesn't show that. For the formula to hold a function must return the same type as the input, while your example modifies the map without returning anything.
A better example of that is the absolute value function abs. Because abs(abs(x)) = abs(x). But that is not to say this is the only useful case, your example is definitely useful.
For the future, I can recommend to also explain why it's useful, why we would want idempotence in our code.
This post made me remember an old podcast episode I listened to a long time ago. I can recommend it if you want to learn a bit of the "why" of idempotence. lispcast.com/what-is-idempotence/
Thanks for the constructive feedback Casper! Also major thanks for sharing Eric's podcast, it really helped me understand the big picture! I hope you don't mind but I edited the post according to your feedback. Thanks a lot and have a great day!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It took me a while to understand what you meant by
f(f(x)) = f(x)
because your example doesn't show that. For the formula to hold a function must return the same type as the input, while your example modifies the map without returning anything.A better example of that is the absolute value function
abs
. Becauseabs(abs(x)) = abs(x)
. But that is not to say this is the only useful case, your example is definitely useful.For the future, I can recommend to also explain why it's useful, why we would want idempotence in our code.
This post made me remember an old podcast episode I listened to a long time ago. I can recommend it if you want to learn a bit of the "why" of idempotence.
lispcast.com/what-is-idempotence/
Thanks for the constructive feedback Casper! Also major thanks for sharing Eric's podcast, it really helped me understand the big picture! I hope you don't mind but I edited the post according to your feedback. Thanks a lot and have a great day!