Created
December 14, 2025 22:00
-
-
Save davidystephenson/1f139bbb6f78674d6bed788d921e4080 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function openMine () { | |
| let diamonds = 21 | |
| function dig (getDug: (remaining: number) => number) { | |
| const dug = getDug(diamonds) | |
| diamonds -= dug | |
| console.log('diamonds', diamonds) | |
| return dug | |
| } | |
| return dig | |
| } | |
| const digNorth = openMine() | |
| const digSouth = openMine() | |
| function getOne () { | |
| return 1 | |
| } | |
| function getTwo () { | |
| return 2 | |
| } | |
| function getHalf (remaining: number) { | |
| return remaining / 2 | |
| } | |
| digNorth(getOne) // diamonds 20 | |
| digSouth(getTwo) // diamonds 19 | |
| const dugNorth = digNorth(getHalf) | |
| const dugSouth = digSouth(getHalf) | |
| console.log('dugNorth', dugNorth) | |
| console.log('dugSouth', dugSouth) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment