Talk:Count how many vowels and consonants occur in a string: Difference between revisions
Talk:Count how many vowels and consonants occur in a string (view source)
Revision as of 01:20, 28 July 2021
, 2 years ago→Trivial task, but apparently not trivial enough
No edit summary |
|||
(8 intermediate revisions by 4 users not shown) | |||
Line 23:
::though personally I prefer the middle style anyway. --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 04:17, 27 July 2021 (UTC)
::: 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 ==
Line 38 ⟶ 54:
:: Obviously I understand your frustration but ideally there would be a "banned from creating tasks" feature/setting on rc. I mean it's not like there aren't 600+ existing tasks with no Ring entry, and it might be better all round if Calmosoft turned his attention to filling some of them in. It might even be a good idea for everyone to only be allowed to create a new task for every N other additions/updates to tasks they did not create. --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 03:49, 27 July 2021 (UTC)
|