 horses. I am building excitement so that this concept sticks in your brain for all eternity!!!
Because functional programming is built around action and logic, there is a strong emphasis on building an ecosystem of functions that are pure.
Thus, pure functions form the foundation of functional programming.
A pure function, simply put, is a function that only does what it is supposed to do.
Given a certain input, it will always yield the same result for that input.
The function always returns an original object after performing the operation it is supposed to do.
Does not rely on any external mutable state.
If the technical conditions above doesn’t make sense, just think of it this way.
A pure function only does what it is supposed to do. Nothing more, nothing less.
It returns a new result set that is not tied in anyway to an external item.
It does not change the passed in item.
Make sense? If not, don’t worry. Keep reading. I am certain that by the end of this, you will fully understand and never, ever forget what a pure function is.
For pure functions, that’s a nope.
In theory, the difference between pure and impure functions are quite clear. However, in practice, sometimes, the lines between the two can be quite blurry, especially when one is just starting out.
In this section, we will aim towards clarifying some of the distinctions between the two.
Sometimes, looking at a code snippet makes concepts so much clearer.
Code can often be many times more expressive than information displayed in text format.
First of all, lets look at a very simple function.
log("hello");  // logs hello to the console.
I am certain that I don’t have to explain to anybody what the code above does. All it does is simply log onto the console the value that was passed.
However, is the function above a pure function?
Think about the golden rules for a second.
Yes, it was a trick question. Believe it or not, the function above is impure. Why? Lets take a look at each of the key facts that make up a pure function.
Does the function only do what it is supposed to do? Yes, the function is meant to log the input and only does that.
The function returns an original object? No. The function does not return any value.
Does not rely on any external mutable state? No. It is using the console object, which is an external, mutable object.
Do you now see why the previous function is not a pure function?
Let us examine a pure function. This should clarify any lingering uncertainty.
Does the function only do what it is supposed to do? Yes, all it does is add the values passed in.
The function returns an original object? Yes. The function returns the result of the sum of the two passed in values.
Does not rely on any external mutable state? Yes. It does not depend on any other objects to perform the add operation.
The function sum(), is therefore, a pure function. Hopefully this makes sense.
Lets say for example, you are an artist. You wanted to borrow a friend’s piece of work, so you asked him for a copy of his work.
You use that copy as a reference to produce your own piece of work.
That is a pure function example. Lets examine why though by examining code.
Your new piece of artwork (based off the friend’s work) does not impact the friend’s artwork in anyway. Not a single stroke or pixel is changed.
It is not relying on any external immutable state. Even if the original copy is manipulated, that change will not affect the copy of the artwork that you have with you. Nor will it make any changes to your fresh new artwork.
The only exception would be if the property being copied over is a reference type. In this case, to avoid possible side effects, people may recommend making deep copies of reference types. In contrast to deep copies, making shallow copies will likely result in unexpected side-effects that may be difficult to find, depending on the size of the application.
Functional programming is a very complex subject. Therefore, I will most likely write additional posts in the near future to supplement what was discussed here.
In the upcoming tutorials, we will go through basic functional programming methods such as filter(), map() and reduce(). Hope that this read helped you understand functional programming with greater clarity, especially if you are new to this.
Please feel free to leave any feedback that will help me improve the content. Until next time, happy coding and peace!DULUTH, MN. (KBJR) - It’s hard to believe, but this is the last week of 2021, and what a year it has been.
If you are looking to ring in the new year with some live theater, look no further than Rubber Chicken Theater in Duluth.
He said the New Year’s Eve show incorporates both old and new sketches.
He describes it as a local version of Saturday Night Live.
Rubber Chicken Theater’s New Year’s Eve performance is on Friday, December 31, at 7:30 p.m.
“It’s just amazing to me, and I think to the audiences, to sit back and look at the talent that this community has and continues to have,” Matuszak said.
They will be performing at Fitger’s Spirit of the North Theater in Duluth.
To reserve tickets, call |||PHONE_NUMBER|||  or email Brian@RubberChickenTheater.com.Halloween is about more than just zombies, you know. There are plenty of other scary TV shows on Netflix 15 Scary TV Shows to Binge-Watch Over Halloween 15 Scary TV Shows to Binge-Watch Over Halloween What better way to anticipate Halloween than by binge-watching scary TV shows on your favorite streaming service? Read More and scary horror movies on Netflix The 11 Best Scary Movies on Netflix Full of Frights The 11 Best Scary Movies on Netflix Full of Frights Here are the best scary movies to watch on Netflix that will give you chills, whether or not it's Halloween. Read More to watch to get yourself into the Halloween spirit.
Explore more about: Media Streaming, Netflix, Television, TV Recommendations, Zombies.
Love to see Kingdom at the TOP! This well-done series adds something new to the Zombie genre.
I don't think Containment fits in this list b/c it has nothing to do with zombies.
Good list. Big fan of The Walking Dead, Z Nation, Dead Set. Helix's first season was great - not so much that second season.
iZombie I could not stand. Too simple and cute and obvious and 'braindead'. A cutesy and uninspiring zombie detective with the memories of the murder victim at the time of the crime... 'nuf said.
Resurrection (excellent, highly recommended. 2 seasons, 21 eps). The other was 'The Returned' (not nearly as engaging, bland, 1 season, 10eps).
Watched the trailer to 'Santa Clarita Diet' just now and it looks really good!
Thanks Gazoo, I'll check out Resurrection! I hope you enjoy Santa Clarita Diet. The first two episodes are rough, but it gets better!
Newcastle Falcons suffered their first defeat of pre-season, but showed more than enough to suggest they are ready for next Friday’s Aviva Premiership kick-off.
Scoring the only try of a feisty work-out and turning down repeated opportunities to kick at goal, director of rugby Dean Richards will be losing no sleep over a scoreline which disguised a performance in which his side went nicely through the gears.
Edinburgh’s decision to farm their ‘home’ game out to Hawick seemed to meet with the approval of a local support base bereft of professional rugby since the disappearance of the Border Reivers, coached by former Falcons boss Steve Bates during their brief existence.
They turned up in their thousands and, whipped up by the pre-match sounds of the traditional pipe band, it had a feeling of how things used to be. Walls of Bill McLaren memorabilia at the legendary commentator’s home club added to the sentiment, and the on-field action lived up to the occasion.
On the 500th anniversary of the battle of Flodden there were no cheap yards, Scott MacLeod earning a raucous cheer in his home town with a line-break in the very first minute – a passage of play which ended with Phil Godman slicing a penalty attempt from the left.
Scotland scrum-half Greig Laidlaw had no such problems from 40 metres out after former Edinburgh Fraser McKenzie’s shoulder charge, and the one-time Falcons target doubled his side’s lead with a second penalty from half the distance.
The selection of twin open-sides Will Welch and Andy Saull was always going to pose questions of back-row balance, and who would shoulder the ball-carrying burden. Ally Hogg and Fraser McKenzie both put in a shift, but a resurgent Edinburgh grew into the half as Welch departed with a knock after 20 minutes.
Godman’s trademark miss-passes offered tantalising sniffs at an interception for the Scottish side’s enthusiastic midfield, Newcastle’s defensive line holding firm despite repeated spells of pressure inside their own 22.
Home referee Neil Paterson’s penalty-count was quickly mounting up against the Falcons, who can ill afford such indiscipline when their league campaign gets underway on Friday night