next up previous contents
Next: The length Function Up: Built-in Functions for Sets, Previous: Built-in Functions for Sets,

The op Operator

The op operator takes either a set, list (array) or string and returns the sequence of expressions formed by removing the outermost braces (set), square brackets (list) or single quotes (string).

> weekdays := ['monday', 'tuesday', 'wednesday', 'thursday', 
>              'friday'];                                    # a list
weekdays := [monday, tuesday, wednesday, thursday, friday]
> op(weekdays);
monday, tuesday, wednesday, thursday, friday                 # a string
> op(weekdays[1]);
monday
> numbers := {1, 2, 3, 4};                                   # a set
numbers := {1,2,3,4}
> op(numbers);
1, 2, 3, 4
We can exploit this operator to combine two lists into a single new list.
> weekdays := ['monday', 'tuesday', 'wednesday', 'thursday', 'friday']:
> weekends := ['saturday', 'sunday']:
> week := [ op(weekdays), op(weekends) ];
week := [monday, tuesday, wednesday, thursday, friday, saturday, sunday]



Gaston Gonnet
1998-09-15