Challenge 1: Replica of PHP's "max" Function

Problem statement

Write a version of PHP’s max function called _max that utilizes the fold operation of the bingo-functional library. Ensure that only non-negative integers are compared and other value types evaluate to 0.

The _max function should receive an array as a parameter and return the integer with the maximum value in the case that the array contains all non-negative integers and a 0 in all other cases.

Sample inputs and outputs

Sample input 1

$list = [10,12,14,16,18]

Expected output

18

Sample input 2

$list = [-1,-3,-5]

Expected output

0

Sample input 3

$list = [a,b,c,d,e]

Expected output

0

Get hands-on with 1200+ tech skills courses.