On Friday, 21 October 2016 at 12:31:00 UTC, Mark wrote:
I second that.
Also, it may be a good idea to simply use classical algorithms
(binary search, quicksort, etc.), written in "D style", as
examples. The typical visitor is probably familiar with these
algorithms and thus the foreign syntax won't be as scary. It
also puts the syntax in a context that the visitor is already
familiar with, so there is a good chance that he'll deduce its
meaning even without supplementary comments.
For instance, TDPL has the following implementation of binary
search in its introductory chapter:
bool binarySearch(T)(T[] input, T value) {
while (!input.empty) {
auto i = input.length / 2;
auto mid = input[i];
if (mid > value) input = input[0 .. i];
else if (mid < value) input = input[i + 1 .. $];
else return true;
}
return false;
}
Nothing too fancy, but it's a good example of how array slicing
in D helps make the code cleaner, shorter and easier to
understand.
Yeah, I agree. Use common tasks everybody is familiar with.
Sorting, searching, string handling.