Higher Order Functions
Why the name? are there lower order functions? How is it any different from the usual method I know from Java, C/C++ or Visual Basic What does it mean when they say “first class citizen”, first class functions What do they look like How do they accept functions as parameter and why is this useful How would it return functions? again, why is this useful Do the Kotlin team themselves use higher order functions What’s with the name The name higher order functions come from the world of Mathematics, in there, a higher order function is also called functional, functional form or functor, and apparently, they take the difference between function and values, a bit more seriously than programming folks.
1. Introduction What’s covered What versions Why this tutorial Why Angular1 (you saved someting in instapaper). Why would you want to use this in 2018?
Package this with
Resources for the book (have it downloadable)
2. Requisite knowledge and background JS Command line experience Experience setting up a POSIX shell such as Cygwin or MingW, if you are using Windows. It is possible to do all the examples which requires the use of the command line in Windows Powershell, but that is out of the scope of this tutorial.
1. Tooling There are a few ways to get started.
Explore the online editor at try.kotlinlang.org Get the command line tools at kotlinlang.org/commandline Use an IDE like Eclipse or IntelliJ IDEA, there is a non-paid version of IntelliJ called CE or Community Edition 2. A few characteristics Like Java, its
compiled, so it goes through the same cycle of writing > compiling > running statically typed, but we don’t always have to write the type.
Copy pasting clipboard to/from terminal Can be done either via xsel or xclip. Xclip is part of most modern installations, so you it may be there in your installation already. The common usages are:
You copied something in an X window (browser or editor etc), you want to paste the content to the terminal. Unfortunately the terminal doesn’t have access to the clipboard. But you can do this on the terminal using
git clone https://github.com/VundleVim/Vundle.vim.git
Create .vimrc in your home folder (~/.vimrc) and add the following entries to it
Save the .vimrc file. Close it and execute the following command on a terminal window
vim +PluginInstall +qall
1. Summing things up Create a module named “sums.py” with three functions in it. These functions are named as follows
sum_to(end) sum_of_even(end) sum_of_odd(end) The module should be loadable from the REPL, sample usage is as follows
>>> import sums >>> sums.sum(100) Sum of numbers from 1 to 100 is 4950 >>> sums.sum_of_even(100) “Your answer here” >>> exer1.sum_of_odd(100) “Your answer here” You should also be able to run the module as a script, like so