#!/usr/bin/env python # ## @package _05e_pascal_zip # A Pascal triangle generator using yield. # # @author Paulo Roma # @since 21/05/2010 # @see http://en.wikipedia.org/wiki/Generator_(computer_science) # @see https://wiki.python.org/moin/Generators # @see https://docs.python.org/2/library/itertools.html # @see https://realpython.com/introduction-to-python-generators # @see https://gist.github.com/kenichi-shibata/7dd7b325f399f64a5a5676254706d6bf from itertools import takewhile, count ## # A Pascal Triangle generator. # # @param nlines number of rows to be returned. # @param line list with the current row. # @return a generator which, each time, return the whole next line of the Pascal triangle. # @see https://pythontips.com/2013/09/29/the-python-yield-keyword-explained/ # @see https://docs.python.org/3/library/functions.html#map # # map(function, iterable, ...) #
# Apply function to every item of iterable and return a list of the results.
# If additional iterable arguments are passed, function must take that many
# arguments and is applied to the items from all iterables in parallel.
# If one iterable is shorter than another it is assumed to be extended with None items.
#
# If function is None, the identity function is assumed; if there are multiple arguments,
# map() returns a list consisting of tuples containing the corresponding items from
# all iterables (a kind of transpose operation).
# The iterable arguments may be a sequence or any iterable object; the result is always a list.
#