3 ms·
Loops themselves can be considered just convenient wrappers around goto. The point is to restrict the variety (structured programming) and make spaghetti unread
by d0mine 3y ago
Loops themselves can be considered just convenient wrappers around goto. The point is to restrict the variety (structured programming) and make spaghetti unreadable code less likely.
Using higher-order functions instead of loops is similar e.g. loops:
# input_ = "1,2,3"
numbers = (int(d) for d in input_.split(","))
product = 1
for n in numbers:
product *= n
can be replaced:
numbers = map(int, input_.split(","))
product = reduce(mul, numbers, 1)
- deleted 3y ago[deleted]