Re: Exercism task - Bob
- Posted by petelomax Feb 13, 2023
- 846 views
axtens_bruce said...
The equal against upper didn't work properly so went back to the original. Filtering "out" all the whitespace worked nicely.
Aye, the actual test needed turns out to be equal(s,upper(s)) and not equal(s,(lower(s)).
Here's my (this time tested!) Phix version for comparison, in my usual semi-code-golf style:
function hey(string s) s = trim(s) if length(s)=0 then return "Fine. Be that way!" end if bool all_caps = equal(s,upper(s)) and not equal(s,lower(s)) return iff(s[$]='?'?iff(all_caps?"Calm down, I know what I'm doing!" :"Sure.") :iff(all_caps?"Whoa, chill out!" :"Whatever.")) end function

