1. Buggy sample codes?

Hello,

I'm totally new to Euphoria (stumbled upon it on Pro-Linux.de while bored on Christmas Eve *g*). The unusual data types got me hooked, so I decided to give it a try.

Today I worked myself through the sample codes for "99 bottles of beer" (http://openeuphoria.org/wiki/view/SampleCode.wc), and "Reverse Game" (http://openeuphoria.org/wiki/view.wc?page=ReverseGame). However, those two appear to be buggy (didn't try "Sieve of Eratosthenes"):

In "99 bottles of beer" it's the colon in the case statements where the interpreter throws an error. I changed these lines in my copy of the code to

case 0 then 
  -- more code 
case 1 then 
  -- more code 

to make it work.

In "Reverse Game" it's impossible to win because this line will never be true:

if equal(board, winner) then 

This is because of these two lines:

sequence winner = series(0, 1, SIZE - 1)  
-- more code 
board = series(1, 1, SIZE - 1)  

winner starts at 0 and will be something like {0,1,2,3,4} (depending on what SIZE is set to), whereas board starts at 1 and will look like {1,2,3,4,5} when sorted. So the test for equality will always return false and the game never ends.

Also in this code the string of help_message doesn't look right because it comments the rest of the code out. Besides, there is an unused %d in it where something like

-- more text 
"with a sequence of " & SIZE & " digits randomized. " 
-- more text 

would have been better in my opinion.

"Prompt the user for a string" (same page as "99 bottles") also gave me a bit of a headache because I couldn't make any sense of the "Errors resolving the following references" for CONSOLE and KEYBOARD that the interpreter threw. I couldn't find these names in the reference manual for v4.0.0, but found gets(0) for standard input instead (this worked perfectly). On the forum I found the topic "Euphoria 4.0 appears to problematic" that deals with this question (among others), so this resolved at least a little of my confusion (and perhaps the bugs I described here are just bugs because I'm using version 4). But I think it's hard for a newbie like me who hasn't used anything before version 4 to figure this out.

I apologize if all of this has been said before; I was just trying to be helpful :)

new topic     » topic index » view message » categorize

2. Re: Buggy sample codes?

I just cleaned these up. Let me know if there are still issues here (or anywhere else).

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu