"functions are first class values" what does this exactly mean?

functional-programming, scala

Solution

It means that functions can be passed around the same way as integers, sequences, etc.

An example (although not Scala):

>>> def add2(x):
...   return x + 2
... 
>>> map(add2, [1, 2, 3])
[3, 4, 5]

Problem

Could somebody clearly explain it with some good example. I came across this statement in Scala, when explaining about the functional programming.

Original source

Related problems