Re: Exercism task - Bob

new topic     » goto parent     » topic index » view thread      » older message » newer message
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  
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu