# Independently authored Python 3.9 map iterator examples.
print(list(map(abs, [-3, 0, 4])))
print(list(map(lambda a, b: a * 10 + b, range(4), [6, 7])))
print(list(map(ord, 'aé雪😀')))
print(list(map(chr, [0, 955, 128512])) == ['\0', 'λ', '😀'])
print(list(map(lambda value: value + 1, b'\0\x7f\xff')))
print(list(map(len, ('a', 'é😀', ''))))
left = iter(range(6))
right = iter([10])
cursor = map(lambda a, b: a + b, left, right)
print(iter(cursor) is cursor, type(cursor).__name__, isinstance(cursor, map))
print(next(cursor), next(cursor, -1), next(cursor, -1), next(left))
print(list(map(None, ())))
stop = StopIteration('callback stop')
def convert(value):
    if value == 1:
        raise stop
    return value * 2
cursor2 = map(convert, [0, 1, 2])
print(next(cursor2))
try:
    next(cursor2)
except StopIteration as error:
    print(error is stop, str(error))
print(next(cursor2), next(cursor2, -1))
