You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/clojurescript.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@
7
7
>
8
8
> It is not yet completely polished, but it is getting close. It does not yet have an integrated inline/on-page REPL yet. But it will soon. <br>
9
9
>
10
-
> Please open an issue with your thoughts [at the re-freame repo](https://github.com/day8/re-frame/) or via twitter [here](https://twitter.com/wazound)
10
+
> Please open an issue with your thoughts [at the re-frame repo](https://github.com/day8/re-frame/) or via twitter [here](https://twitter.com/wazound)
11
11
>
12
12
> Many Thanks!
13
13
@@ -23,7 +23,7 @@ Clojure is a modern LISP.
23
23
24
24
Alan Kay once described LISP as "Maxwell's equations of software".
25
25
Paul Graham believes LISP was a competitive advantage for his startup.
26
-
Eric Raymmond said that learning LISP was profoundly enligtening and that knowing it would make you a better programmer for the rest of your days.
26
+
Eric Raymond said that learning LISP was profoundly enlightening and that knowing it would make you a better programmer for the rest of your days.
27
27
28
28
In the 70s, 80s and 90s, the LISP community went through a washing machine phase of evolutionary churn.
29
29
Innovation flourished, experiments happened, prototype ideas were tested and knowledge foliated.
@@ -255,7 +255,7 @@ Example list evaluations, involving symbols:
|`(inc 3)`|`4`| Step 1: evaluate each element of the list (there are two):<br> • the symbol `inc` is bound to a builtin function<br> • and `3` evaluates to `3`<br>Step 2: call the function with `3` as the argument.<br>The return value `4`|
257
257
|`[5 (inc 6)]`|`[5 7]`| Evaluate each element of the vector. `5` evaluates to `5`.<br>Then, evaluating that 2nd element is a function call. |
258
-
|`(+ 1 2)`|`3`| The symbol `+` is bound to a builin function.<br>And that function adds together its arguments |
258
+
|`(+ 1 2)`|`3`| The symbol `+` is bound to a builtin function.<br>And that function adds together its arguments |
259
259
|`(+ 1 2 3)`|`6`| Surprise! Turns out this function can handle a variable<br>number of arguments. |
260
260
|`[1 (+ 1 2 3)]`|`[1 6]`||
261
261
@@ -293,7 +293,7 @@ Well, in your mind's eye, see this nested example as `(f arg1 arg2)` where:
293
293
-`arg1` is `1`
294
294
-`arg2` is `(inc 10)` <-- a nested form
295
295
296
-
To evaluate this form, you'll remember from the last section that it is a twostep process. First, evaluate each of the three elements. So the execution trace will be:
296
+
To evaluate this form, you'll remember from the last section that it is a two-step process. First, evaluate each of the three elements. So the execution trace will be:
297
297
298
298
-`+` will evaluate to the builtin function bound to that symbol
|`(+ 3 (count [1 2]))`|`5`| Evaluation trace:<br> • `+` is evaluated to a function<br> • `3` is evaluated to `3`<br> • `(count [1 2])` is evaluated as a function call which returns `2`<br> • call function with args `3` and `2`, which returns `5`|
310
310
|`(= 2 (inc 1))`|`true`|`=` is a symbol which is bound to a builtin function.<br>You can guess what it does. |
311
-
|`(= (inc 1) (dec 3))`|`true`|`dec` is bound to a bultin, and it decrements its arg by one |
311
+
|`(= (inc 1) (dec 3))`|`true`|`dec` is bound to a builtin, and it decrements its arg by one |
312
312
313
313
314
314
Evaluate these experiments yourself (any surprises?):
@@ -570,7 +570,7 @@ Consider these two:
570
570
571
571
Now, consider what is happening here:
572
572
```clj
573
-
(defmy-inc (fn [a] (+ a 1))
573
+
(defmy-inc (fn [a] (+ a 1)))
574
574
```
575
575
That `fn` form will create a function, and then the `def` will bind it to the symbol `my-inc`. Two steps. Hey, we've just created our own `inc`.
576
576
```clj
@@ -635,7 +635,7 @@ Define another:
635
635
```clj
636
636
(defngreet
637
637
[username]
638
-
(str"Hello " username)))
638
+
(str"Hello " username))
639
639
```
640
640
`str` is a builtin function which turns each of its arguments into a string and concatenates them.
In this particular, we could have got away with no using a `let`, like this:
708
+
In this particular, we could have got away with not using a `let`, like this:
709
709
```clj
710
710
(defngreet
711
711
[name friendly?]
712
-
[:div (if friendly? "Hello ""Go away ") name)
712
+
[:div (if friendly? "Hello ""Go away ") name])
713
713
```
714
714
715
715
```clj
@@ -872,7 +872,7 @@ XXX Live coding here.
872
872
873
873
## `reduce`
874
874
875
-
In the functional world, `reduce` is part 600 pound gorilla, part swiss arm knife.
875
+
In the functional world, `reduce` is part 600 pound gorilla, part swiss army knife.
876
876
877
877
It takes three arguments:
878
878
@@ -988,7 +988,7 @@ Deeply nested forms, like this, are often rewritten using the `thread first` mac
988
988
```clj
989
989
(-> (+01) ; (+ 0 1)
990
990
(+2) ; (+ (+ 0 1) 2)
991
-
(+4))); (+ (+ (+ 0 1) 2) 4)
991
+
(+4)) ; (+ (+ (+ 0 1) 2) 4)
992
992
```
993
993
`->` is a symbol and it is the first element in a form `(-> ...)`.
994
994
So, this is a function call and the symbol `->` is bound to the function to be called, a bit
@@ -1031,7 +1031,7 @@ Work out the evaluation of:
1031
1031
:aa) ;; same as (:aa)
1032
1032
```
1033
1033
1034
-
`->` belongs to a small family of marcos. Another one is the `thread last` macro `->>`. It operates the same way except it threads the value as the argument in the last position, not the first.
1034
+
`->` belongs to a small family of macros. Another one is the `thread last` macro `->>`. It operates the same way except it threads the value as the argument in the last position, not the first.
1035
1035
1036
1036
## Thread Last Macro `->>`
1037
1037
@@ -1089,7 +1089,7 @@ you'll see a vector of three values ` [{:doors 2} {:doors 2, :seats 4} {:doors
1089
1089
1090
1090
Notice how `car1` is unchanged, even though we did an `assoc` into `car1` . Same with XXXXXXXXX
1091
1091
1092
-
When you are used to imperative, in-place modification of data, it can initially be mysterfying as to how you can achieve anything. Rest assured, you can.
1092
+
When you are used to imperative, in-place modification of data, it can initially be mystifying as to how you can achieve anything. Rest assured, you can.
0 commit comments