Created
December 14, 2025 21:29
-
-
Save davidystephenson/bd618d5602bf5da33a0afe7243c4d563 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
| let diamonds: number = 10 | |
| function dig (getDug: (remaining: number) => number) { | |
| let dug = getDug(diamonds) | |
| diamonds -= dug | |
| return dug | |
| } | |
| function getOne () { | |
| return 1 | |
| } | |
| function getHalf (remaining: number) { | |
| return remaining / 2 | |
| } | |
| dig(getOne) | |
| const dug = dig(getHalf) | |
| console.log('dug', dug) | |
| console.log('remaining', diamonds) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment