# Antescofo Library
of Predefined Functions

Antescofo includes a set of 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.

In the following pages, 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.

### 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`.

### Overloaded functions

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.

### Function call in infix form

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.

## Listing by categories

### mathematical functions:

@abs, @acos, @asin, @atan, @between, @ceil, @clear, @cos, @cosh, @exp, @floor, @log, @log10, @log2, @max, @min, @pow, @rand, @rand_int, @random, @rnd_bernoulli, @rnd_binomial, @rnd_exponential, @rnd_gamma, @rnd_geometric, @rnd_normal, @rnd_uniform_float, @rnd_uniform_int, @round, @sin, @sinh, @sqrt, @tan

### random related functions:

@rand, @rand_int, @random, @rnd_bernoulli, @rnd_binomial, @rnd_exponential, @rnd_gamma, @rnd_geometric, @rnd_normal, @rnd_uniform_float, @rnd_uniform_int

### tab related functions:

@car, @cdr, @clear, @concat, @cons, @copy, @count, @dim, @domain, @drop, @empty, @explode, @find, @flatten, @gnuplot, @insert, @iota, @is_list, @is_prefix, @is_subsequence, @is_suffix, @lace, @last, @listify, @map, @max_val, @median, @member, @normalize, @occurs, @permute, @push_back, @push_front, @range, @reduce, @remove, @remove_duplicate, @replace, @resize, @reverse, @rotate, @scan, @scramble, @size, @slice, @sort, @sputter, @stutter, @tab_history, @tab_history_date, @tab_history_rdate, @take

in addition, see listable functions.

### listable functions:

@!=, @%, @&&, @!=, @%, @&&, @*, @+, @-, @<, @<=, @==, @>, @>=, @div, @||, @+, @-, @<, @<=, @==, @>, @>=, @div, @||, @/, @abs, @acos, @approx, @asin, @atan, @between, @ceil, @cos, @cosh, @exp, @floor, @log, @log10, @log2, @pow, @round, @sin, @sinh, @sqrt, @tan

### nim related functions:

@aggregate, @align_breakpoints, @dim, @filter_max_t, @filter_median_t, @filter_min_t, @integrate, @linearize, @max_key, @max_val, @min, @min_key, @min_val, @projection, @push_back, @push_front, @sample, @simplify_lang_v, @simplify_radial_distance_t, @simplify_radial_distance_v, @window_filter_t

### map related functions:

@add_pair, @clear, @count, @domain, @find, @gshift_map, @insert, @is_defined, @is_function, @is_map, @listify, @make_duration_map, @make_label_bpm, @make_label_duration, @make_label_pitches, @make_label_pos, @make_score_map, @map, @map_compose, @map_concat, @map_history, @map_history_date, @map_history_rdate, @map_normalize, @map_reverse, @mapval, @max_key, @max_val, @member, @merge, @min_key, @min_val, @occurs, @range, @remove, @select_map, @shift_map

### string related functions:

@count, @dump, @dumpvar, @explode, @find, @is_prefix, @is_string, @is_subsequence, @is_suffix, @member, @occurs, @push_back, @string2fun, @string2proc, @system, @Tracing, @UnTracing

### predicates:

@!=, @&&, @||, @<=, @<, @==, @>=, @>, @approx, @arch_darwin, @arch_linux, @arch_windows, @between, @empty, @find, @is_bool, @is_defined, @is_exec, @is_fct, @is_float, @is_function, @is_int, @is_integer_indexed, @is_list, @is_map, @is_nim, @is_numeric, @is_obj, @is_obj_xxx, @is_prefix, @is_string, @is_subsequence, @is_suffix, @is_symbol, @is_undef, @is_vector, @member, @occurs

### score related functions:

@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 @score_tempi

### system related functions:

@arch_darwin, @arch_linux, @arch_windows, @dumpvar, @gnuplot, @history_length, @loadvalue, @loadvar, @plot, @rplot, @savevalue, @set_osc_handling_tab, @string2fun, @string2obj, @string2proc, @system

## Alphabetical Listing of Antescofo Predefined Functions

@!=

@%

@&&

@!=

@%

@&&

@*

@+

@-

@<

@<=

@==

@>

@>=

@div

@||

@+

@-

@<

@<=

@==

@>

@>=

@div

@||

@abs

@acos

@active

@add_pair

@aggregate

@align_breakpoints

@approx

@arch_darwin

@arch_linux

@arch_windows

@asin

@atan

@between

@bounded_integrate

@bounded_integrate_inv

@car

@cdr

@ceil

@clear

@concat

@cons

@copy

@cos

@cosh

@count

@dim

@domain

@drop

@dump

@dumpvar

@empty

@exp

@explode

@filter_max_t

@filter_median_t

@filter_min_t

@find

@flatten

@floor

@gnuplot

@gshift_map

@history_length

@insert

@integrate

@iota

@is_bool

@is_defined

@is_exec

@is_fct

@is_float

@is_function

@is_int

@is_integer_indexed

@is_interpolatedmap

@is_list

@is_map

@is_nim

@is_numeric

@is_obj

@is_obj_xxx

@is_prefix

@is_proc

@is_string

@is_subsequence

@is_suffix

@is_symbol

@is_tab

@is_undef

@is_vector

@lace

@last

@linearize

@listify

@loadvalue

@loadvar

@log

@log10

@log2

@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_score_map

@map

@map_compose

@map_concat

@map_history

@map_history_date

@map_history_rdate

@map_normalize

@map_reverse

@mapval

@max

@max_key

@max_val

@median

@member

@merge

@min

@min_key

@min_val

@normalize

@number_active

@occurs

@permute

@plot

@pow

@projection

@push_back

@push_front

@rand

@rand_int

@random

@range

@reduce

@remove

@remove_duplicate

@replace

@reshape

@resize

@reverse

@rnd_bernoulli

@rnd_binomial

@rnd_exponential

@rnd_gamma

@rnd_geometric

@rnd_normal

@rnd_uniform_float

@rnd_uniform_int

@rotate

@round

@rplot

@sample

@savevalue

@scan

@score_tempi

@scramble

@select_map

@set_osc_handling_tab

@shape

@shift_map

@simplify_lang_v

@simplify_radial_distance_t

@simplify_radial_distance_v

@sin

@sinh

@size

@slice

@sort

@sputter

@sqrt

@string2fun

@string2proc

@stutter

@system

@tab_history

@tab_history_date

@tab_history_rdate

@take

@tan

@Tracing

@UnTracing

@window_filter_t

#### Search

From here you can search these documents. Enter your search terms below.