FN denotes an anonymous function. FN, like WITH, is a closure, and as such allows variables to be defined within the argument context and subsequently referenced. It takes an indeterminate number of arguments.

Function category: Special


FN([arg1...], arg2)




Optional. Expected argument or set of arguments. However, a function can be defined that takes no external arguments.


Required. Body of the function and must always occur as the last argument. The result of this expression will be what is returned by the FN function.


Example 1: Find relative vehicle scores

Let's say we're given a response with the following vehicle performance information:

"data": {
"vehicle_ratings": [92, 84, 71, 80, 96]

If we wanted relative vehicle scores with the highest existing score serving as a benchmark, we could use FN .

We then apply it by passing FN as the function argument to MAP:

MAP(FN(x, x + 4), data.vehicle_ratings)

This would return the following:

[96, 88, 75, 84, 100]

Example 2: Using multiple arguments

FN can also take multiple arguments. Given the following data:

"data": {
"vehicle_safety_ratings": [92, 84, 71, 80, 96],
"vehicle_performance_ratings": [95, 81, 77, 83, 90]

We could use FN with MAP which can take two arguments and generate a combined_vehicle_rating:

MAP(FN(x, y, x + y), data.vehicle_safety_ratings, data.vehicle_performance_ratings)

This returns the following:

[187, 165 ,148, 163, 186]