From d10d9e79f96f0c32134459dbd19ad3a015536581 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Mon, 1 Apr 2013 10:58:13 -0500 Subject: [PATCH] Move the comment section, explain for loops --- docs/language/index.rst | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/language/index.rst b/docs/language/index.rst index f8be172..5b903c6 100644 --- a/docs/language/index.rst +++ b/docs/language/index.rst @@ -252,6 +252,23 @@ You can see that we used "do" to wrap multiple statments. If you're familiar with other lisps, this is the equivalent of "progn" elsewhere. +Comments start with semicolons:: + + (print "this will run") + ; (print "but this will not") + (+ 1 2 3) ; we'll execute the addition, but not this comment! + +Looping is not hard but has a kind of special structure. In python, +we might do:: + + for i in range(10): + print "'i' is now at " + str(i) + +The equivalent in hy would be:: + + (for [i (range 10)] + (print (+ "'i' is now at " (str i)))) + You can also import and make use of various python libraries. For example:: @@ -261,11 +278,6 @@ example:: (os.mkdir "/tmp/somedir/anotherdir") (print "Hey, that path isn't there!")) -Comments start with semicolons:: - - (print "this will run") - ; (print "but this will not") - (+ 1 2 3) ; we'll execute the addition, but not this comment! TODO