<!doctype html>

<html lang="en">

<head>
	<meta name="generator" content="Hugo 0.143.1">
  <title>Mailund on the Internet</title>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <meta name="description" content="The HTML5 Herald" />
  <meta name="author" content="" />
  

  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css" />

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />

<link rel="stylesheet" type="text/css" href="https://mailund.dk/css/styles.css" />
<link rel="stylesheet" href="https://cdn.rawgit.com/tonsky/FiraCode/1.205/distr/fira_code.css">

 
       <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Droid Sans" type="text/css" media="all" />
     
       <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Fira Mono" type="text/css" media="all" />
     

 <style>
 body {
     font-family: 'Droid Sans';
 }
 code {
    font-family: 'Fira Code';
 }
 </style>

 <script type="text/javascript" async
   src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
   MathJax.Hub.Queue(function() {
     
     
     
     var all = MathJax.Hub.getAllJax(), i;
     for(i = 0; i < all.length; i += 1) {
         all[i].SourceElement().parentNode.className += ' has-jax';
     }
   });

   MathJax.Hub.Config({
   
   TeX: { equationNumbers: { autoNumber: "AMS" } }
   });
   MathJax.Hub.Config({
   tex2jax: {
     inlineMath: [['$$','$$'], ['\\(','\\)']],
     displayMath: [['$$$','$$$']],
     processEscapes: true,
     processEnvironments: true,
     skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
     TeX: { equationNumbers: { autoNumber: "AMS" },
          extensions: ["AMSmath.js", "AMSsymbols.js"] }
   }
   });
 </script>

      <script async src="https://www.googletagmanager.com/gtag/js?id=386493837"></script>
      <script>
        var doNotTrack = false;
        if ( false ) {
          var dnt = (navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack);
          var doNotTrack = (dnt == "1" || dnt == "yes");
        }
        if (!doNotTrack) {
          window.dataLayer = window.dataLayer || [];
          function gtag(){dataLayer.push(arguments);}
          gtag('js', new Date());
          gtag('config', '386493837');
        }
      </script>
</head>

<body>
  <div id="container">
    <header>
      <h1>
                <a href="https://mailund.dk/">Mailund on the Internet</a>
            </h1>

      <ul id="social-media">
                
      </ul>
      
      <p><em>On Writing, Science, Programming and more</em></p>
      

    </header>

    
<nav>
    <ul>
        
        <li>
            <a class="" href="https://mailund.dk/about/">
                <i class="fa-li fa  fa-lg"></i><span>About</span>
            </a>
        </li>
        
        <li>
            <a class="" href="https://mailund.dk/posts">
                <i class="fa-li fa  fa-lg"></i><span>Posts</span>
            </a>
        </li>
        
        <li>
            <a class="" href="https://mailund.dk/books/">
                <i class="fa-li fa  fa-lg"></i><span>Books</span>
            </a>
        </li>
        
        <li>
            <a class="" href="https://mailund.dk/fiction/">
                <i class="fa-li fa  fa-lg"></i><span>Fiction</span>
            </a>
        </li>
        
        <li>
            <a class="" href="https://mailund.dk/publications/">
                <i class="fa-li fa  fa-lg"></i><span>Publications</span>
            </a>
        </li>
        
        <li>
            <a class="" href="https://mailund.dk/software/">
                <i class="fa-li fa  fa-lg"></i><span>Software</span>
            </a>
        </li>
        
    </ul>
</nav>

    <main>




<section id="home">
        <ul>
          
          <li class="first">
            <h1><a href="https://mailund.dk/posts/old-places/" title="Old Places">Old Places</a></h1> 
            <aside>
    <ul>
        <li>
            <time class="post-date" datetime="2025-03-06T14:31:28&#43;01:00">Mar 6, 2025</time>
        </li>
        
        
        <li>
            Categories: 
            <em>
                
                    
                    <a href="https://mailund.dk/categories/writing/">Writing</a>
                
            </em>
        </li>
        

        

        <li>15 min read</li>
    </ul>
</aside>
            <p><p><em>It is not easy writing like Neil Gaiman, and I certainly cannot. There is a certain rhythm to his prose that you don’t fully notice until you read it aloud. He has a way of blending the magical and the mundane and the childish and the deeply serious and having it all make sense, although he rarely explains a thing.</em></p></p>
            
            <a href="https://mailund.dk/posts/old-places/">Read more&hellip;</a>
            
          </li>
          
          <li >
            <h1><a href="https://mailund.dk/posts/scala-lists/" title="Scala Lists, Eager and Lazy">Scala Lists, Eager and Lazy</a></h1> 
            <aside>
    <ul>
        <li>
            <time class="post-date" datetime="2025-02-19T06:22:14&#43;01:00">Feb 19, 2025</time>
        </li>
        
        
        <li>
            Categories: 
            <em>
                
                    
                    <a href="https://mailund.dk/categories/programming/">Programming</a>
                
            </em>
        </li>
        

        
        <li>
            <em>
                
                    
                    <a href="https://mailund.dk/tags/scala/">#Scala</a>
                
                    , 
                    <a href="https://mailund.dk/tags/functional-programming/">#Functional Programming</a>
                
            </em>
        </li>
        

        <li>4 min read</li>
    </ul>
</aside>
            <p><p>So, I returned to looking at Scala. I wanted to implement two types of lists: a regular linked list and a lazy list (i.e., a list where you don’t evaluate the tail before you need it). Both are already available in Scala, but I’m solely doing this for educational purposes.</p></p>
            
            <a href="https://mailund.dk/posts/scala-lists/">Read more&hellip;</a>
            
          </li>
          
          <li >
            <h1><a href="https://mailund.dk/posts/kmp-implementations/" title="KMP Implementations">KMP Implementations</a></h1> 
            <aside>
    <ul>
        <li>
            <time class="post-date" datetime="2025-02-17T17:56:54&#43;01:00">Feb 17, 2025</time>
        </li>
        
        
        <li>
            Categories: 
            <em>
                
                    
                    <a href="https://mailund.dk/categories/programming/">Programming</a>
                
                    , 
                    <a href="https://mailund.dk/categories/algorithms/">Algorithms</a>
                
            </em>
        </li>
        

        
        <li>
            <em>
                
                    
                    <a href="https://mailund.dk/tags/c/">#C</a>
                
                    , 
                    <a href="https://mailund.dk/tags/rust/">#Rust</a>
                
                    , 
                    <a href="https://mailund.dk/tags/go/">#Go</a>
                
                    , 
                    <a href="https://mailund.dk/tags/python/">#Python</a>
                
            </em>
        </li>
        

        <li>11 min read</li>
    </ul>
</aside>
            <p><p>Following on my <a href="https://mailund.dk/posts/some-simple-string-search-implementations/">previous post</a> I set out to implement the Knuth-Morris-Pratt algorithm.</p>
<p>This algorithm shifts the pattern <code>p</code> along <code>x</code>, exploiting the structure in <code>p</code> to skip positions we know cannot match. To do this, it uses a so-called <em>border array</em> that we need to pre-compute.</p></p>
            
            <a href="https://mailund.dk/posts/kmp-implementations/">Read more&hellip;</a>
            
          </li>
          
          <li >
            <h1><a href="https://mailund.dk/posts/some-simple-string-search-implementations/" title="Simple String Search Implementations">Simple String Search Implementations</a></h1> 
            <aside>
    <ul>
        <li>
            <time class="post-date" datetime="2025-02-16T06:39:39&#43;01:00">Feb 16, 2025</time>
        </li>
        
        
        <li>
            Categories: 
            <em>
                
                    
                    <a href="https://mailund.dk/categories/programming/">Programming</a>
                
                    , 
                    <a href="https://mailund.dk/categories/algorithms/">Algorithms</a>
                
            </em>
        </li>
        

        
        <li>
            <em>
                
                    
                    <a href="https://mailund.dk/tags/c/">#C</a>
                
                    , 
                    <a href="https://mailund.dk/tags/rust/">#Rust</a>
                
                    , 
                    <a href="https://mailund.dk/tags/go/">#Go</a>
                
                    , 
                    <a href="https://mailund.dk/tags/python/">#Python</a>
                
            </em>
        </li>
        

        <li>19 min read</li>
    </ul>
</aside>
            <p><p>I’ll get back to playing with Scala soon, but since I don’t know which skills to brush up on, I also decided to play with a few other things.</p>
<p>I have taught string algorithms for over a decade, so I figured that using a few simple algorithms I know very well would be an interesting way to play with how the same goal can be achieved in different languages.</p></p>
            
            <a href="https://mailund.dk/posts/some-simple-string-search-implementations/">Read more&hellip;</a>
            
          </li>
          
          <li >
            <h1><a href="https://mailund.dk/posts/giving-scala-a-go/" title="Giving Scala a Go—Playing with Lists">Giving Scala a Go—Playing with Lists</a></h1> 
            <aside>
    <ul>
        <li>
            <time class="post-date" datetime="2025-02-14T13:19:35&#43;01:00">Feb 14, 2025</time>
        </li>
        
        
        <li>
            Categories: 
            <em>
                
                    
                    <a href="https://mailund.dk/categories/programming/">Programming</a>
                
            </em>
        </li>
        

        
        <li>
            <em>
                
                    
                    <a href="https://mailund.dk/tags/programming/">#programming</a>
                
                    , 
                    <a href="https://mailund.dk/tags/scala/">#Scala</a>
                
            </em>
        </li>
        

        <li>5 min read</li>
    </ul>
</aside>
            <p><p>Soon, I will be unemployed — the needs of Kvantify and my interests and qualifications have diverged over the last year — so it is time to brush up on my skills, so I look interesting for potential future employer. Since I don’t know what a future employer will be looking for, this mainly means finding something I’m not familiar with but interested in and playing with it. Today, the choice fell on Scala.</p></p>
            
            <a href="https://mailund.dk/posts/giving-scala-a-go/">Read more&hellip;</a>
            
          </li>
          
          <li >
            <h1><a href="https://mailund.dk/posts/prefix-doubling-attemps/" title="Prefix Doubling Attempts">Prefix Doubling Attempts</a></h1> 
            <aside>
    <ul>
        <li>
            <time class="post-date" datetime="2021-11-25T14:08:34&#43;01:00">Nov 25, 2021</time>
        </li>
        
        
        <li>
            Categories: 
            <em>
                
                    
                    <a href="https://mailund.dk/categories/programming/">Programming</a>
                
            </em>
        </li>
        

        
        <li>
            <em>
                
                    
                    <a href="https://mailund.dk/tags/programming/">#programming</a>
                
                    , 
                    <a href="https://mailund.dk/tags/algorithms/">#algorithms</a>
                
                    , 
                    <a href="https://mailund.dk/tags/c/">#C</a>
                
                    , 
                    <a href="https://mailund.dk/tags/python/">#Python</a>
                
            </em>
        </li>
        

        <li>10 min read</li>
    </ul>
</aside>
            <p><p>I&rsquo;ve been working on an algorithm for suffix array construction today. It&rsquo;s called <em>prefix doubling</em>, but I don&rsquo;t have a link, sorry. I think it comes from <a href="https://dl.acm.org/doi/10.1145/800152.804905">this paper</a> but I don&rsquo;t have access to it at home.</p></p>
            
            <a href="https://mailund.dk/posts/prefix-doubling-attemps/">Read more&hellip;</a>
            
          </li>
          
          <li >
            <h1><a href="https://mailund.dk/posts/cps-and-iterators-in-c/" title="CPS and Iterators in C">CPS and Iterators in C</a></h1> 
            <aside>
    <ul>
        <li>
            <time class="post-date" datetime="2021-10-21T04:50:01&#43;02:00">Oct 21, 2021</time>
        </li>
        
        
        <li>
            Categories: 
            <em>
                
                    
                    <a href="https://mailund.dk/categories/programming/">Programming</a>
                
            </em>
        </li>
        

        
        <li>
            <em>
                
                    
                    <a href="https://mailund.dk/tags/programming/">#programming</a>
                
                    , 
                    <a href="https://mailund.dk/tags/c/">#C</a>
                
            </em>
        </li>
        

        <li>47 min read</li>
    </ul>
</aside>
            <p><p>Today, I want to talk about <em>continuation-passing-style</em> (CSP). This is a general approach you can use to translate recursions into tail-calls.</p>
<p>What&rsquo;s tail-calls, I (imagine hearing) you ask?</p>
<p>A <a href="https://en.wikipedia.org/wiki/Tail_call">tail-call</a> is when a function calls another function as the last thing it does. Tail-recursion is when that last call is a recursive call, but that is just a special case of tail-calls.</p></p>
            
            <a href="https://mailund.dk/posts/cps-and-iterators-in-c/">Read more&hellip;</a>
            
          </li>
          
          <li >
            <h1><a href="https://mailund.dk/posts/cstr-slices/" title="C Slices">C Slices</a></h1> 
            <aside>
    <ul>
        <li>
            <time class="post-date" datetime="2021-10-19T04:25:05&#43;02:00">Oct 19, 2021</time>
        </li>
        
        
        <li>
            Categories: 
            <em>
                
                    
                    <a href="https://mailund.dk/categories/programming/">Programming</a>
                
            </em>
        </li>
        

        
        <li>
            <em>
                
                    
                    <a href="https://mailund.dk/tags/programming/">#programming</a>
                
                    , 
                    <a href="https://mailund.dk/tags/c/">#C</a>
                
            </em>
        </li>
        

        <li>23 min read</li>
    </ul>
</aside>
            <p><p>About those slices <a href="https://mailund.dk/posts/macro-metaprogramming/">I mentioned yesterday</a>, here&rsquo;s what&rsquo;s that about.</p>
<p>I&rsquo;m working on some string algorithms and more straightforward C implementations than those I put in <a href="https://amzn.to/3pfzvdd">my book</a>.</p>
<p>I implemented all the algorithms and data structures I use in my string algorithm class in Python and Go in the spring,^[I&rsquo;m toying with the idea of writing string algorithms books for those languages, but I have a long list of writing obligations, so I don&rsquo;t know if that will ever happen.] and I plan to implement them in Rust as soon as I get the time. Still, I&rsquo;m also playing with the idea of reimplementing everything in C in a (perhaps) more accessible form.</p></p>
            
            <a href="https://mailund.dk/posts/cstr-slices/">Read more&hellip;</a>
            
          </li>
          
          <li >
            <h1><a href="https://mailund.dk/posts/macro-metaprogramming/" title="Macro Metaprogramming">Macro Metaprogramming</a></h1> 
            <aside>
    <ul>
        <li>
            <time class="post-date" datetime="2021-10-18T04:43:09&#43;02:00">Oct 18, 2021</time>
        </li>
        
        
        <li>
            Categories: 
            <em>
                
                    
                    <a href="https://mailund.dk/categories/programming/">Programming</a>
                
            </em>
        </li>
        

        
        <li>
            <em>
                
                    
                    <a href="https://mailund.dk/tags/programming/">#programming</a>
                
                    , 
                    <a href="https://mailund.dk/tags/c/">#C</a>
                
            </em>
        </li>
        

        <li>24 min read</li>
    </ul>
</aside>
            <p><p>I&rsquo;ve been working on a small C library for Python- or Go-like slices the last couple of weeks. Essentially arrays, but where I can index from the end using negative numbers (like in Python) and where I can extract a sub-slice, <code>x[i:j]</code>, in constant time (like in Go; I implement them the same way as Go does).</p></p>
            
            <a href="https://mailund.dk/posts/macro-metaprogramming/">Read more&hellip;</a>
            
          </li>
          
          <li >
            <h1><a href="https://mailund.dk/posts/witness-array/" title="&#39;Witness&#39; arrays">&#39;Witness&#39; arrays</a></h1> 
            <aside>
    <ul>
        <li>
            <time class="post-date" datetime="2021-09-15T07:59:33&#43;02:00">Sep 15, 2021</time>
        </li>
        
        
        <li>
            Categories: 
            <em>
                
                    
                    <a href="https://mailund.dk/categories/programming/">Programming</a>
                
            </em>
        </li>
        

        
        <li>
            <em>
                
                    
                    <a href="https://mailund.dk/tags/programming/">#programming</a>
                
                    , 
                    <a href="https://mailund.dk/tags/algorithms/">#algorithms</a>
                
                    , 
                    <a href="https://mailund.dk/tags/c/">#C</a>
                
            </em>
        </li>
        

        <li>6 min read</li>
    </ul>
</aside>
            <p><p>The other day I was reminded of an exercises we got first or second year when I studied computer science. It is a cool little trick, that I&rsquo;ve never seen outside of that exercise, so I thought I&rsquo;d share it.</p></p>
            
            <a href="https://mailund.dk/posts/witness-array/">Read more&hellip;</a>
            
          </li>
          
        </ul>
      </section>



</main>
    <footer>
        <h6>Copyright © 2020-2025 - Thomas Mailund |
            Rendered by <a href="https://gohugo.io" title="Hugo">Hugo</a> |
            <a href="https://mailund.dk/index.xml">Subscribe</a></h6>
    </footer>
</div>
<script src="https://mailund.dk/js/scripts.js"></script>
</body>
<div id="amzn-assoc-ad-04956520-8388-43ab-9b6e-fbe758d208f8"></div>
<script async src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&adInstanceId=04956520-8388-43ab-9b6e-fbe758d208f8"></script>

<script type="text/javascript"
  src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

</html>
