elib1_misc

Functions

added_files(Dir, Fun) -> term()

Added files makes a listing of all the files in Dir
then it calls Fun(), finally in lists all the files
in Dir again. It returns a list of the files
which have been added to the directory.

as_bits(B) -> term()

convert a bitstring to a list of zeros and ones.
so <<2#11011:5>> is converted to [1,1,0,1,1]

bin2hex(B) -> term()

Convert a binary to list of hex characters.

byte_to_hex_string(X) -> term()

return the hex representation of a byte

check_io_list(T) -> term()

Test if an I/O list really is an IO list.

collect_atom(L) -> term()

Extract an atom from the start of a string.

collect_int(L) -> term()

extract a base ten integer from the start of a string

collect_string(T) -> term()

collect_string(S) -> {S1, S2} such that
S = S1 ++ S2. Here s1 must begin with a single or double quote.

collect_word(T) -> term()

Extracts the next word from the start of a string.

complete(Str, L) -> term()

complete(A, L) Compute possible completions of a
string. A is a string, L is a list of possible strings
that A might be the prefix of.

Return values:
error - means no string will ever match
{more,L} - means there are completions
but we need more characters. L = [Str] = a list of
possible strings that might match
{yes, S} - means there is a unique completion,
S is the largest string
such that A ++ S is a prefix of all the elements of L

dos2unix(T) -> term()

replace \r\n with \n.

downcase_char(X) -> term()

Convert uppercase character to lowercase.

dump(File, Term) -> term()

Dumps a term into a file. The extension .tmp
is added to the filename (so it is easy to delete all files
with the extension .tmp. This is very usuful for debugging
program which produce very large data structures

duplicates(X) -> term()

Return a list of all duplicated items in A

ensure_started(Name, Fun) -> term()

Ensure_started modified from
% File: eunit_server.erl
% By Richard Carlsson <richardc@it.uu.se>
Checks if there is a registered process called Name
If not spawns Fun() in a new process and registers it as Name

eval_file(File) -> term()

Evaluate a series of expressions contained in a file.

eval_string(Str) -> term()

Evaluate code in a string

every(Pid, Time, Fun) -> term()

Links to Pid then every Time Fun is
evaluated. If Pid exits, this process stops.

expand_file_template(FileIn, Assoc, FileOut) -> term()

Expand a template file, with property list to produce a file.

expand_tabs(Xs) -> term()

Expand tabs, the tab stop is assumed to be fixed 8 column tabs.

expand_template(Template, Assoc) -> term()

Expand a template and a property list.

extract_attribute(Mod, Key) -> term()

Extract an attribute from beam code.

extract_prefix(T, B) -> term()

if A is a prefix of B return {yes, C} where A ++ C = B
otherwise no

fetch(Key, L) -> term()

fetch(Key, PropertyList) -> Val or raises an errors.
provides a wrapper around lists:keyfind

file2lines(File) -> term()

Read file into line buffer
"\n" at the end of each linhe is retained

file2md5(File) -> term()

compute the MD5 checksum of a file

file2numberedlines(File) -> term()

Read file into numbered line buffer. The \n is retained at the end of
each line.

file2string(File) -> term()

file2template(File) -> term()

file2term(File) -> term()

Reads a file into a binary and
does binary_to_term on the
result.

file_size_and_type(File) -> term()

return the file type and length in bytes

find_src(Mod) -> term()

Given a module name find_src(Mod) attempts to find the source
code for the module. We look first in the current directory, thereafter
in ..\ebin. If all else fails try to load the module
and look in Mod:module_info(compile).

first(T) -> term()

The analog of last(L). last(L) is the last element in the
list. first(L) is all the elements except the last.
Obeys the identity: first(X) ++ last(X) == X for noempty
lists X.

flatten_io_list(L) -> term()

flattens an I/O list.

flush_buffer() -> term()

Clear all message out of the process mailbox.

for(Max, X2, F) -> term()

for(Min, Max, F) -> [F(Min), F(Min+1), ... F(Max)].

force(Fun) -> term()

Force evauation of a fun

foreach_chunk_in_file(File, BlockSize, Fun) -> term()

Open File and reads into binary chunks Len bytes at a
time for each chunk compute F(Bin) and return the list
[F(Bin)].

foreach_word_in_file(File, F) -> term()

Apply F(Word) to each Word contained in a given file.
We extract "words" from a file and call F(Word) for each word.
this is done for its side effect. There is no return value.

foreach_word_in_string(Str, F) -> term()

Apply F(Word) to each Word contained in a string.

forever() -> term()

Suspend for a very long time.

get_erl_section(File, Tag) -> term()

Extract a tagged region of a file.

get_erl_section(File, Tag) -> Data | exit + warning message

Looks in File for a section marked
Data is quoted for html

%% START:Tag
....
%% END:Tag

very strict Tag must come immediately after :

get_line(Str) -> term()

get next line
get_line(Str) -> {Line, Str'}

get_line(T, L) -> term()

Get line and add to reversed line.

have_common_prefix(L) -> term()

Find the common prefix in a list of strings.

hex2bin(Str) -> term()

Convert a hex string to a binary.

hex2list(T) -> term()

Convert a hex string to a list of bytes.

hex_nibble2int(X) -> term()

Convert a hex nibble chanrcater to an integer.

id(I) -> term()

Identity function.

include_dir() -> term()

Return the name of the include directory.

include_file(X) -> term()

Find the fully qualified name of a file in the include directory.

interlieve(Sep, T) -> term()

Interlieve a symbol Sep between elements in a list.
Given a list [X1,X2,...,Xn] makes the list.
[X1,Sep,X2,Sep,...,Sep,Xn].

is_alphanum(X) -> term()

test if a character is aphanumeric.

is_blank_line(T) -> term()

check if a line is all blank

is_prefix(T, T1) -> term()

true if A is a prefix of B otherwise false.

is_response_correct(Challenge, Response, Secret) -> term()

used in an MD5 callenge response test

keep_alive(Name, Fun) -> term()

Keep a registerd process alive, restarting if necessary.

lines2para(Lines) -> term()

Add \n between lines with \n's.

list2frequency_distribution(L) -> term()

Make a frequency distribution of a numbner of items in a list.

longest_common_prefix(L) -> term()

Given a list of strings return the longest prefix which is
common to all lists.

lookup(Key, L) -> term()

Fast property list lookup.
Fast because it uses the internal lists:keysearch which is a BIF

lorem(N) -> term()

extract N lines of Lorum ipsum

ls(Dir) -> term()

List the files in a directory.
Returns a directory listing relative to Dir -- the filenames are sorted.
classified as files or directories and the sizes are given.

make_challenge() -> term()

Make a random string to be used as a challenge in
challenge response authentication.

make_response(Challenge, Secret) -> term()

Makwe the response for a challenge response authentication
algorithm.

make_test_strings(Str) -> term()

make_test_strings(Str)

merge_kv(KV) -> term()

Take a property list [{Key,Val}] where Key can occur
More than once and make it into a list {Key, [Val]} where
each Key occurs only once.

mini_shell() -> term()

Emulate the shell.

ndots(T) -> term()

Count the number of dots in a string

nibble_to_hex_char(X) -> term()

Convert an integer in 0..15 to a hex character

odd(X) -> term()

odd(X) is true if X is odd

on_exit(Pid, Fun) -> term()

on_exit(Pid, Fun) links to Pid. If Pid dies
with reason Why then Fun(Why) is evaluated.

out_of_date(In, Out) -> term()

outfile(File, Ext) -> term()

padd(X, L) -> term()

add X to L if it is not a member of the list
padd is short for "possible add"

perms(L) -> term()

Return all permutations of a string.

pmap(F, L) -> term()

Parallel version of map

pmap1(F, L) -> term()

Parallel map that is not order preserving.
pmap1([X,Y,Z]) return any permutation of [F(X), F(Y), F(Z)].

priority_receive() -> term()

priority receive

random_seed() -> term()

Seed the random number generator.
This is evaluated for its side effect. Now well tested at all.

random_string(N) -> term()

Return a random string with N characters.

read_at_most_n_lines(File, N) -> term()

Read the first N lines of a file.

remove_duplicates(L) -> term()

Remove duplicate entries from a list. The resulting list
is sorted.

remove_leading_and_trailing_whitespace(X) -> term()

remove leading and trailing white space from a string.

remove_leading_whitespace(T) -> term()

remove leading white space from a string.

remove_prefix(T, T1) -> term()

remove_prefix(X, Y) -> Z finds Z such that X ++ Z = Y
Note: this is only called when it is known that
X is a prefix of Y

remove_trailing_whitespace(X) -> term()

remove trailing white space from a string.

replace(Key, Val, Old) -> term()

Replace and Key with Key,Val in the property list
Old.

root_dir() -> term()

the root dir of the library

rpc(Pid, Q) -> term()

Standard RPC.

safe(Fun) -> term()

Evauate a function within a catch to make it safe.

show_loaded(Fun0) -> term()

show_loaded(Fun0) -> Mods
show which functions get loaded
when you evaluate Fun0().

skip_blanks(T) -> term()

Remove any spaces at the beginning of a string.

skip_to_nl(T) -> term()

skip all characters up to and including new line

sleep(T) -> term()

sleep(N) sleeps for N milliseconds.

spawn_monitor(Term, X2, Fun) -> term()

spawn_monitor behaves just like spawn but
prints a message when the function terminates.
spawn_monitor(Term, Flag, Fun0) spawns Fun0 and prints Term
when the function terminates if Flag =0 true.

split_at_char(Str, C) -> term()

Split a string at the first occurance of a given character.

split_list(Fun1, L) -> term()

split(Fun, [X]) -> [{Header,[X]}]
Splits a lists
Fun(X) -> {yes, Header} | no
the list L is partitioned into segments
for which Fun(X) -> {yes,Header}
The header '$none' is used for leading
elements in the list

string2exprs(Str) -> term()

Convert a string contianign a number of expressions to
the abstract form of the expressions.

string2html(T) -> term()

Quote < and & so they can be included in HTML.

string2latex(T) -> term()

Turn a Erlang string into a LateX string quiting where necessary.

string2lines(Str) -> term()

Split a string into lines. Each line is terminated by
\n of eof. \n at end of each line is retained

string2stream(Str) -> term()

Convert a string to a stream.

string2template(Str) -> term()

Parse a string containing a template.

string2term(Str) -> term()

Convert a string to a term.

string2toks(T) -> term()

simple tokeniser. Turns a string into a list of tokens

sub_binary(Bin, Start, Stop) -> term()

return the binary between Start and Stop in Bin

template2file(Template, Assoc, FileOut) -> term()

fill in the template and write to file

term2file(File, Term) -> term()

Write term_to_binary(Term) to a file.

term2string(Term) -> term()

Convert a term to a printable string.

test_function_over_substrings(F, Str) -> term()

Tests a function by calling it with different substrings of
a given string.

tex2pdf(File) -> term()

TeX to PDF
Run pdflatex on the created /verb+.tex+ file.
In the rare event that you get a syntax error in your generated
.tex file then the best thig to do is manually run pdflatex
to determine the fault.
Runs with output in the directory where File is

time_fun(Str, Fun) -> term()

time_fun(Str, Fun)
times Fun().
Prints Str and time if evaluation of Fun succeeds
otherwise prints error

time_stamp() -> term()

return a string contining the current data and time

to_lower(Str) -> term()

Lowercase a string.

trim(S) -> term()

remove leading and trailing white space from a string.

unconsult(File, L) -> term()

Write a file (inverse of consult).
A joke.

which(Mod) -> term()

Find the directory name where a module was loaded from.

which_added(Fun) -> term()

spawn a fun and find out which additional modules get loaded.
Returns the names of the new modules which have been loaded and
where they were loaded from.