SETL

from Wikipedia, the free encyclopedia

SETL (Set Language, English for set language) is a high-level programming language that is based on the set theory of mathematics . It was developed in 1969/70 by Jack Schwartz at the Courant Institute of Mathematical Sciences of New York University .

SETL recognizes integer , real , string , boolean and the zero value omega (om) as fundamental data types . There is no strong typing , the data type of a variable is adapted depending on the assigned content. SETL also has automatic garbage collection .

SETL has two data structures , the unordered set (engl. Amount ) and the tuple (engl. Tuples ) as an ordered sequence of elements. A set has the peculiarity that there is no duplicate value in it, but this is permitted with a tuple . Except for this restriction, the content of a set or a tuple is arbitrary; they can also contain other sets and tuples . A special case is the map (short for mapping , Eng. Figure ). It is a set of ordered pairs and consists of tuples of length 2.

SETL also provides do-while loops , if-then-else and case statements . There are also specialized loops for iterating through tuples and sets .

SETL knows numerous operators for the basic arithmetic operations , as well as trigonometric and other mathematical tasks. SETL also has special operators for working with sets and character strings. You can also define your own operators.

implementation

Due to the long-term cooperation between New York University and scientists from Novosibirsk , SETL was implemented not only on computers from the American company Burrough , but also on Russian computers of the BESM-6 and ES EVM types . There are now various implementations for all common operating systems .

Sample source code

Two examples for outputting all prime numbers from 2 to n. The second example in particular shows that the language is based on set theory.

program primzahlen;
  $ Dieses Programm gibt alle Primzahlen aus, die kleiner als der eingelesene Parameter sind
  read(n);              $lese Parameter ein
  primes := { };        $Menge der ausgegebenen Primzahlen
  p := 2;               $erste Primzahl festlegen
  $ Schleife um weitere Primzahlen zu ermitteln
  loop while p < n do   $ Wiederhole solange p kleiner als n ist
    if notexists t in primes | p mod t = 0 then
      print(p);         $keine der bisherig ermittelten Primzahlen ist Teiler von p, also gib die Primzahl aus
      primes with := p; $Füge sie zur Menge der ausgegebenen Primzahlen hinzu
    end if;
    p := p + 1;         $Zu testende Zahl um eins erhöhen
  end loop;
end program primzahlen;
program primzahlen2;
  read(n);
  print({p in {2..n} | forall t in {2..p - 1} | p mod t > 0});
  $Gib die Menge aller Zahlen p aus der Menge 2 bis n aus, für die gilt,
  $dass p sich durch keine der Zahlen der Menge 2 bis p-1 glatt teilen lässt
 end program primzahlen2;

Web links