Skip to content

Instantly share code, notes, and snippets.

@LeeeeT
Last active February 7, 2024 22:52
Show Gist options
  • Save LeeeeT/52f06d36fa197b92245b8bc1810b2d11 to your computer and use it in GitHub Desktop.
Save LeeeeT/52f06d36fa197b92245b8bc1810b2d11 to your computer and use it in GitHub Desktop.
Lambdas ain't too much
from functools import cache
from sys import setrecursionlimit
setrecursionlimit(10000)
(lambda: lambda define:
lambda: define()(lambda: lambda value: lambda: lambda function:
lambda: value()
)()(lambda: lambda constant:
lambda: define()(lambda: lambda first: lambda: lambda second: lambda: lambda value:
lambda: second()(lambda: first()(lambda: value())())()
)()(lambda: lambda compose:
lambda: define()(lambda: lambda function:
lambda: function()(lambda: function())()
)()(lambda: lambda self_referential:
lambda: define()(lambda: lambda function:
lambda: self_referential()(lambda: lambda self: lambda: function()(lambda: self()(lambda: self())())())()
)()(lambda: lambda recursive:
lambda: define()(lambda: lambda true: lambda: lambda false:
lambda: true()
)()(lambda: lambda true:
lambda: define()(lambda: lambda true: lambda: lambda false:
lambda: false()
)()(lambda: lambda false:
lambda: define()(lambda: lambda bool: lambda: lambda true: lambda: lambda false:
lambda: bool()(lambda: false())()(lambda: true())()
)()(lambda: lambda negate:
lambda: define()(lambda: lambda first: lambda: lambda second:
lambda: first()(lambda: second())()(lambda: false())()
)()(lambda: lambda both:
lambda: define()(lambda: lambda zero: lambda: lambda successor:
lambda: zero()
)()(lambda: lambda zero:
lambda: define()(lambda: lambda number: lambda: lambda zero: lambda: lambda successor:
lambda: successor()(lambda: number())()
)()(lambda: lambda successor:
lambda: define()(
lambda: successor()(lambda: zero())()
)()(lambda: lambda one:
lambda: define()(
lambda: successor()(lambda: one())()
)()(lambda: lambda two:
lambda: define()(
lambda: successor()(lambda: two())()
)()(lambda: lambda three:
lambda: define()(
lambda: successor()(lambda: three())()
)()(lambda: lambda four:
lambda: define()(
lambda: successor()(lambda: four())()
)()(lambda: lambda five:
lambda: define()(
lambda: successor()(lambda: five())()
)()(lambda: lambda six:
lambda: define()(
lambda: successor()(lambda: six())()
)()(lambda: lambda seven:
lambda: define()(
lambda: successor()(lambda: seven())()
)()(lambda: lambda eight:
lambda: define()(
lambda: successor()(lambda: eight())()
)()(lambda: lambda nine:
lambda: define()(
lambda: successor()(lambda: nine())()
)()(lambda: lambda ten:
lambda: define()(lambda: recursive()(lambda: lambda fold_number: lambda: lambda function: lambda: lambda value: lambda: lambda number:
lambda: number()(lambda: value())()(lambda: lambda number: lambda: function()(lambda: fold_number()(lambda: function())()(lambda: value())()(lambda: number())())())()
)())()(lambda: lambda fold_number:
lambda: define()(lambda: lambda number:
lambda: number()(lambda: true())()(lambda: constant()(lambda: false())())()
)()(lambda: lambda is_zero:
lambda: define()(lambda: recursive()(lambda: lambda add: lambda: lambda addend: lambda: lambda augend:
lambda: augend()(lambda: addend())()(lambda: lambda number: lambda: successor()(lambda: add()(lambda: addend())()(lambda: number())())())()
)())()(lambda: lambda add:
lambda: define()(lambda: recursive()(lambda: lambda subtract: lambda: lambda subtrahend: lambda: lambda minuend:
lambda: subtrahend()(lambda: minuend())()(lambda: lambda subtrahend_predessor: lambda: minuend()(lambda: zero())()(lambda: lambda minuend_predessor: lambda: subtract()(lambda: subtrahend_predessor())()(lambda: minuend_predessor())())())()
)())()(lambda: lambda subtract:
lambda: define()(lambda: lambda first: lambda: lambda second:
lambda: both()(lambda: is_zero()(lambda: subtract()(lambda: first())()(lambda: second())())())()(lambda: is_zero()(lambda: subtract()(lambda: second())()(lambda: first())())())()
)()(lambda: lambda equal:
lambda: define()(lambda: lambda second: lambda: lambda first:
lambda: is_zero()(lambda: subtract()(lambda: second())()(lambda: first())())()
)()(lambda: lambda less_or_equal:
lambda: define()(lambda: lambda second: lambda: lambda first:
lambda: is_zero()(lambda: subtract()(lambda: first())()(lambda: second())())()
)()(lambda: lambda greater_or_equal:
lambda: define()(lambda: recursive()(lambda: lambda multiply: lambda: lambda multiplier: lambda: lambda multiplicand:
lambda: multiplier()(lambda: zero())()(lambda: lambda number: lambda: add()(lambda: multiplicand())()(lambda: multiply()(lambda: number())()(lambda: multiplicand())())())()
)())()(lambda: lambda multiply:
lambda: define()(lambda: recursive()(lambda: lambda divide: lambda: lambda divisor: lambda: lambda divident:
lambda: greater_or_equal()(lambda: divisor())()(lambda: divident())()(lambda: successor()(lambda: divide()(lambda: divisor())()(lambda: subtract()(lambda: divisor())()(lambda: divident())())())())()(lambda: zero())()
)())()(lambda: lambda divide:
lambda: define()(lambda: lambda divisor: lambda: lambda divident:
lambda: subtract()(lambda: multiply()(lambda: divident())()(lambda: divide()(lambda: divisor())()(lambda: divident())())())()(lambda: divident())()
)()(lambda: lambda remainder:
lambda: define()(lambda: lambda divisor: lambda: lambda divident:
lambda: is_zero()(lambda: remainder()(lambda: divisor())()(lambda: divident())())()
)()(lambda: lambda multiple:
lambda: define()(lambda: lambda first: lambda: lambda second: lambda: lambda function:
lambda: function()(lambda: first())()(lambda: second())()
)()(lambda: lambda pair:
lambda: define()(lambda: lambda pair:
lambda: pair()(lambda: lambda first: lambda: lambda second: lambda: first())()
)()(lambda: lambda first:
lambda: define()(lambda: lambda pair:
lambda: pair()(lambda: lambda first: lambda: lambda second: lambda: second())()
)()(lambda: lambda second:
lambda: define()(lambda: lambda empty: lambda: lambda continuation:
lambda: empty()
)()(lambda: lambda empty_list:
lambda: define()(lambda: lambda list:
lambda: list()(lambda: true())()(lambda: constant()(lambda: constant()(lambda: false())())())()
)()(lambda: lambda is_empty:
lambda: define()(lambda: lambda head: lambda: lambda tail: lambda: lambda empty: lambda: lambda continuation:
lambda: continuation()(lambda: head())()(lambda: tail())()
)()(lambda: lambda list_continuation:
lambda: define()(lambda: lambda item: lambda: lambda list:
lambda: is_empty()(lambda: list())()(lambda: list_continuation()(lambda: item())()(lambda: empty_list())())()(lambda: list_continuation()(lambda: item())()(lambda: list())())()
)()(lambda: lambda prepend:
lambda: define()(lambda: recursive()(lambda: lambda append: lambda: lambda item: lambda: lambda list:
lambda: list()(lambda: list_continuation()(lambda: item())()(lambda: empty_list())())()(lambda: lambda head: lambda: lambda tail: lambda: list_continuation()(lambda: head())()(lambda: append()(lambda: item())()(lambda: tail())())())()
)())()(lambda: lambda append:
lambda: define()(lambda: recursive()(lambda: lambda reverse: lambda: lambda list:
lambda: list()(lambda: empty_list())()(lambda: lambda head: lambda: lambda tail: lambda: append()(lambda: head())()(lambda: reverse()(lambda: tail())())())()
)())()(lambda: lambda reverse:
lambda: define()(lambda: recursive()(lambda: lambda fold_list_left: lambda: lambda function: lambda: lambda value: lambda: lambda list:
lambda: list()(lambda: value())()(lambda: lambda head: lambda: lambda tail: lambda: fold_list_left()(lambda: function())()(lambda: function()(lambda: head())()(lambda: value())())()(lambda: tail())())()
)())()(lambda: lambda fold_list_left:
lambda: define()(lambda: recursive()(lambda: lambda fold_list_right: lambda: lambda function: lambda: lambda value: lambda: lambda list:
lambda: list()(lambda: value())()(lambda: lambda head: lambda: lambda tail: lambda: function()(lambda: head())()(lambda: fold_list_right()(lambda: function())()(lambda: value())()(lambda: tail())())())()
)())()(lambda: lambda fold_list_right:
lambda: define()(lambda: recursive()(lambda: lambda map_list: lambda: lambda function: lambda: lambda list:
lambda: list()(lambda: empty_list())()(lambda: lambda head: lambda: lambda tail: lambda: list_continuation()(lambda: function()(lambda: head())())()(lambda: map_list()(lambda: function())()(lambda: tail())())())()
)())()(lambda: lambda map_list:
lambda: define()(lambda: recursive()(lambda: lambda concatenate: lambda: lambda first: lambda: lambda second:
lambda: first()(lambda: second())()(lambda: lambda head: lambda: lambda tail: lambda: list_continuation()(lambda: head())()(lambda: concatenate()(lambda: tail())()(lambda: second())())())()
)())()(lambda: lambda concatenate:
lambda: define()(lambda: lambda digits:
lambda: (lambda: recursive()(lambda: lambda self: lambda: lambda digits: lambda: lambda multiplier: lambda: digits()(lambda: zero())()(lambda: lambda head: lambda: lambda tail: lambda: add()(lambda: self()(lambda: tail())()(lambda: multiply()(lambda: ten())()(lambda: multiplier())())())()(lambda: multiply()(lambda: multiplier())()(lambda: head())())())())())()(lambda: digits())()(lambda: one())()
)()(lambda: lambda digits_to_number:
lambda: define()(
lambda: digits_to_number()(lambda: list_continuation()(lambda: eight())()(lambda: list_continuation()(lambda: four())()(lambda: empty_list())())())()
)()(lambda: lambda character_zero:
lambda: define()(
lambda: digits_to_number()(lambda: list_continuation()(lambda: nine())()(lambda: list_continuation()(lambda: four())()(lambda: empty_list())())())()
)()(lambda: lambda character_one:
lambda: define()(
lambda: digits_to_number()(lambda: list_continuation()(lambda: zero())()(lambda: list_continuation()(lambda: five())()(lambda: empty_list())())())()
)()(lambda: lambda character_two:
lambda: define()(
lambda: digits_to_number()(lambda: list_continuation()(lambda: one())()(lambda: list_continuation()(lambda: five())()(lambda: empty_list())())())()
)()(lambda: lambda character_three:
lambda: define()(
lambda: digits_to_number()(lambda: list_continuation()(lambda: two())()(lambda: list_continuation()(lambda: five())()(lambda: empty_list())())())()
)()(lambda: lambda character_four:
lambda: define()(
lambda: digits_to_number()(lambda: list_continuation()(lambda: three())()(lambda: list_continuation()(lambda: five())()(lambda: empty_list())())())()
)()(lambda: lambda character_five:
lambda: define()(
lambda: digits_to_number()(lambda: list_continuation()(lambda: four())()(lambda: list_continuation()(lambda: five())()(lambda: empty_list())())())()
)()(lambda: lambda character_six:
lambda: define()(
lambda: digits_to_number()(lambda: list_continuation()(lambda: five())()(lambda: list_continuation()(lambda: five())()(lambda: empty_list())())())()
)()(lambda: lambda character_seven:
lambda: define()(
lambda: digits_to_number()(lambda: list_continuation()(lambda: six())()(lambda: list_continuation()(lambda: five())()(lambda: empty_list())())())()
)()(lambda: lambda character_eight:
lambda: define()(
lambda: digits_to_number()(lambda: list_continuation()(lambda: seven())()(lambda: list_continuation()(lambda: five())()(lambda: empty_list())())())()
)()(lambda: lambda character_nine:
lambda: define()(lambda: lambda mapping: lambda: lambda left:
lambda: fold_list_left()(lambda: lambda pair: lambda: lambda result: lambda: equal()(lambda: first()(lambda: pair())())()(lambda: left())()(lambda: second()(lambda: pair())())()(lambda: result())())()(lambda: zero())()(lambda: mapping())()
)()(lambda: lambda map_left:
lambda: define()(lambda: lambda mapping: lambda: lambda right:
lambda: fold_list_left()(lambda: lambda pair: lambda: lambda result: lambda: equal()(lambda: second()(lambda: pair())())()(lambda: right())()(lambda: first()(lambda: pair())())()(lambda: result())())()(lambda: zero())()(lambda: mapping())()
)()(lambda: lambda map_right:
lambda: define()(
lambda: list_continuation()(lambda: pair()(lambda: zero())()(lambda: character_zero())())()(lambda: list_continuation()(lambda: pair()(lambda: one())()(lambda: character_one())())()(lambda: list_continuation()(lambda: pair()(lambda: two())()(lambda: character_two())())()(lambda: list_continuation()(lambda: pair()(lambda: three())()(lambda: character_three())())()(lambda: list_continuation()(lambda: pair()(lambda: four())()(lambda: character_four())())()(lambda: list_continuation()(lambda: pair()(lambda: five())()(lambda: character_five())())()(lambda: list_continuation()(lambda: pair()(lambda: six())()(lambda: character_six())())()(lambda: list_continuation()(lambda: pair()(lambda: seven())()(lambda: character_seven())())()(lambda: list_continuation()(lambda: pair()(lambda: eight())()(lambda: character_eight())())()(lambda: list_continuation()(lambda: pair()(lambda: nine())()(lambda: character_nine())())()(lambda: empty_list())())())())())())())())())())()
)()(lambda: lambda digit_character:
lambda: define()(
lambda: map_left()(lambda: digit_character())()
)()(lambda: lambda digit_to_character:
lambda: define()(
lambda: map_right()(lambda: digit_character())()
)()(lambda: lambda character_to_digit:
lambda: define()(
lambda: compose()(lambda: reverse())()(lambda: map_list()(lambda: digit_to_character())())()
)()(lambda: lambda digits_to_string:
lambda: define()(
lambda: compose()(lambda: reverse())()(lambda: map_list()(lambda: character_to_digit())())()
)()(lambda: lambda string_to_digits:
lambda: define()(
lambda: remainder()(lambda: ten())()
)()(lambda: lambda first_digit:
lambda: define()(
lambda: divide()(lambda: ten())()
)()(lambda: lambda pop_first_digit:
lambda: define()(lambda: lambda number:
lambda: is_zero()(lambda: number())()(lambda: list_continuation()(lambda: zero())()(lambda: empty_list())())()(lambda: (lambda: recursive()(lambda: lambda self: lambda: lambda number: lambda: is_zero()(lambda: number())()(lambda: empty_list())()(lambda: list_continuation()(lambda: first_digit()(lambda: number())())()(lambda: self()(lambda: pop_first_digit()(lambda: number())())())())())())()(lambda: number())())()
)()(lambda: lambda number_to_digits:
lambda: define()(
lambda: compose()(lambda: number_to_digits())()(lambda: digits_to_string())()
)()(lambda: lambda number_to_string:
lambda: define()(
lambda: compose()(lambda: string_to_digits())()(lambda: digits_to_number())()
)()(lambda: lambda string_to_number:
lambda: define()(lambda: lambda print: lambda: lambda input: lambda: lambda exit:
lambda: input()(lambda: lambda string: lambda: lambda input: lambda: print()(lambda: number_to_string()(lambda: string_to_number()(lambda: string())())())()(lambda: exit())())()
)()(lambda: lambda main:
lambda: define()(lambda: lambda __literal:
lambda: (lambda: false(), lambda: true())[__literal()]()
)()(lambda: lambda __pure_bool:
lambda: define()(lambda: lambda __value:
lambda: bool(__value())
)()(lambda: lambda __impure_truthy:
lambda: define()(
lambda: compose()(lambda: __impure_truthy())()(lambda: __pure_bool())()
)()(lambda: lambda __pure_truthy:
lambda: define()(
lambda: compose()(lambda: __pure_truthy())()(lambda: negate())()
)()(lambda: lambda __pure_falsey:
lambda: define()(lambda: lambda __first: lambda: lambda __second:
lambda: __first() == __second()
)()(lambda: lambda __impure_equal:
lambda: define()(
lambda: __impure_equal()(lambda: 0)()
)()(lambda: lambda __impure_is_zero:
lambda: define()(
lambda: compose()(lambda: __impure_is_zero())()(lambda: __pure_bool())()
)()(lambda: lambda __pure_is_zero:
lambda: define()(lambda: lambda __item: lambda: lambda __sequence:
lambda: __sequence()[__item()]
)()(lambda: lambda __get_item:
lambda: define()(
lambda: __get_item()(lambda: 0)()
)()(lambda: lambda __head:
lambda: define()(
lambda: __get_item()(lambda: slice(1, None))()
)()(lambda: lambda __tail:
lambda: define()(lambda: lambda __addend: lambda: lambda __augend:
lambda: __augend() + __addend()
)()(lambda: lambda __add:
lambda: define()(lambda: lambda __subtrahend: lambda: lambda __minuend:
lambda: __minuend() - __subtrahend()
)()(lambda: lambda __subtract:
lambda: define()(
lambda: __add()(lambda: 1)()
)()(lambda: lambda __increment:
lambda: define()(
lambda: __subtract()(lambda: 1)()
)()(lambda: lambda __decrement:
lambda: define()(lambda: recursive()(lambda: lambda __pure_number: lambda: lambda __literal:
lambda: __pure_is_zero()(lambda: __literal())()(lambda: zero())()(lambda: successor()(lambda: __pure_number()(lambda: __decrement()(lambda: __literal())())())())()
)())()(lambda: lambda __pure_number:
lambda: define()(lambda: lambda number:
lambda: fold_number()(lambda: __increment())()(lambda: 0)()(lambda: number())()
)()(lambda: lambda __unpure_number:
lambda: define()(lambda: lambda __character:
lambda: ord(__character())
)()(lambda: lambda __ord:
lambda: define()(lambda: lambda __number:
lambda: chr(__number())
)()(lambda: lambda __chr:
lambda: define()(
lambda: compose()(lambda: __ord())()(lambda: __pure_number())()
)()(lambda: lambda __pure_character:
lambda: define()(
lambda: compose()(lambda: __unpure_number())()(lambda: __chr())()
)()(lambda: lambda __unpure_character:
lambda: define()(lambda: recursive()(lambda: lambda __pure_string: lambda: lambda __literal:
lambda: __pure_falsey()(lambda: __literal())()(lambda: empty_list())()(lambda: list_continuation()(lambda: __pure_character()(lambda: __head()(lambda: __literal())())())()(lambda: __pure_string()(lambda: __tail()(lambda: __literal())())())())()
)())()(lambda: lambda __pure_string:
lambda: define()(lambda: lambda string:
lambda: fold_list_left()(lambda: lambda current: lambda: lambda accumulator: lambda: __add()(lambda: __unpure_character()(lambda: current())())()(lambda: accumulator())())()(lambda: str())()(lambda: string())()
)()(lambda: lambda __unpure_string:
lambda: define()(lambda: lambda string: lambda: lambda continuation:
lambda: true()(lambda: continuation())()(print(__unpure_string()(string)()))()
)()(lambda: lambda __print:
lambda: define()(lambda: recursive()(lambda: lambda __input: lambda:
lambda: (lambda: lambda input: lambda: lambda function: lambda: function()(lambda: __pure_string()(lambda: input())())()(lambda: __input()())())()(cache(input))()
)())()(lambda: lambda __input:
lambda: main()(lambda: __print())()(lambda: __input()())()(lambda: exit())()
)())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())())()(lambda: lambda definition: lambda: lambda scope: lambda: scope()(lambda: definition())())()
assert False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment