# Antescofo Library of Predefined Functions

Antescofo includes more than 360 predefined functions. They are described mostly in the chapters Expressions, Scalar values and Data structures. For the reader's convenience, we give here a list of these functions and there is a description page for each of them in the next section.

In these following sections, the sequence of names after the function defines the type of the arguments accepted by a function. For example numeric is used when an argument must satisfy the predicate @is_numeric, that is @is_int or @is_float. In addition, we use the term value when the function accepts any kind of argument.

In the rest of this page, we recall some useful features of Antescofo functions (see chapter Functions for a more detailed treatment) and we list the predefined functions using several categories in order to facilitate their identification according to their uses.

## Listable Functions and Listable Predicates¶

When a function f is marked as listable, the function is extended to accept tab arguments in addition to scalar arguments. Usually, the result of the application of f on a tab is the tab resulting on the point-wise application of f to the scalar elements of the tab. But for predicate, i.e. a function that returns a bool, the result is the predicate that returns true if the scalar version returns true on all the elements of the tabs.

For example, @abs is a listable function on numeric, so it can be applied to a tab of numerics. The result is the tab of the absolute value of the elements of the tab argument.

Another example: the function @approx is a listable predicate and @approx(u, v) returns true if @approx(u[i], v[i]) returns true for all elements i of the tabs u and v.

Some functions accept different kinds of values for the same argument. For example @insert accepts tab or map as its first argument. Such functions are said overloaded: they gather under the same name several specialized version of the function.

A user-defined function can be overloaded: it recquires to check the type of the argument value to dispatch to the specialized versions (written elsewhere).

Overloading methods is more simple: the same identifier can be used to name a method in different objects.

## Side-Effect¶

Most functions are pure functions, that is, they do not modify their arguments and build a new value for the result.

In some cases, the function works by a side-effect, like @push_back which modifies its argument in place. Such functions are marked as impure. We also qualify functions that may return different values when called with the same arguments as impure, even if they do not produce a side-effect (for example, functions that return a random number).

## Special forms¶

Special forms are syntactic constructs similar to function calls but that are subject to some restriction or that behave differently of a function call.

For example, boolean predicates are a special form of function application because they do not always evaluate all their arguments (they are lazy). For instance, the conjunction && evaluates its second argument only if the first is not false.

Another example is @plot, @history_length or @dumpvar that only accepts a variable as an argument, not a general expression.

Special forms cannot be curryfied nor passed as an argument: they are not ordinary functional values. Note, howevever that they can be wrapped in a user-defined function which is an ordinary functional value.

## Infix function call¶

A function call is usually written in prefix form:

      @drop($t, 1) @scramble($t)


It is possible to write function calls in infix form, as follows:

      $t.@drop(1)$t.@scramble()


The @ character is optional when naming a function in infix call, so we can also write:

      $t.drop(1)$t.scramble()


This syntax is the same as for a method call. The general form is:

      arg1 . @fct (arg2, arg3, ...)    ; or more simply
arg1 . fct (arg2, arg3, ...)


The argi are expressions. Notice that the infix call, with or without the @ in the function name, is not ambiguous with the notation used to refer to a variable local $x in a compound action from the exe of this action, exe.$x, because $x cannot be the name of a function. The infix notation is less general than the prefix notation. In the prefix notation, the function can be given by an expression. For example, functions can be stored into an array and then called following the result of an expression: $t := [@f, @g]
; ...
($t[exp])()  will call @f or @g following the value returned by the evaluation of exp. Only function name (with or without @) are accepted in the infix notation. ## Named parameters and optional arguments in functions applications¶ The identifier of the arguments in a function definition can be used, withoout the leading $ as a name for an out-of-order argument passing in function application. See section Named parameters and out-of-order application (this also holds for processes and methods).

Arguments may have a default value, as explained in section Optional arguments and default argument's value. In case of partial application, these arguments take their default value if they are not explicitly specified in the call.

# Listing by categories¶

Function names in square brackets are either reserved for internal use or awaiting documentation.

## String Management¶

Most functions acting on tabs operate also on strings.

For regular expressions, see @r_compile and also @parse.

## Predicates¶

@!=    @&&    @||    @<=    @<    @==    @>=    @>    @approx    @arch_darwin    @arch_linux    @arch_windows    @between    @empty    @find    [@is_applicable]    [@is_applicable_exe]    @is_bool    @is_defined    @is_exec    @is_fct    @is_float    @is_fct    [@is_fun]    @is_function    @is_int    @is_integer_indexed    @is_list    @is_map    [@is_Napplicable]    @is_nim    [@is_not_initialized]    @is_numeric    [@is_paf]    @is_obj    @is_obj_xxx    @is_prefix    @is_proc    @is_string    [@is_string_or_symbol]    @is_subsequence    @is_suffix    @is_symbol    @is_tab    @is_undef    @is_vector    @member    @occurs

## Score Introspection¶

[@always_next_event_except_sil_pos]   @bach_score   @current_event   @event_label_position   @make_bpm_map   @make_bpm_tab   @make_duration_map   @make_duration_tab   @make_label_bpm   @make_label_duration   @make_label_pitches   @make_label_pos   @make_pitch_tab   @make_score_map   [@next_event_except_sil_pos]   [@next_event_with_sil_pos]   [@next_sil_pos]   @optional_attributes    @performance_data    @score_duration    @score_tempi   @specified_duration

# Alphabetical Listing of Antescofo Predefined Functions¶

Function names in square brackets are either reserved for internal use or awaiting documentation. This listing is automatically produced by the command antescofo::libraryinfo.

## @H...¶

[@has_apply]    @host_date    [@hypot]    @hz2midi    @hz2midicent    @hz2symb

## @I...¶

[@i2base]    [@ideal_beat2sec]    [@ideal_sec2beat]    [@ideal_tempo]    @info    @insert    [@integrate0]    [@integrate_symb]    [@inverse_symb]    @iota    [@is_applicable]    [@is_applicable_exe]    @is_bool    @is_defined    @is_exec    @is_fastforward    @is_fct    @is_float    @is_following_on    [@is_fun]    @is_function    [@is_inf]    [@is_initialized]    @is_int    @is_integer_indexed    @is_list    @is_map    [@is_nan]    [@is_Napplicable]    @is_nim    [@is_not_initialized]    @is_numeric    @is_obj    [@is_paf]    @is_paused    @is_playing_on    @is_prefix    @is_proc    @is_running    @is_stopped    @is_string    [@is_string_or_symb]    @is_subsequence    @is_suffix    @is_symbol    @is_tab    @is_undef    @is_vector

## @L...¶

@lace    @last    [@lgamma]    [@linear_approx]    @linearize    @listify    [@lnow]    @loadvalue    @loadvar    @local_beat_position    @local_tempo    @log    @log10    @log2    @logical_date

## @N...¶

[@nan]    [@next_event_except_sil_pos]    [@next_event_with_sil_pos]    [@next_sil_pos]    @nim2vezer    [@nimify]    @normalize    @number_active

## @O...¶

@occurs    [@odei_map_function]    @optional_attributes

## @P...¶

@parse    @performance_data    [@performance_tempo]    @permute    @pow    @print    [@priority]    @projection    @push_back    @push_front    @pwd

## @R...¶

@r_compile    @r_findall    @r_match    @r_search    @rand    @rand_int    @random    @range    @read_file    @reduce    [@remainder]    @remove    @remove_duplicate    @replace    @reshape    @resize    @reverse    @rnd_bernoulli    @rnd_binomial    [@rnd_cauchy]    [@rnd_chi_squared]    @rnd_exponential    @rnd_gamma    @rnd_geometric    [@rnd_lognormal_distribution]    [@rnd_negative_binomial]    @rnd_normal    [@rnd_poisson]    @rnd_uniform_float    @rnd_uniform_int    [@rnd_weibull]    @rotate    @round

## @T...¶

@take    @tan    [@tanh]    @tgamma    @time    @to_num    @Tracing    [@type_of]    @typecheck

## @W...¶

[@window_filter]

## @_...¶

[@_sleep]    [@_yield]    [@_terminate]    [@_print]    [@_thread_qos]    [@_gotcha]