Comment

Comment by tjalfi

Set-based programming is a fairly old idea. Jack Schwartz[0] created SETL[1] in 1969.

SETL2[2] and SETLX[3] interpreters are available.

Here is a sample program[4] by Keith S. Thompson. I have removed the comment header for brevity.

  program Fizz_Buzz;
    fizz := {3, 6..100};
    buzz := {5, 10..100};
    fizzbuzz := fizz * buzz;
    fizz -:= fizzbuzz;
    buzz -:= fizzbuzz;
    num := {1..100} - fizz - buzz - fizzbuzz;
    line_map := {[n, "Fizz"]     : n in fizz} +
                {[n, "Buzz"]     : n in buzz} +
                {[n, "FizzBuzz"] : n in fizzbuzz} +
                {[n, n]          : n in num};
    loop for i in [1..100] do
        print(line_map(i));
    end loop;
  end Fizz_Buzz;
[0] http://www.settheory.com

[1] http://wiki.c2.com/?SetlLanguage

[2] http://www.setl.org/setl/

[3] https://randoom.org/Software/SetlX

[4] https://raw.githubusercontent.com/Keith-S-Thompson/fizzbuzz-...

Edited to fix formatting of footnotes and add newlines.

parent tjalfi 9 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton