Created
July 1, 2010 11:26
-
-
Save jeena/459846 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/lua | |
secretword = "llama" -- the secret word | |
write ("What is your name? ") | |
name = read ("*l") | |
if name == "Randal" then | |
print ("Hello, Randal! How good of you to be here!") | |
else | |
print ("Hello " .. name .. "!") -- ordinary greeting | |
write ("What is the secret word? ") | |
guess = read ("*l") | |
while guess ~= secretword do | |
write ("Wrong, try again. What is the secret word? ") | |
guess = read ("*l") | |
end | |
end | |
#!/usr/bin/env ruby -wKU | |
secretword = Regexp.new "llama" # the secret word | |
print("What is your name? ") | |
name = gets | |
if name == "Randal" then | |
print("Hello, Randal! How good of you to be here!") | |
else | |
puts("Hello " + name.strip + "!") # ordinary greeting | |
print("What is the secret word? ") | |
guess = gets | |
while not guess =~ secretword do | |
puts("Wrong, try again. What is the secret word? ") | |
guess = gets | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment