Dashes! Dashes everywhere! ... in the tutorial
The tutorial used underscores in Hy code everywhere. Updated all examples to use dashes, as per Hy convention.
This commit is contained in:
parent
d98e4fd733
commit
6ec89af988
@ -144,8 +144,8 @@ Now let's look at the equivalent Hy program:
|
||||
|
||||
(defn simple-conversation []
|
||||
(print "Hello! I'd like to get to know you. Tell me about yourself!")
|
||||
(setv name (raw_input "What is your name? "))
|
||||
(setv age (raw_input "What is your age? "))
|
||||
(setv name (raw-input "What is your name? "))
|
||||
(setv age (raw-input "What is your age? "))
|
||||
(print (+ "Hello " name "! I see you are "
|
||||
age " years old.")))
|
||||
|
||||
@ -390,13 +390,13 @@ In Python we might see::
|
||||
|
||||
The same thing in Hy::
|
||||
|
||||
=> (defn optional_arg [pos1 pos2 &optional keyword1 [keyword2 42]]
|
||||
=> (defn optional-arg [pos1 pos2 &optional keyword1 [keyword2 42]]
|
||||
... [pos1 pos2 keyword1 keyword2])
|
||||
=> (optional_arg 1 2)
|
||||
=> (optional-arg 1 2)
|
||||
[1 2 None 42]
|
||||
=> (optional_arg 1 2 3 4)
|
||||
=> (optional-arg 1 2 3 4)
|
||||
[1 2 3 4]
|
||||
=> (optional_arg :keyword1 1
|
||||
=> (optional-arg :keyword1 1
|
||||
... :pos2 2
|
||||
... :pos1 3
|
||||
... :keyword2 4)
|
||||
@ -414,7 +414,7 @@ We can reproduce this with "apply"::
|
||||
=> (setv args [1 2])
|
||||
=> (setv kwargs {"keyword2" 3
|
||||
... "keyword1" 4})
|
||||
=> (apply optional_arg args kwargs)
|
||||
=> (apply optional-arg args kwargs)
|
||||
[1, 2, 4, 3]
|
||||
|
||||
There's also a dictionary-style keyword arguments construction that
|
||||
@ -422,7 +422,7 @@ looks like:
|
||||
|
||||
.. code-block:: clj
|
||||
|
||||
(defn another_style [&key {"key1" "val1" "key2" "val2"}]
|
||||
(defn another-style [&key {"key1" "val1" "key2" "val2"}]
|
||||
[key1 key2])
|
||||
|
||||
The difference here is that since it's a dictionary, you can't rely on
|
||||
@ -438,7 +438,7 @@ The Hy equivalent:
|
||||
|
||||
.. code-block:: clj
|
||||
|
||||
(defn some_func [foo bar &rest args &kwargs kwargs]
|
||||
(defn some-func [foo bar &rest args &kwargs kwargs]
|
||||
(import pprint)
|
||||
(pprint.pprint (, foo bar args kwargs)))
|
||||
|
||||
@ -490,7 +490,7 @@ In Hy:
|
||||
.. code-block:: clj
|
||||
|
||||
(defclass Customer [models.Model]
|
||||
[[name (models.CharField :max_length 255})]
|
||||
[[name (models.CharField :max-length 255})]
|
||||
[address (models.TextField)]
|
||||
[notes (models.TextField)]])
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user