lib: add Seq:prepend as an alias of `insert_all(0)`
authorJean Privat <jean@pryen.org>
Fri, 15 Aug 2014 19:56:27 +0000 (15:56 -0400)
committerJean Privat <jean@pryen.org>
Fri, 15 Aug 2014 19:56:27 +0000 (15:56 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

lib/standard/collection/abstract_collection.nit

index b99c465..a806c57 100644 (file)
@@ -803,6 +803,15 @@ interface Sequence[E]
        #     assert a  == [20,10,1,2,3]
        fun unshift(e: E) is abstract
 
+       # Add all items of `coll` before the first one.
+       #
+       #     var a = [1,2,3]
+       #     a.prepend([7..9])
+       #     assert a  == [7,8,9,1,2,3]
+       #
+       # Alias of `insert_at(coll, 0)`
+       fun prepend(coll: Collection[E]) do insert_all(coll, 0)
+
        # Remove the first item.
        # The second item thus become the first.
        #