diff options
Diffstat (limited to 'lab3/src/main/scala/jsy/lab3/Lab3.worksheet.js')
-rw-r--r-- | lab3/src/main/scala/jsy/lab3/Lab3.worksheet.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lab3/src/main/scala/jsy/lab3/Lab3.worksheet.js b/lab3/src/main/scala/jsy/lab3/Lab3.worksheet.js new file mode 100644 index 0000000..8d4d9ce --- /dev/null +++ b/lab3/src/main/scala/jsy/lab3/Lab3.worksheet.js @@ -0,0 +1,24 @@ +/* + * CSCI 3155: Lab 3 JavaScript Worksheet + * + * This worksheet is a place to experiment with JavaScript expressions. + */ + +// The new language feature in Lab 3 is first-class functions. + +const id = function (x) { + return x; +}; + +const plus = (x) => (y) => x + y; + +const j = plus(3)(4); + +id("Hello, ") + j; + +const factorial = function f(n) { + return n === 0 ? 1 : n * f(n - 1); +}; + +const factorial3 = factorial(3); +factorial3; |