Skip to content

Instantly share code, notes, and snippets.

@alice
Forked from gulnara/gist:5384900
Last active December 16, 2015 06:39
Show Gist options
  • Save alice/5392920 to your computer and use it in GitHub Desktop.
Save alice/5392920 to your computer and use it in GitHub Desktop.
My comments start with // to distinguish from gulnara's.
#assignment is done via <-, equality is id with only one =
// Nice!
prompt <- '>'
#printing is done via show
show 'What's your name?'
#the input from user is taken via user_input = raw_input in python
// What does |using| do here? I'm guessing it starts the argument list?
name <- user_input using prompt
#any variable that is referenced in the string will be referenced via %var and outside the string it will be rerenced via % and the name of the variable
// This comment is out of date, although I think you improved on your original semantics. My one question would be, does it join the arguments to "show" with spaces? If so, you should be explicit about that.
// Also, I assume you're adopting the Python convention of having |print| be a statement, rather than a function, since this doesn't use |using|. http://docs.python.org/2/reference/simple_stmts.html#print
show 'Hello' name
show 'Let's play a game! Pick any number between 1 and 20.'
# randomize is a method - haven't figured out how to implement yet
// http://docs.python.org/2/library/random.html#random.randint ?
i <- randomize using 1 to 20
#loops have names and in order to break out of a loop you use stop + the name of then loop
# the insides of the loop have to be indented
loop guessing:
stratting with // Does this need a : to start an indented block as well?
initial guess <- 0
end
guess <- guess + 1
// What does |via| do?
// I assume |number_input| is syntactic sugar for parsing a number from |user_input| - what happens if someone types in (for example) "xyzzy"?
number <- number_input via prompt
#conditinal statements are defined via ?, then, default:
is number < i ?
then show 'The number is too low. Try again.'
or is number > i ?
then show 'The number is too high. Try again.'
otherwise // Again, do these blocks need to be started with : ?
show 'You guessed it! Great job' name 'You found my number in' guess 'tries.'
stop guessing
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment