Closed GoogleCodeExporter closed 9 years ago
The vala source:
using Gee;
public interface Enumerable<G> : Iterable<G> {
public delegate O DFunc<I, O>(I elem);
public void map(DFunc fn, Gee.List acc) {
foreach (G i in this) {
acc.add(fn(i));
}
}
}
public class EnumerableList<G> : Gee.ArrayList<G>, Enumerable<G> {
}
public string f(int i) {
return "%d".printf(i);
}
public static int main(string[] args) {
var a = new EnumerableList<int> ();
a.add(1);
a.add(2);
a.add(3);
var b = new Gee.ArrayList<string> ();
a.map((Enumerable.DFunc<int, string>) f , b);
foreach (string i in b) {
stdout.printf("-- %s --\n", i);
}
return 0;
}
Original comment by seje...@gmail.com
on 20 Aug 2010 at 12:03
This issue was closed by revision r747.
Original comment by seje...@gmail.com
on 20 Aug 2010 at 12:18
Original comment by seje...@gmail.com
on 24 Aug 2010 at 6:23
Original issue reported on code.google.com by
seje...@gmail.com
on 20 Aug 2010 at 12:03