set


set(obj)
      

Return a set initialized with the elements in the object obj. Obj must be either a set, a list, an array, a string or a hash table. If obj is a hash table, each key-value pair will become an entry in the set.

A set stores an unordered sequence of objects without duplicates. It is an implementation of the mathematical concept of a finite set. Unlike most other collection types, rather than retrieving a specific element from a set, one typically tests a value for membership in a set. A set literal is written by enclosing the objects in #(), example: #(1, 2, 3, 4, 5).

Examples:


set(#{1:2, 3:4}) // hash table -> set
// #(1:2, 3:4)

set("hello, world") // string -> set
// #(\,,\o,\e,\w,\r,\h,\d,\l,\space)

set([1,2,3,2,3,4]) // list -> set
// #(1,2,3,4)

set(#[1,2,3,2,3,4]) // array -> set
// #(1,2,3,4)

set(#(1,2,3,2,3,4)) // set -> set
// #(1,2,3,4)
      

Also see:

make_set
set_length
is_set
is_set_member
set_difference
set_intersection
set_union
is_superset
is_subset
set_to_list


Core Module Index | Contents