Talk:Count how many vowels and consonants occur in a string: Difference between revisions

m
 
(6 intermediate revisions by 3 users not shown)
Line 25:
 
::: Yes but the problem is that, according to the [https://ring-lang.sourceforge.io/doc1.14/operators.html Ring documentation], 'not x and y' '''is''' evaluated as '(not x) and y' because the unary operator 'not' has higher precedence than the binary operator 'and'. It was the first thing I checked when I was trying to understand how he'd managed to arrive at 24 as the answer. What I suspect may have happened here is that he's copy/pasted the results from an earlier version of the code as it seems very unlikely there would be a bug in the language implementation for something as basic as this. --[[User:PureFox|PureFox]] ([[User talk:PureFox|talk]]) 09:14, 27 July 2021 (UTC)
 
:::: Doh, I think I might finally have understood it. Here's the original code:
::::<lang ring>for n = 1 to len(str)
if isvowel(str[n]) = 1
vowel += 1
else not isvowel(str[n]) and ascii(str[n]) > 64 and ascii(str[n]) < 123
cons += 1
ok
next</lang>
:::: Notice that there's no 'if' after the 'else'. So I think the following expression is simply evaluated and the result discarded. Consequently, if the character isn't a vowel, 'cons' will always be incremented and he'll end up with 24 consonants. --[[User:PureFox|PureFox]] ([[User talk:PureFox|talk]]) 10:05, 27 July 2021 (UTC)
 
::::: Oh, that is fabulous! Your "it seems very unlikely there would be a bug in the language implementation for something as basic as this" now rings so loud. (oh, pun not intended, but there it is) --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 15:18, 27 July 2021 (UTC)
 
: I'll second the deletion. This task is really hard to do correctly because the rules for when 'y' is a vowel are complicated. The 'y' in "country" used in the examples is unquestionably a vowel. 'y' is a vowel in words like "try" and "system" but not "you" or "yo-yo"). [[User:Garbanzo|Garbanzo]] ([[User talk:Garbanzo|talk]]) 01:20, 28 July 2021 (UTC)
 
== task wording ==
125

edits