Last active
December 30, 2015 09:19
-
-
Save eriktaubeneck/7808280 to your computer and use it in GitHub Desktop.
Revisions
-
eriktaubeneck revised this gist
Dec 5, 2013 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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,5 @@ from itertools import tee, imap, izip, islice from operator import itemgetter def all_but_last_n(it,n): it1, it2 = tee(it,2) -
eriktaubeneck revised this gist
Dec 5, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 @@ -2,6 +2,6 @@ def all_but_last_n(it,n): it1, it2 = tee(it,2) return imap(itemgetter(0),izip(it1,islice(it2,n,None))) assert [0,1,2] == list(all_but_last_n(xrange(5),2)) -
eriktaubeneck created this gist
Dec 5, 2013 .There are no files selected for viewing
This file contains hidden or 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, imap, izip, islice def all_but_last_n(it,n): it1, it2 = tee(it,2) return imap(lambda x:x[0],izip(it1,islice(it2,n,None))) assert [0,1,2] == list(all_but_last_n(xrange(5),2))