Comment by fainpul
1 day ago
I assume this is the same as this?
# python
[127 * sin(x * tau * freq / samplerate) for x in range(samplerate)]
1 day ago
I assume this is the same as this?
# python
[127 * sin(x * tau * freq / samplerate) for x in range(samplerate)]
For that matter,
Pretty much, yeah! The difference is that in Python the function that calculates a single value looks like:
...while the function that calculates a batch of values looks like:
Meanwhile in Lil (and I'd guess APL and K), the one function works in both situations.
You can get some nice speed-ups in Python by pushing iteration into a list comprehension, because it's more specialised in the byte-code than a for loop. It's a lot easier in Lil, since it often Just Works.
A few more examples in K and Lil where pervasive implicit iteration is useful, and why their conforming behavior is not equivalent to a simple .map() or a flat comprehension: http://beyondloom.com/blog/conforming.html
And in Julia it’s foo.(x).