Filter by array of tuples

You can create an anonymous function that does the tuple de-structuring if you want, it just requires an extra tailing comma in the arguments:

julia> f = ((index, item),) -> println("index: $index, item: $item")
#9 (generic function with 1 method)

julia> map(f, enumerate(["a", "b", "c"]))
index: 1, item: a
index: 2, item: b
index: 3, item: c

You need the comma to differentiate ((a, b),) -> ..., which is a function taking a single argument (a tuple) from (a, b) -> ..., which is a function taking two arguments, as mentioned above.

4 Likes