packages feed

highlighting-kate-0.6.3: tests/abc.d.html

<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><style type="text/css">div.sourceCode { overflow-x: auto; }
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
  margin: 0; padding: 0; vertical-align: baseline; border: none; }
table.sourceCode { width: 100%; line-height: 100%; }
td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
td.sourceCode { padding-left: 5px; }
code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
code > span.dt { color: #902000; } /* DataType */
code > span.dv { color: #40a070; } /* DecVal */
code > span.bn { color: #40a070; } /* BaseN */
code > span.fl { color: #40a070; } /* Float */
code > span.ch { color: #4070a0; } /* Char */
code > span.st { color: #4070a0; } /* String */
code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
code > span.ot { color: #007020; } /* Other */
code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
code > span.fu { color: #06287e; } /* Function */
code > span.er { color: #ff0000; font-weight: bold; } /* Error */
code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
code > span.cn { color: #880000; } /* Constant */
code > span.sc { color: #4070a0; } /* SpecialChar */
code > span.vs { color: #4070a0; } /* VerbatimString */
code > span.ss { color: #bb6688; } /* SpecialString */
code > span.im { } /* Import */
code > span.va { color: #19177c; } /* Variable */
code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code > span.op { color: #666666; } /* Operator */
code > span.bu { } /* BuiltIn */
code > span.ex { } /* Extension */
code > span.pp { color: #bc7a00; } /* Preprocessor */
code > span.at { color: #7d9029; } /* Attribute */
code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
</style></head><body><div class="sourceCode"><pre class="sourceCode"><code class="sourceCode"><span class="kw" title="KeywordTok">import</span> std.stdio, std.ascii, std.algorithm, std.array, std.range;

<span class="kw" title="KeywordTok">alias</span> Block = <span class="dt" title="DataTypeTok">char</span>[<span class="dv" title="DecValTok">2</span>];

<span class="dt" title="DataTypeTok">bool</span> canMakeWord(<span class="kw" title="KeywordTok">immutable</span> Block[] blocks, <span class="kw" title="KeywordTok">in</span> <span class="bu" title="BuiltInTok">string</span> word) <span class="kw" title="KeywordTok">pure</span> <span class="kw" title="KeywordTok">nothrow</span>
<span class="kw" title="KeywordTok">in </span>{
    <span class="kw" title="KeywordTok">assert</span>(blocks.all!(w =&gt; w[].all!isAlpha));
    <span class="kw" title="KeywordTok">assert</span>(word.all!isAlpha);
} <span class="kw" title="KeywordTok">body</span> {
    <span class="dt" title="DataTypeTok">bool</span> inner(<span class="bu" title="BuiltInTok">size_t</span>[] indexes, <span class="kw" title="KeywordTok">in</span> <span class="bu" title="BuiltInTok">string</span> w) <span class="kw" title="KeywordTok">pure</span> <span class="kw" title="KeywordTok">nothrow</span> {
        <span class="kw" title="KeywordTok">if</span> (w.empty)
            <span class="kw" title="KeywordTok">return</span> <span class="kw" title="KeywordTok">true</span>;

        <span class="kw" title="KeywordTok">immutable</span> c = w[<span class="dv" title="DecValTok">0</span>].toUpper;
        <span class="kw" title="KeywordTok">foreach</span> (<span class="kw" title="KeywordTok">ref</span> idx; indexes) {
            <span class="kw" title="KeywordTok">if</span> (blocks[idx][<span class="dv" title="DecValTok">0</span>].toUpper != c &amp;&amp;
                blocks[idx][<span class="dv" title="DecValTok">1</span>].toUpper != c)
                <span class="kw" title="KeywordTok">continue</span>;
            indexes[<span class="dv" title="DecValTok">0</span>].swap(idx);
            <span class="kw" title="KeywordTok">if</span> (inner(indexes[<span class="dv" title="DecValTok">1</span> .. $], w[<span class="dv" title="DecValTok">1</span> .. $]))
                <span class="kw" title="KeywordTok">return</span> <span class="kw" title="KeywordTok">true</span>;
            indexes[<span class="dv" title="DecValTok">0</span>].swap(idx);
        }

        <span class="kw" title="KeywordTok">return</span> <span class="kw" title="KeywordTok">false</span>;
    }

    <span class="kw" title="KeywordTok">return</span> inner(blocks.<span class="dt" title="DataTypeTok">length</span>.iota.array, word);
}

<span class="dt" title="DataTypeTok">void</span> main() {
    <span class="kw" title="KeywordTok">enum</span> Block[] blocks = <span class="st" title="StringTok">&quot;BO XK DQ CP NA GT RE TG QD FS</span>
<span class="st" title="StringTok">                           JW HU VI AN OB ER FS LY PC ZM&quot;</span>.split;

    <span class="kw" title="KeywordTok">foreach</span> (w; <span class="st" title="StringTok">&quot;&quot;</span> ~ <span class="st" title="StringTok">&quot;A BARK BoOK TrEAT COmMoN SQUAD conFUsE&quot;</span>.split)
        writefln(<span class="ss" title="SpecialStringTok">`&quot;%s&quot; %s`</span>, w, blocks.canMakeWord(w));

    <span class="co" title="CommentTok">// Extra test.</span>
    <span class="kw" title="KeywordTok">immutable</span> Block[] blocks2 = [<span class="st" title="StringTok">&quot;AB&quot;</span>, <span class="st" title="StringTok">&quot;AB&quot;</span>, <span class="st" title="StringTok">&quot;AC&quot;</span>, <span class="st" title="StringTok">&quot;AC&quot;</span>];
    <span class="kw" title="KeywordTok">immutable</span> word = <span class="st" title="StringTok">&quot;abba&quot;</span>;
    writefln(<span class="ss" title="SpecialStringTok">`&quot;%s&quot; %s`</span>, word, blocks2.canMakeWord(word));
}</code></pre></div></body>