<< the_union Sets Utilities >>

Scilab Scholar module for schools >> Sets > value

value

vector of values of elements in a set or character string

Calling sequence

v = value(e)

Arguments

e

set or character string

v

vector of values

Description

It is possible to assign values to the elements of a set. This enables one, for example, to have sets of coins, tickets or playing cards with values. For this, the value is given by placing them in parentheses at the end of the name of an element. For example to create a set of 3 coins called "a", "b" and "c", with values 1 euro, 1 euro and 2 euros, one writes :

set1=define_set("a(1)","b(1)","c(2)").

The function value returns the vector of values for the elements of a set, allowing numerical calculations to be done with them.

If an element does not have a value, the value of 0 is assumed.

If e is a character string, and its elements represent digits, the result is a vector of corresponding digits. This allows, for example, to obtain the vector of digits in an integer n by using the function call value(string(n)).

Examples

set1=define_set("a(1)","b(1)","c(2)")
v=value(set1)
sum(v)
set1=define_set("a","b(1)")
value(set1)
value("1234")
n=850;
value(string(n))

See Also

<< the_union Sets Utilities >>