SETL (SET Language) is a very high-level programming language based on the mathematical theory of sets. It was originally developed by (Jack) Jacob T. Schwartz at the New York University (NYU) Courant Institute of Mathematical Sciences in the late 1960s.
SETL provides two basic aggregate data types: unordered sets, and sequences (the latter also called tuples). The elements of sets and tuples can be of any arbitrary type, including sets and tuples themselves. Maps are provided as sets of pairs (i.e., tuples of length 2) and can have arbitrary domain and range types. Primitive operations in SETL include set membership, union, intersection, and power set construction, among others.
SETL provides quantified boolean expressions constructed using the universal and existential quantifiers of first-order predicate logic.
SETL provides several iterators to produce a variety of loops over aggregate data structures.
Print all prime numbers from 2 to :
print([n in [2..N] | forall m in {2..n - 1} | n mod m > 0]);
The notation is similar to list comprehension.
A factorial procedure definition:
procedure factorial(n); -- calculates the factorial n!
return if n = 1 then 1 else n * factorial(n - 1) end if;
end factorial;
A more conventional SETL expression for factorial (n > 0):
/[1..n]
Implementations of SETL were available on the DEC VAX, IBM/370, SUN workstation and APOLLO.
In the 1970s, SETL was ported to the BESM-6, ES EVM and other Russian computer systems.
SETL was used for an early implementation of the programming language Ada, named the NYU Ada/ED translator. This later became the first validated Ada implementation, certified on April 11, 1983.
According to Guido van Rossum, "Python's predecessor, ABC, was inspired by SETL -- Lambert Meertens spent a year with the SETL group at NYU before coming up with the final ABC design!"
SET Language 2 (SETL2), a backward incompatible descendant of SETL, was created by Kirk Snyder of the Courant Institute of Mathematical Sciences at New York University in the late 1980s.