[Nice-commit] Nice/stdlib/nice/lang collections.nice,1.54,1.55 array.nice,1.27,1.28
Brought to you by:
bonniot
From: <ar...@us...> - 2003-09-03 23:26:33
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang In directory sc8-pr-cvs1:/tmp/cvs-serv29656/F:/nice/stdlib/nice/lang Modified Files: collections.nice array.nice Log Message: Revert filter to a monomorphic return type. Index: collections.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/collections.nice,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** collections.nice 30 Aug 2003 23:06:07 -0000 1.54 --- collections.nice 3 Sep 2003 23:26:30 -0000 1.55 *************** *** 27,31 **** <Collection C, T, U> C<U> map(C<T> coll, T->U func); ! <Collection C, T, U | T <: U> C<U> filter(C<T>, T->boolean); /** Return a collection containing all elements for which converter --- 27,33 ---- <Collection C, T, U> C<U> map(C<T> coll, T->U func); ! //<Collection C, T, U | T <: U> C<U> filter(C<T>, T->boolean); ! //temporaly using a non polymorpic return because of type inference ! <Collection C, T> C<T> filter(C<T>, T->boolean); /** Return a collection containing all elements for which converter *************** *** 126,132 **** } ! <C,T,U> filter(coll, test) { ! C<U> res = coll.similarEmptyCollection(); for (T elem : coll) if (test(elem)) --- 128,134 ---- } ! <C,T> filter(coll, test) { ! C<T> res = coll.similarEmptyCollection(); for (T elem : coll) if (test(elem)) Index: array.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/array.nice,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** array.nice 25 Aug 2003 17:27:10 -0000 1.27 --- array.nice 3 Sep 2003 23:26:30 -0000 1.28 *************** *** 86,99 **** <C,T,U> map(a@Array, func) = fill(new U[a.length], int i => func(a[i])); ! <C,T,U> filter(a@Array, test) = a.filter(test); // Specialized versions for arrays. ! <T, U | T <: U> U[] filter(T[] a, T -> boolean test) { int l = a.length; int found = 0; ! U[] res = cast(new U[l]); a.foreach(T elem => --- 86,99 ---- <C,T,U> map(a@Array, func) = fill(new U[a.length], int i => func(a[i])); ! <C,T> filter(a@Array, test) = a.filter(test); // Specialized versions for arrays. ! <T> T[] filter(T[] a, T -> boolean test) { int l = a.length; int found = 0; ! T[] res = cast(new T[l]); a.foreach(T elem => |