[nem-en] Extension methods
Alejandro Serrano
trupill at yahoo.es
Tue Jan 31 21:05:07 CET 2006
Thanks for telling it. As of today, System.Query has
been merged into the mcs/class Mono tree, and all
Sequence.cs files have been merged too. Please check
there for the latest versions.
I will correct as soon as possible the SkipWhile
method. Equals<T> just follws the spec, which tells
that objects must be compared using both Equals and
GetHashCode methods. I just followed it ;-)
Thanks,
trupill
--- Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl>
escribió:
> Alejandro Serrano <trupill at yahoo.es> writes:
>
> > I attach a C# implementation of System.Query to
> start thinking about
> > query-like expressions.
>
> Anybody has tested it? I browsed it just for
> curiosity, and found
> e.g. this in System.Query/SequencePartitioning.cs:
>
>
> [System.Runtime.CompilerServices.Extension]
> public static IEnumerable<T>
> SkipWhile<T> (
> IEnumerable<T> source,
> Func<T, bool> predicate)
> {
> if (source == null ||
> predicate == null)
> throw new
> ArgumentNullException ();
>
> bool yield = false;
>
> foreach (T element in
> source) {
> if (yield)
> yield return
> element;
> else
> if
> (!predicate (element))
>
> yield = true;
> }
> }
>
> which doesn't yield the first element which doesn't
> satisfy the
> predicate, or this in
> System.Query/SequenceNotInSpec.cs:
>
>
> [System.Runtime.CompilerServices.Extension]
> private static bool Equals<T> (
> T first, T second)
> {
> // Mostly, values in
> Enumerable<T>
> // sequences need to be
> compared using
> // Equals and GetHashCode
>
> if (first == null || second
> == null)
> return (first ==
> null && second == null);
> else
> return
> ((first.Equals (second) ||
>
> first.GetHashCode () == second.GetHashCode ()));
> }
>
> where comparing hash codes doesn't seem to make
> sense.
>
> --
> __("< Marcin Kowalczyk
> \__/ qrczak at knm.org.pl
> ^^ http://qrnik.knm.org.pl/~qrczak/
>
> _______________________________________________
> https://nemerle.org/mailman/listinfo/devel-en
>
______________________________________________
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com
More information about the devel-en
mailing list