Functional programming (often abbreviated FP) is the process of building software by composing pure functions, avoiding shared state, mutable data, and side-effects. We will discuss some of these concepts and their benefits.
Purity means there are no side effects to a function. The only impact pure functions can have on the outside world is through their output value, and the only way the external world affect them is through their parameters.
This function is pure:
def addition(x, y):
return x + y
This function is impure:
Pure functions are nice, because they are easy to reason…
Like many others I read Noam Bardin’s post and it resonated with me. Especially the part about employee motivations.
It is often I find myself talking about the similarities between programming and managing, so maybe programming is a way to start what I want to say.
One principle which good programmers adhere to is the following: a function should do one thing, and one thing alone.
This is a good practice because it helps you separate your program into very small steps, and small steps are easier to read, write, understand, test, optimize and reuse. Let’s illustrate the relationship between…
Sometimes simple questions lead you to an interesting trail of thoughts. This one was “should you use nested functions to encapsulate logic only used once?”
First of all, a small refresher, nested functions are functions written within a scope of another function. They have many uses in python.
def foo(a, b, c): def bar(x, y):
return x * y
return bar(a, b) + c
But for this question, the asker was interested in the case where some logic which is used only within
foo can be encapsulated within its scope.
When coding we want to hide immaterial detail. E.g. we…
Imperative programming is characterized by iterative nesting. A function has embedded calls to other ones. By embedded I mean that these calls are in the function body, and so there is a tight coupling between a function and its constituents. This has many shortcomings and is typically solved by function composition.
Composition is like taking two things and connecting them. Not one thing is on top of, embedded or superior to the other, they just feed into each other. …
You should learn how to download movies using torrents by yourself.
If you’re old enough to use a browser you should learn how to search for movies, download them with subtitles and watch them.
This is for several reasons:
So you want to train a binary classifier over strings, using state of the art language models. All you really want is an API that gets two groups of strings and an example usage. You don’t really want to know about masks and encodings and special tokens just yet, you just want to experiment a bit. Well there you go.
In this example we learn to identify past vs present tense in <50 examples.
So two problems I thought about:
The question of whether Machines Can Think… is about as relevant as the question of whether Submarines Can Swim.
- Edsger W. Dijkstra
Three preliminary notes:
If you ever wondered what’s programming like, you might find this essay interesting.
I know at least some people view programming as a bit grey, too mathematical or uncreative. It is sometimes these things, but it’s also a bunch of other things.
If you only have time for a short video, this is the best explanation I’ve seen yet: http://video.disney.com.au/fantasia-sorcerers-apprentice
I’ve always liked it but it is only since I’ve become an experienced programmer that I’ve started to get emotional about it. …