Parametric polymorphism: Difference between revisions
Content added Content deleted
(D entry: updated and improved) |
(Better D entry) |
||
Line 224: | Line 224: | ||
// Show the arrays of the whole tree. |
// Show the arrays of the whole tree. |
||
//root.tmap(x => writefln("%(%.2f %)", x)); |
//root.tmap(x => writefln("%(%.2f %)", x)); |
||
root.tmap((ref |
root.tmap((ref x) => writefln("%(%.2f %)", x)); |
||
// Modify the arrays of the whole tree. |
// Modify the arrays of the whole tree. |
||
//root.tmap((x){ x[] += 10; }); |
//root.tmap((x){ x[] += 10; }); |
||
root.tmap((ref |
root.tmap((ref x){ x[] += 10; }); |
||
// Show the arrays of the whole tree again. |
// Show the arrays of the whole tree again. |
||
writeln(); |
writeln(); |
||
//root.tmap(x => writefln("%(%.2f %)", x)); |
//root.tmap(x => writefln("%(%.2f %)", x)); |
||
root.tmap((ref |
root.tmap((ref x) => writefln("%(%.2f %)", x)); |
||
}</lang> |
}</lang> |
||
{{out}} |
{{out}} |