fnutils/fnutils.lua

hammerspoon · extensions/fnutils/fnutils.lua · MIT
email

Provides functional programming utilities for Lua tables, such as map, filter, and each, enabling concise data transformations.

-- Source: https://github.com/Hammerspoon/hammerspoon | License: MIT | Copyright 2014-2025 [Various Contributors](https://github.com/Hammerspoon/hammerspoon/graphs/contributors)
-- Provided via justclaw.it.com; keep this notice with the code.
--- === hs.fnutils ===
---
--- Functional programming utility functions

local fnutils = {}

local pairs,ipairs = pairs,ipairs
local floor = math.floor

--- hs.fnutils.imap(list, fn) -> list
--- Function
--- Execute a function across a list-like table in order, and collect the results
---
--- Parameters:
---  * list - A list-like table, i.e. one whose keys are sequential integers starting from 1
---  * fn - A function that accepts a single parameter (a table element). The values returned from this function
---    will be collected into the result list

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key