<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Clojure on SCMB XYZ</title>
    <link>https://www.scmb.xyz/tags/clojure/</link>
    <description>Recent content in Clojure on SCMB XYZ</description>
    <generator>Hugo</generator>
    <language>en-gb</language>
    <copyright>&amp;copy; Seamus Bradley 2021–6</copyright>
    <lastBuildDate>Fri, 02 Feb 2024 16:34:03 +0000</lastBuildDate>
    <atom:link href="https://www.scmb.xyz/tags/clojure/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Haskellbrain: Week 3 of 48 in 24</title>
      <link>https://www.scmb.xyz/post/week-3-exercism/</link>
      <pubDate>Fri, 02 Feb 2024 16:34:03 +0000</pubDate>
      <guid>https://www.scmb.xyz/post/week-3-exercism/</guid>
      <description>&lt;p&gt;Well, I&amp;rsquo;m quite late with this week&amp;rsquo;s challenges.&#xA;Again, I was only going for the silver medal of doing any three languages,&#xA;but I didn&amp;rsquo;t have a lot of time to spare for the challenges last week,&#xA;and I also spent more time than I should have tweaking my haskell solution in particular.&lt;/p&gt;&#xA;&lt;p&gt;This week&amp;rsquo;s &lt;a href=&#34;https://exercism.org/exercises/raindrops&#34;&gt;exercise&lt;/a&gt; is fizzbuzz, but slightly different.&lt;/p&gt;&#xA;&lt;h1 id=&#34;javascript&#34;&gt;JavaScript&lt;/h1&gt;&#xA;&lt;p&gt;First up, here&amp;rsquo;s my javascript solution.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-javascript&#34; data-lang=&#34;javascript&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;convert&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;num&lt;/span&gt;) =&amp;gt; {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;s&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;  [[&lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Pling&amp;#34;&lt;/span&gt;], [&lt;span style=&#34;color:#ae81ff&#34;&gt;5&lt;/span&gt;,&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Plang&amp;#34;&lt;/span&gt;], [&lt;span style=&#34;color:#ae81ff&#34;&gt;7&lt;/span&gt;,&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Plong&amp;#34;&lt;/span&gt;]]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      .&lt;span style=&#34;color:#a6e22e&#34;&gt;map&lt;/span&gt;(([&lt;span style=&#34;color:#a6e22e&#34;&gt;x&lt;/span&gt;,&lt;span style=&#34;color:#a6e22e&#34;&gt;y&lt;/span&gt;]) =&amp;gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;num&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;%&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;x&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;===&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;?&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;y&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      .&lt;span style=&#34;color:#a6e22e&#34;&gt;join&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;s&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;===&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;?&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;num&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;toString&lt;/span&gt;() &lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;s&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;};&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The basic idea is to take a list of pairs (a divisor and a string)&#xA;and map that pair to the string if $n$ is divisible by the divisor,&#xA;or map to the empty string otherwise.&#xA;We then join those strings together.&#xA;The final wrinkle is to check if the string we have left over is is still empty,&#xA;and if it is, return the number as a string, rather than the resultant string.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Indiana Jonesing: Week 2 of 48 in 24</title>
      <link>https://www.scmb.xyz/post/week-2-exercism/</link>
      <pubDate>Sat, 27 Jan 2024 13:48:11 +0000</pubDate>
      <guid>https://www.scmb.xyz/post/week-2-exercism/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://exercism.org/exercises/reverse-string&#34;&gt;This week&amp;rsquo;s challenge&lt;/a&gt;&#xA;was to reverse a string.&#xA;And I took the &amp;ldquo;Indiana Jones when that guy waves the sword around and Indy just shoots him&amp;rdquo;&#xA;approach this week and got the silver medal using three languages that make this exercise a one-liner.&lt;/p&gt;&#xA;&lt;h1 id=&#34;clojure&#34;&gt;Clojure&lt;/h1&gt;&#xA;&lt;p&gt;First up, Clojure:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-clojure&#34; data-lang=&#34;clojure&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;ns &lt;/span&gt;reverse-string)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;defn &lt;/span&gt;reverse-string [s] &lt;span style=&#34;color:#75715e&#34;&gt;;; &amp;lt;- arglist goes here&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#a6e22e&#34;&gt;clojure.string/reverse&lt;/span&gt; s)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1 id=&#34;haskell&#34;&gt;Haskell&lt;/h1&gt;&#xA;&lt;p&gt;Next Haskell:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-haskell&#34; data-lang=&#34;haskell&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;module&lt;/span&gt; ReverseString (&lt;span style=&#34;color:#a6e22e&#34;&gt;reverseString&lt;/span&gt;) &lt;span style=&#34;color:#66d9ef&#34;&gt;where&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;reverseString&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;::&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;String&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;-&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;String&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;reverseString&lt;/span&gt; str &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; reverse str&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1 id=&#34;javascript&#34;&gt;JavaScript&lt;/h1&gt;&#xA;&lt;p&gt;And finally, Javascript.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Starting off easy: Week 1 of 48 in 24</title>
      <link>https://www.scmb.xyz/post/week-1-exercism/</link>
      <pubDate>Tue, 23 Jan 2024 21:19:25 +0000</pubDate>
      <guid>https://www.scmb.xyz/post/week-1-exercism/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://www.exercism.org&#34;&gt;Exercism&lt;/a&gt; &amp;ndash; one of my favourite &amp;ldquo;learn to code&amp;rdquo; websites &amp;ndash;&#xA;is doing a thing where each week (ish?) there is a new challenge to solve a coding exercise in several languages.&#xA;It&amp;rsquo;s called &amp;ldquo;&lt;a href=&#34;https://exercism.org/challenges/48in24&#34;&gt;48 in 24&lt;/a&gt;&amp;rdquo;.&#xA;It looks like you get a bronze medal if you solve the coding exercise in some language,&#xA;a silver medal if you solve it in three specific languages,&#xA;and a gold medal if you solve it in any three languages in 2024.&#xA;We&amp;rsquo;ll see how long this lasts, but I&amp;rsquo;m going to try to blog about my attempts to solve the exercise.&#xA;To be clear, these are my attempts to solve the exercise, likely often in languages I&amp;rsquo;m not that familiar&#xA;with, so the solutions might not be optimal or idiomatic.&#xA;I&amp;rsquo;m also not going to explain every key word and language construct I use,&#xA;I&amp;rsquo;ll only explain those things that I think you might not be able to guess by looking at the code.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
