python from fn import F squared_values = F.map(lambda x: x**2, [1, 2, 3, 4]) print(squared_values) # [1, 4, 9, 16] product = F.reduce(lambda x, y: x * y, [1, 2, 3, 4]) print(product) # 24 odd_numbers = F.filter(lambda x: x % 2 != 0, [1, 2, 3, 4]) print(odd_numbers) # [1, 3] python from fn import _ double = lambda x: x * 2 add_five = lambda x: x + 5 combined_function = F.compose(double, add_five) result = combined_function(10) print(result) # 25 python from fn import _ infinite_sequence = F.iterate(lambda x: x + 2, 1) first_five = F.take(5, infinite_sequence) print(list(first_five)) # [1, 3, 5, 7, 9]


上一篇:
下一篇:
切换中文