Functional

The 'functional' module provides functional programming style functionality

Function Signatures

// Apply a function to each element in the list and return a new list.
const map = (list: List, func: Function) => List

// Apply a function to each element in the list and flatten the results into a single list.
const flatmap = (list: List, func: Function) => List

// Filter elements from the list based on a predicate function and return a new list.
const filter = (list: List, func: Function) => List

// Reduce the list to a single value using a binary function.
const reduce = (list: List, func: Function) => T

// Find the first element in the list that satisfies the predicate function.
const find = (list: List, func: Function) => T

// Apply a function to each element in the list without returning a value.
const forEach = (list: List, func: Function) => None

// Find the index of the first element in the list that satisfies the predicate function.
const indexOf = (list: List, func: Function) => Number

// Chain a value through a series of functions.
const chain = (value: X, func: Function) => Y

// Apply a function to each value in an object and return a new object.
const obj_map = (obj: Object, fn: Function) => Object

// Filter values from an object based on a predicate function and return a new object.
const obj_filter = (obj: Object, fn: Function) => Object

// Transform values in an object using a transformation function and return a new object.
const obj_transform = (obj: Object, fn: Function) => Object

// Convert a list to an object using a key transformation function.
const list_to_obj = (ls: List, fn: Function) => Object

// Generate a list of numbers from a start value to an end value (inclusive).
const range = (start: Number, end: Number) => List

Last updated