{"type":"rich","version":"1.0","provider_name":"Transistor","provider_url":"https://transistor.fm","author_name":"The Eric Normand Podcast","title":"What is a function’s identity?","html":"<iframe width=\"100%\" height=\"180\" frameborder=\"no\" scrolling=\"no\" seamless src=\"https://share.transistor.fm/e/41e3178d\"></iframe>","width":"100%","height":180,"duration":576,"description":"Some functions have identities, which are values that tell you where to start calculating. In this episode, we look at what identities are, some examples of them, and how you can use them in your own code.\r\n\r\nTranscript\r\nEric Normand: Is a function’s identity? By the end of this episode, you’ll know what an identity is and how to use them in your code. My name is Eric Normand. I help people thrive with functional programming.\r\nThis is an important topic because many common operations, operations we use every day, have identities. You might not know that term, but you’ve definitely used them. It’s a fundamental idea from algebra, and it tells us where to start an operation.\r\nBasically, it’s the value you start with. When you’re counting, you’re going to start at zero. You don’t start at one. Before you start counting, you’re at zero, then the first thing you count down when it gets to one.\r\nCounting is just adding one each time. Zero is the identity value of addition. Multiplication also has an identity value, it’s one. If you multiply one times anything, you get that number. Same thing with adding zero. If you add zero to anything, you get the number back. That’s what an identity means.\r\nThere’s other identities all around. If you’re adding letters to the end of a string, you’re going to start with an empty string. If you’re adding elements to an array, you’re going to start with an empty array.\r\nThe same property holds, if you stake a string and you concatenate on an empty string to the end, you get the same string out. The same thing if you take an empty array and you concatenate them, you’re going to get the original array out.\r\nYou can look at all sorts of operations and try to find if they have an identity. The ones that have an identity tend to be the more algebra feeling ones. I’m talking about hash map merge.\r\nIf you merge two hash maps, basically copying the keys and values from one into the other, the identity is the empty map. Another property of the...","thumbnail_url":"https://img.transistorcdn.com/WbyB3L00271RX0nwX_O6wfvG-9-GVuhuQNa4JxI1IvI/rs:fill:0:0:1/w:400/h:400/q:60/mb:500000/aHR0cHM6Ly9pbWct/dXBsb2FkLXByb2R1/Y3Rpb24udHJhbnNp/c3Rvci5mbS9zaG93/LzQzMzgvMTU2ODQ4/NjQ0MC1hcnR3b3Jr/LmpwZw.webp","thumbnail_width":300,"thumbnail_height":300}