[IronPython] how to use Predicates in IPy?

Dino Viehland dinov at microsoft.com
Fri Jul 24 22:24:14 CEST 2009


Is this actually a List<T> or something that just happens
to have a similar FindAll method?  It looks like List<T> only
has a single overload so it works there.

In this case you can do:

Predicate[UInt32](lambda x: True)
Or
Predicate[Primitive](lambda x: True)

To construct the delegate explicitly depending on which overload you want.

> -----Original Message-----
> From: users-bounces at lists.ironpython.com [mailto:users-
> bounces at lists.ironpython.com] On Behalf Of Count László de Almásy
> Sent: Friday, July 24, 2009 1:19 PM
> To: Discussion of IronPython
> Subject: Re: [IronPython] how to use Predicates in IPy?
>
> both attempts give a TypError:
>
> >>> sim.ObjectsPrimitives.FindAll(lambda inst:True)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: Multiple targets could match: FindAll(Predicate[UInt32]),
> FindAll(Predicate[Primitive])
>
> On Fri, Jul 24, 2009 at 10:15 AM, Dino Viehland<dinov at microsoft.com>
> wrote:
> > You can just do:
> >
> > x.FindAll(lambda inst:True)
> >
> > or:
> >
> > def MyPredicate(obj):
> >        return True
> >
> > x.FindAll(MyPredicate)
> >
> >> -----Original Message-----
> >> From: users-bounces at lists.ironpython.com [mailto:users-
> >> bounces at lists.ironpython.com] On Behalf Of Count László de Almásy
> >> Sent: Friday, July 24, 2009 12:04 AM
> >> To: Discussion of IronPython
> >> Subject: [IronPython] how to use Predicates in IPy?
> >>
> >> I've been unable to find any examples of how to define/use
> Predicates
> >> in IPy, as for use with .NET's List(T).FindAll method. Specifically
> >> I'm trying to use
> >>
> http://lib.openmetaverse.org/docs/trunk/html/M_OpenMetaverse_InternalDi
> >> ctionary_2_FindAll_1.htm
> >>
> >> Anyway, if someone could help with an example of how to do such
> things
> >> in IPy I'd greatly appreciate. The one mention of it in this list's
> >> archives is from 2006 and refers to an example url that is now
> broken.
> >>
> >> --
> >> Cheers, László
> >> _______________________________________________
> >> Users mailing list
> >> Users at lists.ironpython.com
> >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> > _______________________________________________
> > Users mailing list
> > Users at lists.ironpython.com
> > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> >
>
>
>
> --
> Cheers, László
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list