(no title)
lokedhs | 2 years ago
As for the language, the longer version looks like an imperative solution please it is an imperative solution. Kap allows you to write code that looks mostly like your average scripting language:
a ← 0
sum ← 0
while (a < 10) {
sum ← sum + a
a ← a + 1
}
sum
But if all you are going to do is write code like that, you might just as well write it in Javascript (well, unless you want to take advantage of support for things like bignums, rationals and complex numbers).Of course, an actual Kap programmer wouldn't write the code above like that. They'd write it like this instead: +/⍳10
There is a perfectly valid argument that the ⍳ in the example above could be written in a different way, and sure, Rob Pike chose to use actual words in his version of APL, or you could use J where the example would be written as +/i.10
But none of that is really important, and most people in the array programming community doesn't care whether you write "plus reduce iota 10", or +/⍳10. What they really care about it how the idea of using array operations completely eliminates loops in most cases. That's what is interesting, not the choice of symbols.
No comments yet.