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
> A function is said to be pure if the return value is only determined by its
80
-
input values, without any side effects.
95
+
input values, without any side effects and mutations.
81
96
82
97
```js
83
98
let greet ="yo";
@@ -157,6 +172,37 @@ Points-free function definitions look just like normal assignments without `func
157
172
158
173
---
159
174
175
+
## Value
176
+
177
+
> Any complex or primitive value that is used in the computation, including functions. Values in functional programming are assumed to be immutable.
178
+
179
+
```js
180
+
5
181
+
Object.freeze({name:'John', age:30}) // The `freeze` function enforces immutability.
182
+
(a) => a
183
+
```
184
+
Note that the value-containing structures defined below such as [Functor](#functor), [Monad](#monad) etc. are themselves values. This means, among other things, that they can be nested within each other.
185
+
186
+
---
187
+
188
+
## Constant
189
+
190
+
> An immutable reference to a value. Not to be confused with `Variable` - a reference to a value which can at any point be updated to point to a different value.
191
+
```js
192
+
constfive=5
193
+
constjohn= {name:'John', age:30}
194
+
```
195
+
Constants are referentially transparent. That is, they can be replaced with the values that they represent without affecting the result.
196
+
In other words with the above two constants the expression:
197
+
198
+
```js
199
+
john.age+ five === ({name:'John', age:30}).age+ (5)
200
+
201
+
```
202
+
Should always return `true`.
203
+
204
+
---
205
+
160
206
## Functor
161
207
162
208
> An object with a `map` function that adhere to certains rules. `Map` runs a function on values in an object and returns a new object.
@@ -296,6 +342,8 @@ The identity value is empty array `[]`
296
342
```js
297
343
[1, 2].concat([]); // [1, 2]
298
344
```
345
+
Functions also form a monoid with the normal functional compositon as an operation and the function which returns its input `(a) => a`
0 commit comments