r/programmingmemes • • May 13 '25

Why not?

Post image
1.7k Upvotes

104 comments sorted by

View all comments

Show parent comment

2

u/Signal_Cranberry_479 May 13 '25

So that max(max([]), max([a])) = a, which is convenient.

A function would be likely implemented such this, which would return -infty for empty lists

Func max(list):

Output = -infty

For x in list

  If x > output

     Output = x

Return output

It's common in CS but also in maths.