while learning the map function, i've landed on this wikipedia page(http://en.wikipedia.org/wiki/Map_(higher-order_function)). For each language there is a column about handing multiple list, i thought it could be a good idea to see how D handle this:

is this the official way ?

---
auto fruits = ["apple", "banana", "orange"][];
auto vegies = ["grass", "salad"][];

// 1 list
auto yougonna = map!(a => "eat " ~ a)(fruits);
// 2 lists
auto youreallygonna = map!( `map!(a => "eat " ~ a)(a)` )([fruits, vegies]);

writeln(yougonna.stringof, yougonna);
writeln(youreallygonna.stringof, youreallygonna);
---

which outputs:

---
yougonna["eat apple", "eat banana", "eat orange"]
youreallygonna[["eat apple", "eat banana", "eat orange"], ["eat grass", "eat salad"]]
---

The doc doesn't specify anything about multiple lists.


Reply via email to