I have a function which needs to determine whether all letters in an input is uppercase. Why does the works() version work, but the fails() version fail when I feed it a string without any alphabetic characters? More specifically, the following three test strings all return true while it should return false:
Thanks! I understand what went wrong with fails() now. It returned true for a string with no alphabetic characters as well, while it should actually check that at least one character in the string is alphabetic.
BTW, your fails_but_works_now() function doesn't do the same as works(). works() makes sure that there is at least one alphabetic character and exactly no lowercase characters in the input string. fails_but_works_now() tests that there is at least one uppercase alphabetic character, but doesn't return false on input where there are lowercase characters.
Thanks! I learnt something today. But I think my first works() function is both shorter and clearer than try_fold(), so I'll stick to that for this specific problem