<jupyter_start><jupyter_text>Lambda Function<jupyter_code>def my_func(n):
    return n**2
my_func(10)
my_lambda_func = lambda n: n**2
my_lambda_func(10)<jupyter_output><empty_output><jupyter_text>Maphttps://docs.python.org/3/library/functions.htmlmap<jupyter_code>mapper = map(lambda n: n**2, [1,2,3])
list(mapper)
list(map(lambda n: n**2, [1,2,3]))<jupyter_output><empty_output><jupyter_text>Filterhttps://docs.python.org/3/library/functions.htmlfilter<jupyter_code>my_list = [12,54,-545,-837,234,675]
filtered = list(filter(lambda x: x >= 0, my_list))
filtered
list(map(lambda x: x-10, filter(lambda x: x >= 0, my_list)))<jupyter_output><empty_output><jupyter_text>functools.reducehttps://docs.python.org/3/library/functools.html<jupyter_code>from functools import  reduce
reduce(lambda x,y: x+y, my_list)
sum(my_list)
reduce(lambda x,y: str(x) + ',' + str(y), filtered)<jupyter_output><empty_output><jupyter_text>Put them together<jupyter_code>reduce(lambda x,y: str(x) + ',' + str(y), map(lambda x: x-10, filter(lambda x: x >= 0, my_list)))<jupyter_output><empty_output><jupyter_text>List comprehenstion<jupyter_code>[i**2 for i in [1,2,3]]
new_list=[]
for i in [1,2,3]:
    new_list.append(i**2)
new_list<jupyter_output><empty_output><jupyter_text>Sortting a list<jupyter_code>sorted(iterable, *, key=None, reverse=False)
sorted([2453,28,134])
sorted(['2453','28','134'])
sorted([2453,28,134], key = lambda x: str(x))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1797520661157025, 'fraction_numerical': 0.05165289256198347, 'mean_word_length': 9.453237410071942, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 32, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '298983', 'license': 'MIT', 'n_tokens_mistral': 647, 'n_tokens_neox': 609, 'n_words': 85, 'path': '2020-08-23-python-functional.ipynb', 'repo_name': 'Cheukting/python02hero', 'size': '1452'}