3 ms·
>Hmm, yes, but it's not a lazy array/list, so it's not online, is it. If you have a few million files in a directory, that's not going to work. It is lazy. The
by Arnavion 7y ago
>Hmm, yes, but it's not a lazy array/list, so it's not online, is it. If you have a few million files in a directory, that's not going to work.
It is lazy. The author slightly misunderstood / oversimplified what's going on. The commandlet does not build an entire array in memory and then write it out; it writes out each item one at a time. Evaluating it as `$(dir)` just forces all its output to be collected into a single value, ie an array. It's the equivalent of writing `output="$(ls)"; <<< $output head -n3` in bash.
I posted an alternative way to write this in https://news.ycombinator.com/item?id=22963842 https://news.ycombinator.com/item?id=22963842 which does not need to build the output as an array first and is also more natural to write.
- cryptonector 7y agoThanks for the clarification.