module Convert: sig
.. end
Convenience functions for accessing terms with OCaml.
exception Convert_error of string
Raised if the input term is not suited for application of a
conversion function.
Converting from Terms to OCaml
val term_to_string : Term.term -> string
Input must be an atom term. Output is its symbol name
val map_term : (Term.term -> 'a) -> Term.term -> 'a list
Input must be a list term. The function is applied to all members and
a list of result is returned.
val term_to_alist : Term.term -> (string * Term.term) list
Input must be a list term of Key=Value pairs. Output is an association
list, where the keys are strings obtained by term_to_string
from
the original keys, and the values are the original terms.
val term_is_list : Term.term -> bool
Returns true if the input term has ./2 or []/0 as main functor.
val term_list_to_list : Term.term -> Term.term list
Input must be a proper list, i.e. each tail must be a list.
The result is a list of the element terms.
val term_sequence_to_list : Term.symbol -> Term.term -> Term.term list
Input must be a sequence constructed from a binary functor, such
that the first argument is the element and the second argument the
rest sequence or the last element (which must have a different main
functor). symbol
specifies the binary functor. The output is a list
of the elements.
val term_to_int : Term.term -> int
Input must be an integer term. Output is an integer.
val term_to_float : Term.term -> float
Input must be a float term. Output is a float.
val term_to_array_of_int : Term.term -> int array
Input must be a list of integer terms. Output is an array of integers.
val term_to_array_of_float : Term.term -> float array
Input must be a list of float terms. Output is an array of floats.
Functions for Accessing Terms in Special Ways
val term_nth_arg : Term.term -> int -> Term.term
Return the nth argument of a compound term.
val term_pair : Term.term -> Term.term * Term.term
Return a pair of the first and second argument of a compound term.
val symbol_to_string : Term.symbol -> string
Returns a string represenation "symbol-name/arity" of the given symbol.
val term_functor_symbol : Term.term -> Term.symbol
Input must be a constant or compound. Result is its functor symbol.
val term_functor_pair : Term.term -> string * int
Input must be a constant or compound. Result is its functor as
(name, arity)
pair.
val predspec_pair : Term.term -> string * int
Input must be a term of the form functor/arity
. Result is the
corresponding (name, arity)
pair.
Converting from OCaml to Terms
val list_of_term_to_term : Term.symbol_table -> Term.term list -> Term.term
val list_of_term_to_term_1 : Term.symbol -> Term.symbol -> Term.term list -> Term.term
val array_of_int_to_term : Term.symbol_table -> int array -> Term.term
val list_of_int_to_term : Term.symbol_table -> int list -> Term.term
val array_of_float_to_term : Term.symbol_table -> float array -> Term.term
val list_of_float_to_term : Term.symbol_table -> float list -> Term.term
val alist_to_term : Term.symbol_table -> (string * Term.term) list -> Term.term
val symbol_to_pred_spec_term : Term.symbol_table -> Term.symbol -> Term.term
val array_to_compound : Term.symbol_table -> string -> Term.term array -> Term.term
val string_to_term : Term.symbol_table -> string -> Term.term
val int_to_term : int -> Term.term
val float_to_term : float -> Term.term