|
<!-- Front of card =========================================================== |
|
|
|
Simple Card Data |
|
|
|
- Type: |
|
What's the answer? |
|
A simple question->answer card; |
|
we're asking the question: "what does this code do?", e.g: |
|
|
|
- A function with an output you have to guess. |
|
- A class with a method that you need to call. |
|
|
|
- Docs: |
|
http://tinyurl.com/anki-simple-card |
|
|
|
- Key: |
|
★ Required |
|
☆ Optional (recommended) |
|
✎ Optional (notes, markdown) |
|
⤷ Field Type |
|
|
|
========================================================================== --> |
|
<!-- ------------------------------------------------------------------------- |
|
★ Title |
|
|
|
⤷ `string` (auto wrapped with a `H1` tag) |
|
-------------------------------------------------------------------------- --> |
|
<h1>In this example, <code>viewThumbnail</code> only takes one argument; |
|
<code>model.selectedUrl</code>. Yet, it still works! Explain why.</h1> |
|
<!-- ------------------------------------------------------------------------- |
|
★ Subtitle |
|
|
|
⤷ `string` (auto wrapped with a `H2` tag) |
|
-------------------------------------------------------------------------- --> |
|
<h2>A partial function</h2> |
|
<!-- ------------------------------------------------------------------------- |
|
☆ Syntax (inline code) |
|
|
|
⤷ `code string` (auto wrapped with <p><code> tag) |
|
-------------------------------------------------------------------------- --> |
|
<p>Already wrapped in a <code><p><code></code> tag. A one |
|
liner: Some very short text for syntax.</p> |
|
<!-- ------------------------------------------------------------------------- |
|
★ Sample (code block or image) |
|
|
|
⤷ `pre block | image` |
|
|
|
| Requires `markdown` fenced code block; |
|
|
|
A markdown fenced code block that will compile to our highlighted |
|
code with Pandoc. What does this code do? |
|
-------------------------------------------------------------------------- --> |
|
<div class="sourceCode" id="cb1"><pre |
|
class="sourceCode elm"><code class="sourceCode elm"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="op">..</span></span> |
|
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a></span> |
|
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="co">-- View --</span></span> |
|
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="fu">view</span> <span class="fu">model</span> <span class="op">=</span></span> |
|
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a> <span class="op">..</span></span> |
|
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a> <span class="op">..</span></span> |
|
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a> <span class="op">,</span> <span class="fu">div</span> [ <span class="fu">id</span> <span class="st">"thumbnails"</span> ]</span> |
|
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a> (<span class="dt">List</span><span class="op">.</span><span class="fu">map</span></span> |
|
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a> (<span class="fu">viewThumbnail</span> <span class="fu">model</span><span class="op">.</span><span class="fu">selectedUrl</span>) <span class="co">-- Apply the function</span></span> |
|
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">model</span><span class="op">.</span><span class="fu">photos</span></span> |
|
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a> )</span> |
|
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a> <span class="op">..</span></span></code></pre></div> |
|
<!-- Back of card ======================================================== --> |
|
<!-- ------------------------------------------------------------------------- |
|
★ Key point (code block or image) |
|
|
|
⤷ `pre block | image` |
|
|
|
| Requires `markdown` fenced code block; |
|
|
|
A markdown fenced code block that will compile to our highlighted |
|
code with Pandoc. The output or answer to the above question. |
|
-------------------------------------------------------------------------- --> |
|
<div class="sourceCode" id="cb2"><pre |
|
class="sourceCode elm"><code class="sourceCode elm"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="fu">viewThumbnail</span> <span class="fu">selectedUrl</span> <span class="fu">thumb</span> <span class="op">=</span></span> |
|
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">img</span> [ <span class="fu">src</span> (<span class="fu">urlPrefix</span> <span class="op">++</span> <span class="fu">thumb</span><span class="op">.</span><span class="fu">url</span>)</span> |
|
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a> <span class="op">,</span> <span class="fu">classList</span> [ (<span class="st">"selected"</span><span class="op">,</span> <span class="fu">selectedUrl</span> <span class="op">==</span> <span class="fu">thumb</span><span class="op">.</span><span class="fu">url</span>) ]</span> |
|
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a> <span class="op">..</span></span> |
|
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a> ] []</span></code></pre></div> |
|
<!-- ------------------------------------------------------------------------- |
|
★ Key point notes |
|
|
|
⤷ `rich html` |
|
-------------------------------------------------------------------------- --> |
|
<p>This is a big chunk of code!!! It’s quite simple though:</p> |
|
<ol type="1"> |
|
<li>We <em>partially</em> apply <code>viewThumbnail</code> passing only |
|
one argument (a <code>"string"</code>)</li> |
|
<li><code>List.map</code> takes a function and a list |
|
<ul> |
|
<li><code>model.photos</code> gives us a list of records</li> |
|
</ul></li> |
|
<li><code>List.map</code> cycles through the records</li> |
|
</ol> |
|
<!-- ------------------------------------------------------------------------- |
|
★ Other notes |
|
|
|
⤷ `rich html` |
|
-------------------------------------------------------------------------- --> |
|
<p>View the <a href="https://ellie-app.com/q4j6ps87Cj5a1">full |
|
program</a> which consumes the function. Here’s some <a |
|
href="https://www.codingexercises.com/guides/quickstart-elm-part-7">other |
|
curried function examples</a> too.</p> |
|
<!-- ------------------------------------------------------------------------- |
|
★ Markdown |
|
|
|
⤷ `raw text` |
|
|
|
Do not add the compiled HTML to your card, rather, use the raw text |
|
Markdown fenced code block. This makes for easier editing of a card |
|
later on. |
|
|
|
Warning: may increase card file size |
|
@ https://github.com/badlydrawnrob/anki/issues/116 |
|
-------------------------------------------------------------------------- --> |
|
<div class="sourceCode" id="cb3"><pre |
|
class="sourceCode elm"><code class="sourceCode elm"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="op">..</span></span> |
|
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a></span> |
|
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="co">-- View --</span></span> |
|
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="fu">view</span> <span class="fu">model</span> <span class="op">=</span></span> |
|
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> <span class="op">..</span></span> |
|
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a> <span class="op">..</span></span> |
|
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a> <span class="op">,</span> <span class="fu">div</span> [ <span class="fu">id</span> <span class="st">"thumbnails"</span> ]</span> |
|
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a> (<span class="dt">List</span><span class="op">.</span><span class="fu">map</span></span> |
|
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a> (<span class="fu">viewThumbnail</span> <span class="fu">model</span><span class="op">.</span><span class="fu">selectedUrl</span>) <span class="co">-- Apply the function</span></span> |
|
<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">model</span><span class="op">.</span><span class="fu">photos</span></span> |
|
<span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a> )</span> |
|
<span id="cb3-12"><a href="#cb3-12" aria-hidden="true" tabindex="-1"></a> <span class="op">..</span></span></code></pre></div> |