Vortex Docs
  • Introduction
  • Getting Started
  • Language Reference
    • Core Functionality
    • Built-in Functions
    • Hooks
    • C Interoperability
    • Coroutines
    • Decorators
    • Type Hinting
    • Error Handling
  • Examples
    • Data Structures
    • Hooks
    • Fetching Data
    • Sockets
    • Event Bus
  • Standard Modules
    • Functional
    • Functools
    • Future
    • I/O
    • JSON
    • Logging
    • Math
    • OS
    • Random
    • Requests
    • SDL
    • SQLite
    • String
    • Sys
    • Time
    • Crypto
    • Websockets
  • Development Roadmap
Powered by GitBook
On this page
  1. Standard Modules

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
PreviousStandard ModulesNextFunctools

Last updated 1 year ago