Data and Math

vfunc

Compose, adapt and reuse functions that take one or two arguments.

Released v1.0.0 · 2026-09-28
Import
use "stdlib/func.ven"

Compose, transform, and pass functions around with no friction.

vfunc.ven
print identity(42)
:: 42
Reference (9 functions)

API reference

identity(x)

Gives back x unchanged.

print identity(42)
:: prints: 42

constant(x)

Builds a zero-argument function that always gives back x.

print constant(7)()
:: prints: 7

compose2(f, g)

Composes two one-argument functions into one: f after g.

make double(x)
    give x * 2
make add_one(x)
    give x + 1
print compose2(add_one, double)(3)
:: prints: 7

pipe(value, functions)

Threads value through every one-argument function in functions, left to right.

make double(x)
    give x * 2
make add_one(x)
    give x + 1
print pipe(3, [double, add_one])
:: prints: 7

flip(fn)

Swaps the argument order of a two-argument function.

make subtract(a, b)
    give a - b
print flip(subtract)(2, 10)
:: prints: 8

once(fn)

Wraps fn so it only ever actually runs on its first call.

state = new_map()
map_set(state, "n", 0)
make bump()
    n = map_get(state, "n") + 1
    map_set(state, "n", n)
    give n
once_fn = once(bump)
print once_fn()
print once_fn()
:: prints: 1
:: prints: 1

memoize(fn)

Wraps a one-argument function fn so repeat calls with the same argument are cached.

make square(x)
    give x * x
sq = memoize(square)
print sq(4)
print sq(4)
:: prints: 16
:: prints: 16

curry2(fn)

Curries a two-argument function into two chained one-argument calls.

make add(a, b)
    give a + b
add3 = curry2(add)(3)
print add3(4)
:: prints: 7

partial1(fn, bound_first)

Binds the first argument of a two-argument function, leaving the second open.

make add(a, b)
    give a + b
add10 = partial1(add, 10)
print add10(5)
:: prints: 15

Get notified when vfunc changes

Get notified about

New versions and security advisories.

New and updated packages, once a day.

News on the math model built in Venutian.