1 import std.stdio;
2
3 struct person {
4 char[] first_name = "(none)";
5 char[] last_name = "(none)";
6 int id = -1;
7 char[] zipcode = "00000";
8 }
9
10 void main(char[][] args)
11 {
12 person[10] population;
13
14 population[2].first_name = "fred";
15 population[2].id = 1001;
16 population[2].zipcode = "27502";
17
18 population[3].first_name = "barney";
19 population[3].id = 1002;
20 population[3].zipcode = "27501";
21
22 foreach (p; filtered(population)) {
23 writefln(p.zipcode);
24 }
25 }
26
27 struct zips { int id; char[] zipcode; }
28
29 zips[] filtered(person[] population) {
30 zips[] retval;
31
32 foreach (p; population) {
33 if (p.id >= 0) {
34 retval ~= zips(p.id, p.zipcode);
35 }
36 }
37
38 return retval;
39 }