3 ms·
range(100).reduce(plus, 0) isn't cryptic, what's cryptic is single character symbols. Looking at that line, unless you know K specifically, it's very difficult
by ehsankia 7y ago
range(100).reduce(plus, 0) isn't cryptic, what's cryptic is single character symbols. Looking at that line, unless you know K specifically, it's very difficult to figure out it's a reduce. Where as `sum(range(100))` is pretty self explanatory to most programmers who don't know python.
- rabidrat 7y agoNot to mention it's a lot easier to search for `reduce` than `+`.
- kaminari 7y agoI don't know K but "+/" immediately stood out to me as "add over", so I think they made a good choice in using "/" for fold. "!", on the other hand...
- chrispsn 7y agoWhat would be a more obvious symbol choice for range (aka til or seq)? Pound (#)?
- qayxc 7y agoThere's no good (or bad) choices for mapping abstract concepts like ranges, mapping, reducing, or combining to common (ASCII-) symbols. Every choice is inherently arbitrary and carries no meaning whatsoever (besides maybe ergonomics). One could just as well argue that "/" is the ISO 8000-2:2009 2-9.6 recommended symbol for division. The same source also shows why symbols alone are inadequate for an explicit representation of abstract concepts: the Nabla symbol alone represents 5 different operations depending on context according to the ISO standard.