Skip to content

Rename conept exercise dirs: closures and recursion #1237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion concepts/closures/.meta/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"blurb": "TODO: add blurb for closures concept",
"blurb": "JavaScript transparently supports closures, that means variables from an outer scope can also be used inside of a nested block of code.",
"authors": ["neenjaw"],
"contributors": ["SleeplessByte"]
}
24 changes: 15 additions & 9 deletions concepts/closures/about.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# About

The name **closure** is historically derived from [_λ-calculus_][wiki-lambda-calculus] and popularized by [_scheme_][wiki-scheme] ([source][wiki-closure]) to reference a function's open and closed variable bindings. There are various reasons to use **closures**, not limited to:
_Closures_ are a programming pattern in JavaScript which allows variables from an outer [lexical scope][wiki-lexical-scope] to be used inside of a nested block of code. JavaScript supports closures transparently, and they are often used without knowing what they are.

```javascript
// Top-level declarations are global-scope
const dozen = 12;

// Functions create a new function-scope and block-scope.
// Referencing the outer variable here is a closure.
function nDozen(n) {
return dozen * n;
}
```

The name _closure_ is historically derived from [_λ-calculus_][wiki-lambda-calculus] and popularized by [_scheme_][wiki-scheme] ([source][wiki-closure]) to reference a function's open and closed variable bindings.

## Reasons to use closures in JavaScript

Expand Down Expand Up @@ -101,14 +114,7 @@ function areaOfCircle(radius) {
}
```

## References

- [Whatthefork.is: A Closure][what-the-fork-is-a-closure]
- [Javascript.info: Variable Scope, Closures][javascript-info-scope-closure]
- [MDN web docs: Closures][mdn-closures]

[javascript-info-scope-closure]: https://javascript.info/closure
[mdn-closures]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures
[wiki-lexical-scope]: https://en.wikipedia.org/wiki/Scope_(computer_science)#Lexical_scoping
[what-the-fork-is-a-closure]: https://whatthefork.is/closure
[wiki-lambda-calculus]: https://en.wikipedia.org/wiki/%CE%9B-calculus
[wiki-scheme]: https://en.wikipedia.org/wiki/Scheme_(programming_language)
Expand Down
22 changes: 5 additions & 17 deletions concepts/closures/links.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
[
{
"url": "https://en.wikipedia.org/wiki/%CE%9B-calculus",
"description": "wiki-lambda-calculus"
"url": "https://javascript.info/closure",
"description": "javascript.info: Closure"
},
{
"url": "https://en.wikipedia.org/wiki/Scheme_(programming_language)",
"description": "wiki-scheme"
"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures",
"description": "MDN: Closures"
},
{
"url": "https://en.wikipedia.org/wiki/Closure_(computer_programming)",
"description": "wiki-closure"
},
{
"url": "https://web.archive.org/web/20210702195218if_/https://whatthefork.is/closure",
"description": "what-the-fork-is-a-closure"
},
{
"url": "https://javascript.info/closure",
"description": "javascript-info-scope-closure"
},
{
"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures",
"description": "mdn-closures"
"description": "Wikipedia: Closure"
}
]
2 changes: 1 addition & 1 deletion concepts/recursion/.meta/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"blurb": "TODO: add blurb for recursion concept",
"blurb": "Recursive functions are functions that call themselves.",
"authors": ["SleeplessByte"],
"contributors": []
}
14 changes: 7 additions & 7 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,24 +131,24 @@
"status": "beta"
},
{
"slug": "recursion",
"slug": "pizza-order",
"name": "Pizza Order",
"uuid": "e9a9fa73-4497-43d5-a4ff-4eb319c98233",
"concepts": ["recursion"],
"prerequisites": [
"arrays",
"functions",
"rest-and-spread",
"array-destructuring",
"array-loops",
"numbers"
"array-transformation"
],
"status": "beta"
"status": "wip"
},
{
"slug": "closures",
"slug": "coordinate-transformation",
"name": "Coordinate Transformation",
"uuid": "5aa39e89-c601-4a66-ab72-5d8512d69e02",
"concepts": ["closures"],
"prerequisites": ["arrays", "booleans"],
"prerequisites": ["arrays", "functions"],
"status": "beta"
},
{
Expand Down
11 changes: 0 additions & 11 deletions exercises/concept/closures/.meta/config.json

This file was deleted.

118 changes: 0 additions & 118 deletions exercises/concept/closures/closures.spec.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
## General

- For each task, each function should return a function closure, using the supplied arguments.
- Read [Whatthefork.is: A Closure][what-the-fork-is-a-closure]
- Read [Javascript.info: Variable Scope, Closures][javascript-info-scope-closure]
- Read [MDN web docs: Closures][mdn-closures]

## 1. Translate the coordinates

Expand All @@ -24,7 +21,3 @@

- For this function, you only have to memoize the result of the last transformation.
- In order to send back the result of the last transformation, you will have to check if the input arguments are the same.

[javascript-info-scope-closure]: https://javascript.info/closure
[mdn-closures]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures
[what-the-fork-is-a-closure]: https://web.archive.org/web/20210702195218if_/https://whatthefork.is/closure
11 changes: 11 additions & 0 deletions exercises/concept/coordinate-transformation/.meta/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"blurb": "Practice your knowledge of closures by implementing various coordinate transformations.",
"authors": ["neenjaw"],
"contributors": ["SleeplessByte"],
"files": {
"solution": ["coordinate-transformation.js"],
"test": ["coordinate-transformation.spec.js"],
"exemplar": [".meta/exemplar.js"]
},
"forked_from": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@ In other words: how _values_ can be _enclosed_ in a _function_. It touches onto

## Prerequisites

- `basics`
- `booleans`
- `arrays`
- `functions`
Loading