[Assorted-commits] SF.net SVN: assorted: [297] scala-commons/trunk/src/commons/Collections. scala
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-02-03 08:39:44
|
Revision: 297 http://assorted.svn.sourceforge.net/assorted/?rev=297&view=rev Author: yangzhang Date: 2008-02-03 00:39:46 -0800 (Sun, 03 Feb 2008) Log Message: ----------- fixed paragraphs Modified Paths: -------------- scala-commons/trunk/src/commons/Collections.scala Modified: scala-commons/trunk/src/commons/Collections.scala =================================================================== --- scala-commons/trunk/src/commons/Collections.scala 2008-02-03 07:41:48 UTC (rev 296) +++ scala-commons/trunk/src/commons/Collections.scala 2008-02-03 08:39:46 UTC (rev 297) @@ -92,7 +92,7 @@ // is in turn == groupByPairwise. /** * This splits up the stream by using spanBy - * + * <p> * <code>[1..9].groupBy(_/3) == [[1,2],[3,4,5],[6,7,8]]</code> */ def groupBy[b](f: a => b) = { @@ -225,28 +225,22 @@ /** * A combination of take and drop. - * + * <p> * <code>span(3)([a,b,c,d,e]) == ([a,b,c],[d,e])</code> */ def span[a](n: Int)(xs: Seq[a]) = (xs take n, xs drop n) /** * Same as span but for Strings, which are treated as an array of chars. - * + * <p> * <code>spanstr(3)("abcde") == ("abc","de") */ def spanstr[a](n: Int)(xs: String) = (xs take n mkString ("","",""), xs drop n mkString ("","","")) - // TODO where does this go??? /** - * [1,3,5,6,7,8] odd -> ([1,3,5],[6,7,8]) - * [] _ -> ([],[]) - */ - - /** * A combination of takeWhile and dropWhile. - * + * <p> * <code>spanBy([1,2,3,4,5])((_ != 3)) == ([1,2],[3,4,5])</code> */ def spanBy[a](xs: Seq[a])(pred: a => Boolean): (Seq[a],Seq[a]) = { @@ -258,7 +252,7 @@ /** * Split up the sequence by the given predicate. Similar to String.split, but * matching is per-element. - * + * <p> * <code> * splitBy([1..10], (_ % 4 < 2)) == [[2,3],[6,7],[8,9]] * </code> @@ -277,7 +271,7 @@ /** * Same as splitBy, but uses the negation of the pred. Note that this is * quite different from Haskell's groupBy. - * + * <p> * <code>groupBy([1,2,3,4,5], (_ % 4 < 2)) == [[1],[4,5],[8,9]]</code> */ def groupBy[a](xs: Seq[a])(pred: a => Boolean): Stream[Seq[a]] = @@ -286,7 +280,7 @@ // TODO: these was renamed from slices. Make sure nothing was broken. /** * Return all length-n "chunks" of xs as a stream. - * + * <p> * <code>chunks([a..h], 3) == [[a,b,c],[d,e,f],[g,h]]</code> */ def chunks[a](n: Int)(xs: Seq[a]): Stream[Seq[a]] = { @@ -297,7 +291,7 @@ // TODO Type-check this code; is it actually a projection? /** * Return all length-n slices of xs. - * + * <p> * <code>slice([a,b,c,d,e], 3) == [[a,b,c],[b,c,d],[c,d,e]]</code> */ def slices[a](xs: Seq[a], n: Int) = @@ -305,7 +299,7 @@ /** * Same as slices(_,2) but yields tuples. - * + * <p> * <code> * pairwise([a,b,c]) == [(a,b),(c,d)] * pairwise([a]) == [] @@ -318,7 +312,7 @@ * Same as Haskell's groupBy. Groups together equal elements, letting the * user supply a custom equality test. Note this is quite different from * groupBy/splitBy. - * + * <p> * <code> * groupPairwiseBy([1..9], (_/3 == _/3)) == [[1,2],[3,4,5],[6,7,8],[9]]] * </code> @@ -351,7 +345,7 @@ /** * Truncate elements off the end of the sequence that satisfy the given * predicate. A reverse dropWhile. - * + * <p> * <code>truncateWhile([1,2,3,4,5], (_ != 3)) == [1,2,3]</code> */ def truncateWhile[a](seq: Seq[a])(pred: a => Boolean) = @@ -393,7 +387,7 @@ /** * Indexes the result of groupBy. - * + * <p> * 0 1 2 3 4 5 6 7 8 9 * [a,b,c,c,c,d,d,e,f,f] -> [[0],[1],[2,3,4],[5,6],[7],[8,9]] * [] -> [] @@ -611,4 +605,10 @@ h } def iterator2array[a](xs: Iterator[a]) = xs.toList.toArray + + // TODO where does this go??? + // + // [1,3,5,6,7,8] odd -> ([1,3,5],[6,7,8]) + // [] _ -> ([],[]) + // } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |