Skip to content

Commit

Permalink
Fixed some code snippets in the tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
Raynes committed May 30, 2010
1 parent 33bf554 commit acd6c8c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion project.clj
Expand Up @@ -5,7 +5,7 @@
[net.cgrand/moustache "1.0.0-SNAPSHOT"] [net.cgrand/moustache "1.0.0-SNAPSHOT"]
[ring/ring-jetty-adapter "0.2.0"] [ring/ring-jetty-adapter "0.2.0"]
[commons-lang/commons-lang "2.5"] [commons-lang/commons-lang "2.5"]
[clj-sandbox "0.3.7"] [clj-sandbox "0.3.8"]
[clj-highlight "0.1.1-SNAPSHOT"] [clj-highlight "0.1.1-SNAPSHOT"]
[hiccup "0.2.3"] [hiccup "0.2.3"]
[clj-gist "1.0.0-SNAPSHOT"]] [clj-gist "1.0.0-SNAPSHOT"]]
Expand Down
12 changes: 9 additions & 3 deletions src/tryclojure/tutorial.clj
Expand Up @@ -74,7 +74,10 @@
"Alright. We have greeted the world. Now what? Math? Clojure is great at math. Thanks to the uniformity of " "Alright. We have greeted the world. Now what? Math? Clojure is great at math. Thanks to the uniformity of "
"prefix notation, we don't have to worry about precedence rules; which we kinda loathe anyway. This goes before that, and that goes before that other thing... blah! In Clojure, mathematical operators work like any other function." "prefix notation, we don't have to worry about precedence rules; which we kinda loathe anyway. This goes before that, and that goes before that other thing... blah! In Clojure, mathematical operators work like any other function."
" The common operators are +, -, *, and /. Let's try them out: "] " The common operators are +, -, *, and /. Let's try them out: "]
(code "(+ 2 2)\n(- 3 2)\n(* 5 5)\n(/ 4 3)") (code "(+ 2 2)\n")
(code "(- 3 2)\n")
(code "(* 5 5)\n")
(code "(/ 4 3)\n")
[:p.bottom [:p.bottom
"So, that was great. But that last one doesn't quite look right. The problem is that Clojure has a built in " "So, that was great. But that last one doesn't quite look right. The problem is that Clojure has a built in "
"Ratio type. You can confirm this by doing this: " (code "(class (/ 4 3))") "."] "Ratio type. You can confirm this by doing this: " (code "(class (/ 4 3))") "."]
Expand Down Expand Up @@ -147,7 +150,9 @@
"Another important fact about sets is that they, like maps, are also functions. A set is a function that takes " "Another important fact about sets is that they, like maps, are also functions. A set is a function that takes "
"an argument and looks inside itself to see if that same object is inside of it. If this is true, it returns the " "an argument and looks inside itself to see if that same object is inside of it. If this is true, it returns the "
"object, or returns nil. Let's try this out for ourselves: "] "object, or returns nil. Let's try this out for ourselves: "]
(code "(#{1 2 3} 3)\n(#{\"abc\" \\e} \\e)\n(#{3 4 \\x} 5)") (code "(#{1 2 3} 3)\n")
(code "(#{\"abc\" \\e} \\e)\n")
(code "(#{3 4 \\x} 5)")
[:p.bottom [:p.bottom
"Okay, so how is this useful? It really isn't. Not alone, anyway. However, when it's combined with other sequence " "Okay, so how is this useful? It really isn't. Not alone, anyway. However, when it's combined with other sequence "
"functions, it can be used to make a really elegant solution to a problem like this."] "functions, it can be used to make a really elegant solution to a problem like this."]
Expand All @@ -166,7 +171,8 @@
"Let's try filter out a bit. Let's try to filter out all odd numbers from a sequence of numbers. Clojure has " "Let's try filter out a bit. Let's try to filter out all odd numbers from a sequence of numbers. Clojure has "
"a function called " (code "odd?") " that we can use. Putting a question mark at the end is a Clojure naming convention " "a function called " (code "odd?") " that we can use. Putting a question mark at the end is a Clojure naming convention "
"for functions that are predicates (return either true or false). Try it out in the REPL:"] "for functions that are predicates (return either true or false). Try it out in the REPL:"]
(code "(odd? 1)\n(odd? 2)") (code "(odd? 1)\n")
(code "(odd? 2)")
[:p.bottom [:p.bottom
"Okay, now we need a sequence of numbers. We could type these out by hand, but that's tedious, and as Clojure " "Okay, now we need a sequence of numbers. We could type these out by hand, but that's tedious, and as Clojure "
"programmers, we do not tolerate 'tedious'. We can use Clojure's range function to generate these numbers for us. " "programmers, we do not tolerate 'tedious'. We can use Clojure's range function to generate these numbers for us. "
Expand Down

0 comments on commit acd6c8c

Please sign in to comment.