Did you know ... Search Documentation:
Pack prolog_library_collection -- prolog/math_ext.pl
PublicShow source
 avg_list(+Numbers:list(number), +Avg:number) is semidet
avg_list(+Numbers:list(number), -Avg:number) is det

Examples

?- avg_list([1 rdiv 3, 1 rdiv 6], X).
X = 1 rdiv 4.

Special cases

Avg is the integer 0 in case Numbers is the empty list. This is in line with how sum_list/2 works.

throws
- instantiation_error if Numbers is non-ground.
 between(+Low:integer, +High:integer, +Interval:integer, +Value:integer) is semidet
between(+Low:integer, +High:integer, +Interval:integer, -Value:integer) is nondet
 decimal_parts(+Decimal:number, -Integer:integer, -Frac:nonneg) is det
decimal_parts(-Decimal:number, +Integer:integer, +Frac:nonneg) is det
throws
- instantation_error
- type_error
 fractional_integer(+Frac:number, -Int:integer) is det
Variant of float_fractional_part/2 where the integer value instead of the fractional part is returned.
 fractional_weights(-Frac:number, +Weights:list(between(0,9))) is det
fractional_weights(+Frac:number, -Weights:list(between(0,9))) is det
 inf_max(+X, +Y, -Z) is det
 inf_min(+X, +Y, -Z) is det
 integer_weights(+Int:nonneg, +Weights:list(between(0,9))) is semidet
integer_weights(-Int:nonneg, +Weights:list(between(0,9))) is det
integer_weights(+Int:nonneg, -Weights:list(between(0,9))) is det
 integer_weights(+Int:nonneg, +Base:nonneg, +Weights:list(between(0,9))) is semidet
integer_weights(-Int:nonneg, +Base:nonneg, +Weights:list(between(0,9))) is det
integer_weights(+Int:nonneg, +Base:nonneg, -Weights:list(between(0,9))) is det
See also
- http://stackoverflow.com/questions/4192063/reversible-binary-to-number-predicate/28442760#28442760