Module ce_lib

Miscellaneous spiffy stuff library.

Description

Miscellaneous spiffy stuff library.

Function Index

attempt/2Catches errors from an error-throwing function.
attempt/3Catches errors and returns a default value if error thrown.
breed/1Returns a copy of a deep aggregate of data with each Fun/0 object contained within replaced by the result of running it.
call_stack/0Returns the current Erlang call stack (not including ce_lib:call_stack/0).
clean/2Evaluate a given Fun with a new, temporary process dictionary.
compose/1Composes a function by chaining the results of a list of functions.
eval/1Evaluates a string as an Erlang expression.
iterate/4Implements iteration with a counter variable.
place/2Places the given value in the process dictionary iff the given key does not yet exist.
repeat/2Implements opaque finite repetition.
to_float/2Tries to convert any term into a float, using default value if it cannot be done.
to_integer/2Tries to convert any term into an integer, using default value if it cannot be done.
to_string/1
to_string/2Tries to convert any term into a string, using default value if it cannot be done.

Function Details

attempt/2

attempt(F::function(), Args::[term()]) -> {ok, term()} | {error, term()}

Catches errors from an error-throwing function. Thanks to Thomas Arts for this code.

attempt/3

attempt(F::function(), Args::[term()], Default::term()) -> term()

Catches errors and returns a default value if error thrown. Also can be used with functions which return {ok, Result} | {error, Why}.

breed/1

breed(T::term()) -> term()

Returns a copy of a deep aggregate of data with each Fun/0 object contained within replaced by the result of running it.

call_stack/0

call_stack() -> [{Module, Function, Arity}]

Returns the current Erlang call stack (not including ce_lib:call_stack/0).

clean/2

clean(F::'fun'(), L::[{key(), value()}]) -> term()

Evaluate a given Fun with a new, temporary process dictionary. The new process dictionary will contain only the values given to clean/2, and will be reset to the old process dictionary after the Fun has been evaluated. Simulates local variables with dynamic scope as found in many non-single-assignment languages.

compose/1

compose(FnTail::[function()]) -> function()

Composes a function by chaining the results of a list of functions. Thanks to Alex Peake for this code.

eval/1

eval(S::string()) -> term()

Evaluates a string as an Erlang expression. This adds reflectivity to Erlang with a simple, Perl-like interface.

iterate/4

iterate(I::integer(), Q::integer(), Fun::'fun'(), Acc::term()) -> term()

Implements iteration with a counter variable. Not dissimilar to 'for loops' in other languages.

place/2

place(Key::term(), Value::term()) -> ok

Places the given value in the process dictionary iff the given key does not yet exist. Exclusive use of place/2 instead of erlang:put/2 imposes the restriction of single-assignment on the process dictionary.

repeat/2

repeat(N::integer(), F::'fun'()) -> [term()]

Implements opaque finite repetition. Not dissimilar to the 'repeat' loop in LOGO. This version is tail-recursive and returns a list of all evaluated results.

to_float/2

to_float(F::term(), D::float()) -> float()

Tries to convert any term into a float, using default value if it cannot be done.

to_integer/2

to_integer(F::term(), D::integer()) -> integer()

Tries to convert any term into an integer, using default value if it cannot be done.

to_string/1

to_string() -> term()

to_string/2

to_string(F::term(), D::string()) -> string()

Tries to convert any term into a string, using default value if it cannot be done.


Generated by EDoc, Dec 25 2007, 02:37:31.