Last active
September 28, 2017 07:23
Revisions
-
lihuanshuai revised this gist
Sep 28, 2017 . No changes.There are no files selected for viewing
-
lihuanshuai revised this gist
Sep 28, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,5 +3,5 @@ def previous_and_next(iterable, fill_value=None): prevs, items, nexts = tee(iterable, 3) prevs = chain([fill_value], prevs) nexts = chain(slice(nexts, 1, None), [fill_value]) return zip(prevs, items, nexts) -
lihuanshuai revised this gist
Sep 28, 2017 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ from itertools import tee, islice as slice, chain, izip as zip def previous_and_next(iterable, fill_value=None): prevs, items, nexts = tee(iterable, 3) prevs = chain([fill_value], prevs) nexts = chain(islice(nexts, 1, None), [fill_value]) return izip(prevs, items, nexts) -
lihuanshuai revised this gist
Sep 28, 2017 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ from itertools import tee, islice as slice, chain, izip as zip def previous_and_next(some_iterable, fill_value=None): prevs, items, nexts = tee(some_iterable, 3) prevs = chain([fill_value], prevs) nexts = chain(islice(nexts, 1, None), [fillvalue]) return izip(prevs, items, nexts) -
lihuanshuai revised this gist
Sep 28, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ from itertools import tee, islice as slice, chain, izip as zip def previous_and_next(some_iterable, fillvalue=None): prevs, items, nexts = tee(some_iterable, 3) prevs = chain([fillvalue], prevs) nexts = chain(islice(nexts, 1, None), [None]) return izip(prevs, items, nexts) -
lihuanshuai revised this gist
Sep 28, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ from itertools import tee, islice as slice, chain, izip as zip def previous_and_next(some_iterable, fillval): prevs, items, nexts = tee(some_iterable, 3) prevs = chain([None], prevs) nexts = chain(islice(nexts, 1, None), [None]) -
lihuanshuai revised this gist
Sep 28, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ from itertools import tee, islice as , chain, izip def previous_and_next(some_iterable): prevs, items, nexts = tee(some_iterable, 3) -
lihuanshuai created this gist
Sep 28, 2017 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ from itertools import tee, islice, chain, izip def previous_and_next(some_iterable): prevs, items, nexts = tee(some_iterable, 3) prevs = chain([None], prevs) nexts = chain(islice(nexts, 1, None), [None]) return izip(prevs, items, nexts)