User:Owittnan/sandbox/A Little Hy Primer

Welcome to A Little Hy Primer. Much like A Little C Primer, this is a novice introduction to the Hy programming language. This text will assume some familiarity with Python and at least a basic level of familiarity with a Lisp.

Installation
To install Hy, you first need Python and Pip installed. There are many guides online about how to do this.

Once you have Python and Pip installed, run. This will install hy from the PyPI package repository.

You can also use the online interpreter.

With that, let's get started.

Hello world
The first program you run in any programming language is the "Hello world" program. So let's do just that. Open up a file and type this in: Make sure to save the file with the .hy extension (not needed in the interpreter). If using the interpreter, click the Run button in the top right of the editor. If not, open a console in the same directory as your .hy file and run, replacing   with the name of the .hy file.

You should see  printed in the console/output box.

Basic operations
Hy can do arithmetic operations. It uses the prefix notation: It also has the standard if conditional operator, but with a more lispy syntax: The above is the same as if-else in Python. To have elifs you use the cond macro: and to execute more than one statement in an if you need a do-block: There are also macros for if you only want the true or false statement: