Post

Higher-order functions take other functions as arguments. The fun part: you must not inline the call unless the target is constant - otherwise you break semantics (and your VM). #kotlin

A first order function takes parameters, a second order function takes a function as a parameter, a third order function takes a function that takes a function as a parameter, and so on

2 reposts7 likes

I think it's useless to try and evaluate the order of a function where the parameter doesn't have a strict static type, because whatever order of function you have, you can always make it have an order one higher. So basically,

Essentially, functions in Python are just one big "function" type, and because the order of a function depends on its parameters, and parameter types can change in Python, it's impossible to know. For example, what would the order of this function be?

In your example, f is simply a higher-order function. That's it. In a typed programming language it returns a function of the same order as its argument, and the order of the function itself is the order of the argument plus one.

Yes and no. The f that you pass as an argument is not the same f. Trying to do so would not pass the type checker. In Python, with enough squinting and hand-waving, you can think of f as being a first order function. It takes and returns a Python value.