Hacker News new | ask | show | jobs
by d0mine 918 days 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)