Skip to content

Commit

Permalink
Merge commit 'cf78251bea393df58ca5ffd0e2c8190846887384'
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienPalard committed May 12, 2017
2 parents 3a872bf + cf78251 commit dc0146c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,11 @@ def stdout(x):
>>> range(3) | permutations | concat('-')
'(0, 1, 2)-(0, 2, 1)-(1, 0, 2)-(1, 2, 0)-(2, 0, 1)-(2, 1, 0)'
transpose()
Transposes the rows and columns of a matrix
>>> [[1, 2, 3], [4, 5, 6], [7, 8, 9]] | transpose
[(1, 4, 7), (2, 5, 8), (3, 6, 9)]
Euler project samples :
# Find the sum of all the multiples of 3 or 5 below 1000.
Expand Down Expand Up @@ -372,8 +377,8 @@ def stdout(x):
'traverse', 'concat', 'as_list', 'as_tuple', 'stdout', 'lineout',
'tee', 'add', 'first', 'chain', 'select', 'where', 'take_while',
'skip_while', 'aggregate', 'groupby', 'sort', 'reverse',
'chain_with', 'islice', 'izip', 'passed', 'index', 'strip',
'lstrip', 'rstrip', 'run_with', 't', 'to_type',
'chain_with', 'islice', 'izip', 'passed', 'index', 'strip',
'lstrip', 'rstrip', 'run_with', 't', 'to_type', 'transpose'
]

class Pipe:
Expand Down Expand Up @@ -621,6 +626,10 @@ def t(iterable, y):
def to_type(x, t):
return t(x)

@Pipe
def transpose(iterable):
return zip(*iterable)

chain_with = Pipe(itertools.chain)
islice = Pipe(itertools.islice)

Expand Down

0 comments on commit dc0146c

Please sign in to comment.