|
1 // Copyright 2009 the Sputnik authors. All rights reserved. |
|
2 // This code is governed by the BSD license found in the LICENSE file. |
|
3 |
|
4 /** |
|
5 * Closures are admitted |
|
6 * |
|
7 * @path ch13/13.0/S13_A18.js |
|
8 * @description Using a function declaration as a function parameter |
|
9 */ |
|
10 |
|
11 ////////////////////////////////////////////////////////////////////////////// |
|
12 //CHECK#1 |
|
13 if (typeof sinx !== 'undefined') { |
|
14 $ERROR('#1: typeof sinx === \'undefined\'. Actual: typeof sinx ==='+typeof sinx); |
|
15 } |
|
16 // |
|
17 ////////////////////////////////////////////////////////////////////////////// |
|
18 |
|
19 var __val = function derivative(f, dx) { |
|
20 return function(x) { |
|
21 return (f(x + dx) - f(x)) / dx; |
|
22 }; |
|
23 }(function sinx(x){return Math.sin(x);},.0001)(0.5); |
|
24 |
|
25 ////////////////////////////////////////////////////////////////////////////// |
|
26 //CHECK#2 |
|
27 if (typeof sinx !== 'undefined') { |
|
28 $ERROR('#2: typeof sinx === \'undefined\'. Actual: typeof sinx ==='+typeof sinx); |
|
29 } |
|
30 // |
|
31 ////////////////////////////////////////////////////////////////////////////// |
|
32 |