Anonymous user
Rock-paper-scissors: Difference between revisions
no edit summary
No edit summary |
|||
Line 1,574:
rock
Computer picked paper, paper wins!</pre>
=={{header|Rascal}}==
<lang rascal>import Prelude;
rel[str, str] whatbeats = {<"Rock", "Sciccors">, <"Sciccors", "Paper">, <"Paper", "Rock">};
list[str] order = ["Rock", "Paper", "Sciccors"];
str CheckWinner(a, b){
if(b == getOneFrom(whatbeats[a]))
return a;
elseif(a == getOneFrom(whatbeats[b]))
return b;
else return "Nobody";
}
public str RPS(human){
computer = getOneFrom(order);
x = if(human=="Rock") "Paper"; elseif(human=="Paper") "Sciccors"; else "Rock";
order = order + x;
return "Computer played <computer>. <CheckWinner(human, computer)> wins!";
}</lang>
=={{header|Ruby}}==
|