Appendix: Utilities#

Utility functions.

(Not intended for external use.)

Combinators#

identity(x)

The identity function, i.e., (𝜆 x ⇒ x).

all_map(f, xs)

Tests whether f holds for all x in xs.

any_map(f, xs)

Tests whether f holds for some x in xs.

flip(f)

Returns the function (𝜆 x, y ⇒ f(y, x)).

foldl(f, x, xs)

Left-folds xs with using f and starting value x.

foldl_args(f, x, *args)

Same as foldl() but applies to varargs.

foldl1(f, xs)

Left-folds xs using f and no starting value.

foldl1_args(f, *args)

Same as foldl1() but applies to varargs.

foldl_infix(f, g, arg1, arg2, *args, **kwargs)

Left-fold variant used to apply infix operators.

unfoldl(f, x)

Left-unfolds x using unpacking function f.

foldr(f, x, xs)

Right-folds xs using f and starting value x.

foldr_args(f, x, *args)

Same as foldr() but applies to varargs.

foldr1(f, xs)

Right-folds xs using f and no starting value.

foldr1_args(f, *args)

Same as foldr1() but applies to varargs.

foldr_infix(f, g, arg1, arg2, *args, **kwargs)

Right-fold variant used to apply infix operators.

unfoldr(f, x)

Right-unfolds x using unpacking function f.

map_args(f, *args)

Same as map() but applies to varargs.

match_first(f, xs[, x])

Returns the first element of xs satisfying f; or x

match_last(f, xs[, x])

Returns the last element of xs satisfying f; or x.

sliding_pairs(it)

Returns a sliding window of width 2 over it.

sliding_pairs_args(x1, x2, *xs)

Same as sliding_pairs() but applies to varargs.

Proxy#

class Proxy(get_proxy)[source]#

Proxy object.

Forwards any access to the object obtained using get_proxy.

Imports#

get_package_data_dir(modname)

Returns package-data directory of modname.

Miscellanea#

Nil()

Class representing the absence of value.

camel2snake(name[, re1, re2])

Converts name from camel-case to snake-case.

get_variant(name[, re])

Returns the next numerical-suffixed variant of name.

get_variant_not_in(name, avoid)

Same as get_variant() but skip variants in avoid.