resolve.md (1028B)
1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. --> 2 3 # Function resolve 4 5 resolve(expr, scope) replaces variable nodes with their scoped values 6 7 8 ## Syntax 9 10 ```js 11 resolve(expr, scope) 12 ``` 13 14 ### Parameters 15 16 Parameter | Type | Description 17 --------- | ---- | ----------- 18 `node` | Node | The expression tree to be simplified 19 `scope` | Object | Scope specifying variables to be resolved 20 21 ### Returns 22 23 Type | Description 24 ---- | ----------- 25 Node | Returns `node` with variables recursively substituted. 26 27 28 ### Throws 29 30 Type | Description 31 ---- | ----------- 32 ReferenceError | If there is a cyclic dependency among the variables in `scope`, resolution is impossible and a ReferenceError is thrown. 33 34 ## Examples 35 36 ```js 37 math.resolve('x + y', {x:1, y:2}) // Node {1 + 2} 38 math.resolve(math.parse('x+y'), {x:1, y:2}) // Node {1 + 2} 39 math.simplify('x+y', {x:2, y:'x+x'}).toString() // "6" 40 ``` 41 42 43 ## See also 44 45 [simplify](simplify.md), 46 [evaluate](evaluate.md)