snipt

Ctrl+h for KB shortcuts

Clojure

clojure leiningen lambda repl

1
2
3
 :repl-options {
  :init-ns reagent-example.repl
  :prompt #(str "[" %1 "] λ => ")}
https://snipt.net/embed/20c01e441ca836c20d12aa1f8b0016f1/
/raw/20c01e441ca836c20d12aa1f8b0016f1/
20c01e441ca836c20d12aa1f8b0016f1
clojure
Clojure
3
2019-05-07T03:54:28
True
False
False
Feb 25, 2016 at 11:50 AM
/api/public/snipt/139568/
clojure-leiningen-lambda-repl-dba5c1cd
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a> <span class="ss">:repl-options</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="ss">:init-ns</span> <span class="nv">reagent-example.repl</span> </span><span id="L-3"><a name="L-3"></a> <span class="ss">:prompt</span> <span class="o">#</span><span class="p">(</span><span class="nb">str </span><span class="s">&quot;[&quot;</span> <span class="nv">%1</span> <span class="s">&quot;] λ =&gt; &quot;</span><span class="p">)}</span> </span></pre></div> </td></tr></table>
clojure, leiningen, repl

Clojure

Clojure in-circle?

1
2
3
4
5
6
7
8
(defn in-circle? [point width]
  (let [mid (/ width 2)
        r mid
        dx (- (point :x) mid)
        dy (- (point :y) mid)]
    (<= (+ (* dx dx)
               (* dy dy))
            (* r r))))
https://snipt.net/embed/689a286c99b06e3dcd6880711c6e4e64/
/raw/689a286c99b06e3dcd6880711c6e4e64/
689a286c99b06e3dcd6880711c6e4e64
clojure
Clojure
8
2019-05-19T16:55:49
True
False
False
/api/public/snipt/53204/
clojure-in-circle
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="p">(</span><span class="kd">defn </span><span class="nv">in-circle?</span> <span class="p">[</span><span class="nv">point</span> <span class="nv">width</span><span class="p">]</span> </span><span id="L-2"><a name="L-2"></a> <span class="p">(</span><span class="k">let </span><span class="p">[</span><span class="nv">mid</span> <span class="p">(</span><span class="nb">/ </span><span class="nv">width</span> <span class="mi">2</span><span class="p">)</span> </span><span id="L-3"><a name="L-3"></a> <span class="nv">r</span> <span class="nv">mid</span> </span><span id="L-4"><a name="L-4"></a> <span class="nv">dx</span> <span class="p">(</span><span class="nb">- </span><span class="p">(</span><span class="nf">point</span> <span class="ss">:x</span><span class="p">)</span> <span class="nv">mid</span><span class="p">)</span> </span><span id="L-5"><a name="L-5"></a> <span class="nv">dy</span> <span class="p">(</span><span class="nb">- </span><span class="p">(</span><span class="nf">point</span> <span class="ss">:y</span><span class="p">)</span> <span class="nv">mid</span><span class="p">)]</span> </span><span id="L-6"><a name="L-6"></a> <span class="p">(</span><span class="nb">&lt;= </span><span class="p">(</span><span class="nb">+ </span><span class="p">(</span><span class="nb">* </span><span class="nv">dx</span> <span class="nv">dx</span><span class="p">)</span> </span><span id="L-7"><a name="L-7"></a> <span class="p">(</span><span class="nb">* </span><span class="nv">dy</span> <span class="nv">dy</span><span class="p">))</span> </span><span id="L-8"><a name="L-8"></a> <span class="p">(</span><span class="nb">* </span><span class="nv">r</span> <span class="nv">r</span><span class="p">))))</span> </span></pre></div> </td></tr></table>
clojure