Skip to content
Browse files

sequences.extras: even simpler round-robin.

  • Loading branch information...
1 parent a62cf7f commit c2e14963744af237f910a6c8b2210f1657c728e5 @mrjbq7 mrjbq7 committed
Showing with 2 additions and 6 deletions.
  1. +2 −6 extra/sequences/extras/extras.factor
View
8 extra/sequences/extras/extras.factor
@@ -184,12 +184,8 @@ PRIVATE>
: 2count ( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ? ) -- ... n )
[ 1 0 ? ] compose 2map-sum ; inline
-: max-lengths ( seq -- n )
- [ length ] [ max ] map-reduce ;
-
: round-robin ( seq -- newseq )
[ { } ] [
- dup [ max-lengths ] [ length ] bi [ iota ] bi@
- [ [ 2array ] with map ] curry map concat swap
- [ [ first2 ] dip nth-unsafe ?nth ] curry map sift
+ [ [ length ] [ max ] map-reduce iota ] keep
+ [ [ ?nth ] with map ] curry map concat sift
] if-empty ;

0 comments on commit c2e1496

Please sign in to comment.
Something went wrong with that request. Please try again.