DEV Community

Discussion on: Write Clean Code Without Loops

Collapse
 
costinmanda profile image
Costin Manda

One example from the top of my head is finding the minimum and maximum of a list. One can use list.min() and list.max(), but it means iterating twice even if it is clearer code. One can use a reduce/Aggregate with a seed that is a tuple, but it's difficult to read. In the end, good old for or foreach loop is the simpler option.

Maybe that's not the best example, but it's what I came up with on a short notice.