Created
January 14, 2026 13:46
-
-
Save Steven24K/fa28d8da224f49ad86ec4c3022b96086 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
| # Higher order function and recursive combined. | |
| count = lambda x, counter, func: counter == x if counter else count(x, func(counter), func) | |
| # some variations using the above function | |
| increment = lambda x: x + 1 | |
| increment_by_two = lambda x: x + 2 | |
| double = lambda x: x * 2 | |
| decrement_by_x = lambda x: lambda y: x - y | |
| decrement = lambda x: decrement_by_x(x)(1) | |
| decrement_by_two = lambda x: decrement_by_x(x)(2) | |
| count_to = lambda to, counter: count(to, counter, increment) | |
| count_double = lambda to, counter: count(to, counter, increment_by_two) | |
| multiply = lambda to, counter: count(to, counter, double) | |
| count_down = lambda min, counter: count(min, counter, decrement) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment