from geom2d import *

l1 = []

for i in range(-5, 6):
    l1.append(Point(i, i*i))

l2 = []

for el in l1:
    l2.append(Point(el.x, -el.y))

print(l1)
print(l2)

# List comprehension
l1c = [Point(i, i*i) for i in range(-5, 6)]
l2c = [Point(el.x, -el.y) for el in l1c]

print("List comprehension")
print(l1c)
print(l2c)

from geom2d import *

l1 = list(map(lambda i: Point(i, i*i), range(-5, 6)))

# l2 = list(map(lambda p: Point(p.x, -p.y), l1))

# l2 = list(filter(lambda p: p.x > 0, l1))
l2 = list(filter(lambda p: p.x % 2 == 0, l1))

print(l1)
print(l2)

Work with lists in functional way (map, filter)
Work with lists in functional way (map, filter)

  from geom2d import *
  
- l1 = []
+ l1 = list(map(lambda i: Point(i, i*i), range(-5, 6)))
  
+ # l2 = list(map(lambda p: Point(p.x, -p.y), l1))
- for i in range(-5, 6):
-     l1.append(Point(i, i*i))
  
+ # l2 = list(filter(lambda p: p.x > 0, l1))
+ l2 = list(filter(lambda p: p.x % 2 == 0, l1))
- l2 = []
- 
- for el in l1:
-     l2.append(Point(el.x, -el.y))
  
  print(l1)
  print(l2)
  
- # List comprehension
- l1c = [Point(i, i*i) for i in range(-5, 6)]
- l2c = [Point(el.x, -el.y) for el in l1c]
- 
- print("List comprehension")
- print(l1c)
- print(l2c)
- 
Work with lists in functional way (map, filter)
## Code Before:
from geom2d import *

l1 = []

for i in range(-5, 6):
    l1.append(Point(i, i*i))

l2 = []

for el in l1:
    l2.append(Point(el.x, -el.y))

print(l1)
print(l2)

# List comprehension
l1c = [Point(i, i*i) for i in range(-5, 6)]
l2c = [Point(el.x, -el.y) for el in l1c]

print("List comprehension")
print(l1c)
print(l2c)

## Instruction:
Work with lists in functional way (map, filter)
## Code After:
from geom2d import *

l1 = list(map(lambda i: Point(i, i*i), range(-5, 6)))

# l2 = list(map(lambda p: Point(p.x, -p.y), l1))

# l2 = list(filter(lambda p: p.x > 0, l1))
l2 = list(filter(lambda p: p.x % 2 == 0, l1))

print(l1)
print(l2)
