3 ms·
> I see using the choice syntax as PROLOG-esque, rather than Python-esque. I didn’t think otherwise. Many functional languages have comprehension syntax, and I
by bmitc 4y ago
> I see using the choice syntax as PROLOG-esque, rather than Python-esque.
I didn’t think otherwise. Many functional languages have comprehension syntax, and I prefer declarative programming.
> When using this pattern, it's clearer to be able to express the space with the shortest syntax rather than the verbose one.
How is
x <- [1,2,3]
or
x <- {1,2,3}
more verbose than
x := (1|2|3)
? Also, the first and especially second are basically identical to mathematical syntax, but the first implies order better.
- TuringTest 4y agoTrue, those are not more verbose, but are merely list enumerations, not comprehension, which bundles multiple generators and tests within the same structure, e.g.: [(x, y) for x in [1, 3, 5] for y in [2, 7, 8] if x < y] It's a single monolithic expression that builds the list. The choice syntax however represents each generator and each test as separate expressions, which may even be part of different functions. This seems to offer more flexibility. For example (I don't know the exact syntax): x:=(1|2); y:=(7|8); x<y; result = (x,y) Here result is bound to the same values as in the comprehensive list; but these values are yield one at a time, instead of being part of a structure that you traverse.
- deleted 4y ago[deleted]