Skip to content

Commit 2372319

Browse files
committedFeb 9, 2020
Lambda
1 parent 5527bfe commit 2372319

File tree

2 files changed

+138
-39
lines changed

2 files changed

+138
-39
lines changed
 

‎Lambda Map.ipynb

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"### lambda expressions, Map & Filter"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": 2,
13+
"metadata": {},
14+
"outputs": [],
15+
"source": [
16+
"def times2(var):\n",
17+
" return var*2"
18+
]
19+
},
20+
{
21+
"cell_type": "code",
22+
"execution_count": 3,
23+
"metadata": {},
24+
"outputs": [
25+
{
26+
"data": {
27+
"text/plain": [
28+
"4"
29+
]
30+
},
31+
"execution_count": 3,
32+
"metadata": {},
33+
"output_type": "execute_result"
34+
}
35+
],
36+
"source": [
37+
"times2(2)"
38+
]
39+
},
40+
{
41+
"cell_type": "code",
42+
"execution_count": 4,
43+
"metadata": {},
44+
"outputs": [
45+
{
46+
"data": {
47+
"text/plain": [
48+
"<function __main__.<lambda>(var)>"
49+
]
50+
},
51+
"execution_count": 4,
52+
"metadata": {},
53+
"output_type": "execute_result"
54+
}
55+
],
56+
"source": [
57+
"lambda var: var*2"
58+
]
59+
},
60+
{
61+
"cell_type": "code",
62+
"execution_count": 5,
63+
"metadata": {},
64+
"outputs": [],
65+
"source": [
66+
"seq = [1,2,3,4,5]"
67+
]
68+
},
69+
{
70+
"cell_type": "code",
71+
"execution_count": 6,
72+
"metadata": {},
73+
"outputs": [
74+
{
75+
"data": {
76+
"text/plain": [
77+
"<map at 0x1f838150e08>"
78+
]
79+
},
80+
"execution_count": 6,
81+
"metadata": {},
82+
"output_type": "execute_result"
83+
}
84+
],
85+
"source": [
86+
"map(times2,seq)"
87+
]
88+
},
89+
{
90+
"cell_type": "code",
91+
"execution_count": 7,
92+
"metadata": {},
93+
"outputs": [
94+
{
95+
"data": {
96+
"text/plain": [
97+
"[2, 4, 6, 8, 10]"
98+
]
99+
},
100+
"execution_count": 7,
101+
"metadata": {},
102+
"output_type": "execute_result"
103+
}
104+
],
105+
"source": [
106+
"list(map(times2,seq))"
107+
]
108+
},
109+
{
110+
"cell_type": "code",
111+
"execution_count": null,
112+
"metadata": {},
113+
"outputs": [],
114+
"source": []
115+
}
116+
],
117+
"metadata": {
118+
"kernelspec": {
119+
"display_name": "Python 3",
120+
"language": "python",
121+
"name": "python3"
122+
},
123+
"language_info": {
124+
"codemirror_mode": {
125+
"name": "ipython",
126+
"version": 3
127+
},
128+
"file_extension": ".py",
129+
"mimetype": "text/x-python",
130+
"name": "python",
131+
"nbconvert_exporter": "python",
132+
"pygments_lexer": "ipython3",
133+
"version": "3.7.4"
134+
}
135+
},
136+
"nbformat": 4,
137+
"nbformat_minor": 4
138+
}

‎Untitled.ipynb

-39
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.