2 ms·
You are absolutely right about that. Not just awk but it happens in almost all programming languages when you're tempted to write a very long code in a super ne
by superasn 8y ago
You are absolutely right about that. Not just awk but it happens in almost all programming languages when you're tempted to write a very long code in a super nested `array_map(array_filter(array_keys(.. .` type of expression.
Don't know why it gives me joy to write those things even when I know it would be far better to write the same in three nested for loops (which are less error prone, more maintainble and gives more flexibility like easy to "break").
- frankquist 8y agoCould you elaborate on that last part? I don't understand how for loops would be more maintainable and less error prone. They have more moving parts and therefore more room for error. Isn't the value proposition of the aforementioned functions exactly avoiding easy to mess up loops?
- superasn 8y agoFor starters when you're in a for loop it's easy to `break` out of it. Not sure if you can do it in array_map or array_filter. Secondly and this is a personal preference but the code looks more readable when the for statements are on different lines telling you which array is being iterated compared to the nested functions where the output of one function is piped as input to another.