On Fri, 2010-08-20 at 17:54 +0530, Martin DeMello wrote:
> On Fri, Aug 20, 2010 at 5:47 PM, Andrea Del Signore <[email protected]> wrote:
Hi,
> >
> > the only error I can spot is here:
> >>
> >> public void map(DFunc fn, Gee.List acc) {
> >
> > should be:
> >
> > public void map(DFunc fn, Gee.List<G> acc)
>
> No, it is a list of the target type, not the source type.
Yes now I see
>
> > I really don't understand what are you trying to do can you explain to
> > me? Thanks.
>
> I'm trying to write a generic map function that consumes a list and
> emits a transformed list. If I have two lists
>
> a = List<source_type> // full
> b = List<target_type> // empty
>
> and a function
>
> target_type fn(source_type)
>
> I should be able to write
>
> a.map(fn, b)
>
> And b[i] should be fn(a[i]) for all i in a's indices.
>
> martin
Thanks for the explanation but I can't really imagine any other way of
doing this without specializing the map method, because I don't see
implemented any "standard" (non generic) IList interface in gee.
So:
public void map<T>(DFunc fn, Gee.List<T> acc) { ... }
and then
a.map<string>((Enumerable.DFunc<int, string>) f , b);
Regards,
Andrea
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list