3 ms·
I agree... But it is not my web site :) For example, the set-valued expression {1..n} is the set of integers 1 through n, and {p in {2..n} | foral
by stralep 16y ago
I agree... But it is not my web site :)
For example, the set-valued expression
{1..n}
is the set of integers 1 through n, and
{p in {2..n} | forall i in {2..p-1} | p mod i /= 0}
is the set of primes through n. (The first vertical bar here is best read as such that, and the second as a pause.)
http://setl.org/doc/setl.html#Overview http://setl.org/doc/setl.html#Overview
- gmartres 16y agoThat made me think of Haskell, so to compare here is the equivalent(and of course totally inefficient) Haskell version: [p| p <- [2..n], all (\i -> p `mod` i /= 0) [2..p-1]] So, has this language more to offer than list comprehensions?
- stralep 16y agoI believe, what Haskell is generating is list. What SETL is making, is set. Could this syntax be used over any monad? [edit] Of course, there are things like */[1..n] for finding factorial, but that is fold in Haskell. It's neat for scripting, and for me, for circuit complexity explorations.
- kapuzineralex 16y agoSo all the fuzz is about the fact that SETL has builtin support for sets? Really, I don't mean to be a troll, but is that it?
- alan-crowe 16y agoI find that example rather discouraging. Generating a list of prime numbers is an interesting toy problem because it comes with certain expections. The trial divisors are 2,3,5,7,9,... that is two and then odd numbers. One is supposed to stop early, when one reaches the square root of p, and one is supposed to detect this efficiently by looking at the quotinent and spotting that it is less than the trial divisor. This makes for messy code in any language. Which is very much the point. Will the language help you with the messiness of real applications? If the example ducks the challenge, that is a strike against the language.