News for hackers. Stuff that matters.
Re:How not to teach recursion (2021) by alecbz on Saturday June 18, 2022 @01:07PM (#31791723)
I don't know if that's a helpful framing?

    def sum(arr):
       total = 0
       for x in arr:
          total += x
       return total

and

    def sum(arr):
      if len(arr) == 0:
         return 0
      return arr[0] + sum(arr[1:])

both operate over an array but I'd call one of them recursive and the other iterative.

There are no comments on this comment yet.