<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<link href="https://propenster.github.io/feed.xml" rel="self" type="application/atom+xml"/>
<link href="https://propenster.github.io" rel="alternate" type="text/html"/>
<updated>2025-10-04T02:44:44.981Z</updated>
<id>https://propenster.github.io/feed.xml</id>
<title type="html">propenster</title>
<subtitle>portfolio plus programming blog by Faith Olusegun aka propenster.</subtitle>
<author><name>Faith Olusegun</name></author>

<entry>
<title type="text">Life Updates: 2 Years in 2 Minutes</title>
<link href="https://propenster.github.io/2025/06/19/resurgence-2-years-in-2-minutes.html" rel="alternate" type="text/html" title="Life Updates: 2 Years in 2 Minutes" />
<published>2025-06-19T00:00:00+00:00</published>
<updated>2025-06-19T00:00:00+00:00</updated>
<id>https://propenster.github.io/2025/06/19/resurgence-2-years-in-2-minutes</id>
<author><name>Faith Olusegun</name></author>
<summary type="html"><![CDATA[It's been a minute—okay, two years—since I last posted. Here's the TL;DR of what's new:]]></summary>
<content type="html" xml:base="https://propenster.github.io/2025/06/19/resurgence-2-years-in-2-minutes.html"><![CDATA[
    <h1>
    <a href="#Life-Updates-2-Years-in-2-Minutes"><span>Life Updates: 2 Years in 2 Minutes</span> <time datetime="2025-06-19">Jun 19, 2025</time></a>
    </h1>
<p><span>It</span>&rsquo;<span>s been a minute—okay, </span><strong><strong><span>two years</span></strong></strong><span>—since I last posted. Here</span>&rsquo;<span>s the TL;DR of what</span>&rsquo;<span>s new:</span></p>
<hr>
<section id="Academic-Upgrade">

    <h3>
    <a href="#Academic-Upgrade"><span>🎓 Academic Upgrade</span> </a>
    </h3>
<p><strong><strong><span>Late 2024:</span></strong></strong><span> Swapped late-night coding sessions for late-night study sessions. Started a Master</span>&rsquo;<span>s in </span><strong><strong><span>Bioinformatics and Computational Biology</span></strong></strong><span>—because why choose between genes and Java when you can have them both?</span><br>
</p>
<hr>
</section>
<section id="Family-Glow-Up">

    <h2>
    <a href="#Family-Glow-Up"><span>👨‍👩‍👧 Family Glow-Up</span> </a>
    </h2>
<p><span>Got married. Had a </span><strong><strong><span>tiny human</span></strong></strong><span> (now a sweet little 1-year-old).  </span>
<strong><span>Pro tip:</span></strong><span> Baby giggles &gt; compiler errors.</span></p>
<hr>
</section>
<section id="Career-Wins">

    <h2>
    <a href="#Career-Wins"><span>💼 Career Wins</span> </a>
    </h2>
<ul>
<li>
<strong><strong><span>2024 Promotion:</span></strong></strong><span> Joined </span><strong><strong><a href="https://www.interswitchgroup.com"><span>Interswitch</span></a></strong></strong><span> (Africa</span>&rsquo;<span>s largest Payment Gateway &amp; FinTech aggregator) as a </span><strong><strong><span>Senior Software Engineer</span></strong></strong><span>. Built systems that power millions of transactions—because money should move faster than my toddler.</span>
</li>
<li>
<strong><strong><span>Mentorship Boom:</span></strong></strong><span> Launched a coding mentorship program in Lagos. It</span>&rsquo;<span>s now </span><strong><strong><span>bigger than my impostor syndrome</span></strong></strong><span>.</span>
</li>
</ul>
<hr>
</section>
<section id="Projects-Papers">

    <h2>
    <a href="#Projects-Papers"><span>🛠 Projects &amp; Papers</span> </a>
    </h2>
<ul>
<li>
<strong><strong><span>VealFramework:</span></strong></strong><span> My web dev framework is now </span><strong><strong><span>fully loaded</span></strong></strong><span>—like a dev stack with extra bacon.</span>
</li>
<li>
<strong><strong><span>Research:</span></strong></strong><span> Co-authored papers (pending publication). </span><strong><span>Spoiler:</span></strong><span> They involve </span><strong><strong><span>both</span></strong></strong><span> code and so much math.</span>
</li>
</ul>
<hr>
</section>
<section id="Verdict">

    <h2>
    <a href="#Verdict"><span>🌟 Verdict</span> </a>
    </h2>
<p><span>Life</span>&rsquo;<span>s chaotic, but the algorithm is </span><strong><strong><span>algorithming</span></strong></strong><span>. Grateful.</span></p>
</section>
]]></content>
</entry>

<entry>
<title type="text">Writing an interpreter from scratch in C# - towards creating your own scripting language</title>
<link href="https://propenster.github.io/2023/12/25/writing-an-interpreter-from-scratch-in-csharp-towards-creating-your-own-scripting-language.html" rel="alternate" type="text/html" title="Writing an interpreter from scratch in C# - towards creating your own scripting language" />
<published>2023-12-25T00:00:00+00:00</published>
<updated>2023-12-25T00:00:00+00:00</updated>
<id>https://propenster.github.io/2023/12/25/writing-an-interpreter-from-scratch-in-csharp-towards-creating-your-own-scripting-language</id>
<author><name>Faith Olusegun</name></author>
<summary type="html"><![CDATA[Since I started learning how to program with BASIC about 8 years ago, I have been fascinated by compilers, interpreters and how a source code gets turned into a program. You know my curiosity is piqued by how a source code gets converted into instructions for the computer and a lot of things that happen under the hood when I compile either my C# or Rust source files. You would not believe what I have learnt in just 1 year.]]></summary>
<content type="html" xml:base="https://propenster.github.io/2023/12/25/writing-an-interpreter-from-scratch-in-csharp-towards-creating-your-own-scripting-language.html"><![CDATA[
    <h1>
    <a href="#Writing-an-interpreter-from-scratch-in-C-towards-creating-your-own-scripting-language"><span>Writing an interpreter from scratch in C# - towards creating your own scripting language</span> <time datetime="2023-12-25">Dec 25, 2023</time></a>
    </h1>

<figure>

<img alt="functions in topscript" src="/assets/topScript.png">
</figure>
<p><span>Since I started learning how to program with BASIC about 8 years ago, I have been fascinated by compilers, interpreters and how a source code gets turned into a program. You know my curiosity is piqued by how a source code gets converted into instructions for the computer and a lot of things that happen under the hood when I compile either my C# or Rust source files. You would not believe what I have learnt in just 1 year.</span></p>
<p><span>Let me take you back to where this new-found interest started, so about a year ago, I picked interested in parsers and compilers reading books like Thorsten Ball</span>&rsquo;<span>s interpreter book and going through a lot of comp sci texts on lexical analysis, compilation, parsing and AST</span>&rsquo;<span>s (abstract syntax trees). Honourable mention is San Jose University with some amazing online lecture materials on parsing (using scala and other languages).</span></p>
<p><span>This knowledge culminated in me playing around with lexers, writing basic parsers for a database language in rust, a mini c compiler which I call </span><a href="https://github.com/propenster/llcc94"><span>llcc94</span></a><span>. But now, I thought it</span>&rsquo;<span>s time I got on something serious to sum up the knowledge gained so far on parsing, interpretation and compilation and language design, I said to myself let</span>&rsquo;<span>s make some compiler or interpreter of some sort.</span></p>
<p><span>Last week, I started working on a new scripting language and I decided to use C# to make it, note that this is like 2 weeks after I had done a youtube tutorial on </span><a href="https://www.youtube.com/watch?v=mAYgIPCc1vs"><span>How to make a superfast JSON parser from scratch in C#</span></a><span> see the video on my </span><a href="https://youtube.com/c/FaithOlusegun"><span>YouTube channel</span></a><span>.</span></p>
<section id="3-basic-components-of-an-interpreter">

    <h2>
    <a href="#3-basic-components-of-an-interpreter"><span>3 basic components of an interpreter</span> </a>
    </h2>
<p><span>To build an interpreter, there are three main components that are involved. They include:</span></p>
<p><strong><strong><span>1. The Lexer</span></strong></strong>
<strong><strong><span>2. The Parser</span></strong></strong>
<strong><strong><span>3. The Interpreter</span></strong></strong></p>
<p><span>Let</span>&rsquo;<span>s now explore each of these components and their respective roles in interpretation.</span></p>
<section id="The-Lexer">

    <h3>
    <a href="#The-Lexer"><span>The Lexer</span> </a>
    </h3>
<p><span>The lexer is the first part of any compilation or interpretation unit, the lexer takes our input source text and converts them into a sequence of tokens.</span></p>
<p><span>Our lexer class is implemented in C# and it takes a string of our source text and creates a sequence of Token object which is a record having two properties - a kind (an enum of TokenKind) and a literal (actual string of the token);</span></p>
<p><span>Consider an example where we have a source like below</span></p>

<figure class="code-block">


<pre><code><span class="line">1 + 2 * 3</span></code></pre>

</figure>
<p><span>Our lexer (provided whitespaces are ignored) breaks this input into tokens below</span></p>

<figure class="code-block">


<pre><code><span class="line">1 =&gt; NumberToken</span>
<span class="line"></span>
<span class="line">\+ =&gt; PlusToken</span>
<span class="line"></span>
<span class="line">2 =&gt; NumberToken</span>
<span class="line"></span>
<span class="line">\* =&gt; StarToken or MultiplyToken</span>
<span class="line"></span>
<span class="line">3 =&gt; NumberToken</span></code></pre>

</figure>
<p><span>This is the only responsibility of the lexer and it</span>&rsquo;<span>s the first stage of interpretation or compiling.</span></p>
</section>
<section id="The-Parser">

    <h3>
    <a href="#The-Parser"><span>The Parser</span> </a>
    </h3>
<p><span>The parser is fundamental in interpretation in that it takes the sequence of tokens generated or emitted by the lexer and produces an abstract syntax tree (AST) of a language. This is of course achieved by a specific set rules or grammar defined by the language specification.</span></p>
</section>
<section id="The-Interpreter">

    <h3>
    <a href="#The-Interpreter"><span>The Interpreter</span> </a>
    </h3>
<p><span>In our case where we are making an interpreted programming language instead of a compiled one, we have the third component - an interpreter. An interpreter interpretes the AST produced by the parser on the fly without compilation. This means the huge tree of expressions emitted from the parser are each evaluated one after another.</span></p>
<p><span>I hope to make a follow-up post diving deep into our C# implementation of this interpreted language called TopScript. I know, the name is cringe(ish) but come on, anything to sound like JavaScript or TypeScript nowadays, it</span>&rsquo;<span>s good for business.</span></p>
<p><span>You may find the implementation on my github </span><a href="https://github.com/propenster/topscript"><span>here</span></a></p>
</section>
</section>
]]></content>
</entry>

<entry>
<title type="text">Simple local sequence alignment search tool with dynamic programming in C</title>
<link href="https://propenster.github.io/2023/12/02/simple-local-sequence-alignment-search-tool-with-dynamic-programming-in-c.html" rel="alternate" type="text/html" title="Simple local sequence alignment search tool with dynamic programming in C" />
<published>2023-12-02T00:00:00+00:00</published>
<updated>2023-12-02T00:00:00+00:00</updated>
<id>https://propenster.github.io/2023/12/02/simple-local-sequence-alignment-search-tool-with-dynamic-programming-in-c</id>
<author><name>Faith Olusegun</name></author>
<summary type="html"><![CDATA[Sequence alignment is fundamental to bioinformatics. In fact, one of the common tasks of a bioinformatician or an omics researcher is sequence alignemnt.]]></summary>
<content type="html" xml:base="https://propenster.github.io/2023/12/02/simple-local-sequence-alignment-search-tool-with-dynamic-programming-in-c.html"><![CDATA[
    <h1>
    <a href="#Simple-local-sequence-alignment-search-tool-with-dynamic-programming-in-C"><span>Simple local sequence alignment search tool with dynamic programming in C</span> <time datetime="2023-12-02">Dec 2, 2023</time></a>
    </h1>
<section id="Simple-Local-Sequence-Alignment-Search-Tool-SLAST">

    <h3>
    <a href="#Simple-Local-Sequence-Alignment-Search-Tool-SLAST"><span>Simple Local Sequence Alignment Search Tool (SLAST).</span> </a>
    </h3>
<p><span>Sequence alignment is fundamental to bioinformatics. In fact, one of the common tasks of a bioinformatician or an omics researcher is sequence alignemnt.</span></p>
<p><span>Sequence alignment is used to identify similarities, homology, and functional relationships between proteins or genes in different organisms or species. By comparing sequences, we can infer evolutionary relationships and gain insights into the structure and function of biological molecules.</span></p>
<p><span>During sequence alignment, the aim is to achieve the highest similarity score. Keep in mind that sequence alignment can have multiple correct solutions, and the outcome may vary based on the specific implementation and scoring parameters.</span></p>
<p><span>I developed a C program for local sequence alignment using dynamic programming to find the optimal alignment.</span></p>
<p><span>This program, called SLAST (Simple Local Alignment Search Tool), generates aligned sequences via dynamic programming. Keep in mind that this is just a simple implementation and does not include the sophisticated heuristics and optimizations of more sophisticated alignment tools like BLAST used in the bioinformatics and genomics community. A full BLAST implementation involves additional complexities such as seeding and extending, filtering, statistical analysis, and database searching.</span></p>
<p><span>SLAST uses a dynamic programming 2-dimensional matrix that stores intermediate scores obtained during the computation of optimal alignments between two sequences. You can call it our scoring matrix. You can find the code on my github here - </span><a href="https://github.com/propenster/slast"><span>https://github.com/propenster/slast</span></a></p>
<p><span>See the code sections below:</span></p>
<p><strong><strong><span>Header - slast.h</span></strong></strong></p>

<figure class="code-block">


<pre><code><span class="line"></span>
<span class="line"><span class="hl-comment">/****************************************************************************</span></span>
<span class="line"><span class="hl-comment">* Filename: slast.h</span></span>
<span class="line"><span class="hl-comment">* Original Author: Faith E. Olusegun (propenster)</span></span>
<span class="line"><span class="hl-comment">* File Creation Date: December 2nd, 2023</span></span>
<span class="line"><span class="hl-comment">* Description: SLAST functions, definitions  - header</span></span>
<span class="line"><span class="hl-comment">* LICENSE: MIT</span></span>
<span class="line"><span class="hl-comment">*************************************************************************************/</span></span>
<span class="line"></span>
<span class="line"><span class="hl-meta">#<span class="hl-keyword">pragma</span> once</span></span>
<span class="line"><span class="hl-meta">#<span class="hl-keyword">ifndef</span> SLAST_H</span></span>
<span class="line"></span>
<span class="line"><span class="hl-meta">#<span class="hl-keyword">define</span> SLAST_H</span></span>
<span class="line"></span>
<span class="line"><span class="hl-comment">/// this could be customized</span></span>
<span class="line"><span class="hl-meta">#<span class="hl-keyword">define</span> MATCH_SCORE 2</span></span>
<span class="line"><span class="hl-meta">#<span class="hl-keyword">define</span> MISMATCH_SCORE -1</span></span>
<span class="line"><span class="hl-meta">#<span class="hl-keyword">define</span> GAP_PENALTY -1</span></span>
<span class="line"></span>
<span class="line"><span class="hl-type">int</span> <span class="hl-title function_">max_of</span><span class="hl-params">(<span class="hl-type">int</span> a, <span class="hl-type">int</span> b, <span class="hl-type">int</span> c)</span>;</span>
<span class="line"></span>
<span class="line"><span class="hl-type">int</span> <span class="hl-title function_">calculateScore</span><span class="hl-params">(<span class="hl-type">char</span> a, <span class="hl-type">char</span> b)</span>;</span>
<span class="line"><span class="hl-type">void</span> <span class="hl-title function_">simpleLocalAlignment</span><span class="hl-params">(<span class="hl-type">char</span>* seq1, <span class="hl-type">char</span>* seq2)</span>;</span>
<span class="line"></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span class="hl-meta">#<span class="hl-keyword">endif</span> <span class="hl-comment">//SLAST_H#pragma once</span></span></span></code></pre>

</figure>
<p><strong><strong><span>Core SLAST Implementation - slast.c</span></strong></strong></p>

<figure class="code-block">


<pre><code><span class="line"><span class="hl-comment">/****************************************************************************</span></span>
<span class="line"><span class="hl-comment">* Filename: slast.c</span></span>
<span class="line"><span class="hl-comment">* Original Author: Faith E. Olusegun (propenster)</span></span>
<span class="line"><span class="hl-comment">* File Creation Date: December 2nd, 2023</span></span>
<span class="line"><span class="hl-comment">* Description: SLAST functions, definitions and implementation details</span></span>
<span class="line"><span class="hl-comment">* LICENSE: MIT</span></span>
<span class="line"><span class="hl-comment">*************************************************************************************/</span></span>
<span class="line"></span>
<span class="line"><span class="hl-meta">#<span class="hl-keyword">include</span> <span class="hl-string">&lt;stdio.h&gt;</span></span></span>
<span class="line"><span class="hl-meta">#<span class="hl-keyword">include</span> <span class="hl-string">&lt;stdlib.h&gt;</span></span></span>
<span class="line"><span class="hl-meta">#<span class="hl-keyword">include</span> <span class="hl-string">&lt;string.h&gt;</span></span></span>
<span class="line"><span class="hl-meta">#<span class="hl-keyword">include</span> <span class="hl-string">&quot;slast.h&quot;</span></span></span>
<span class="line"></span>
<span class="line"><span class="hl-comment">/// @brief </span></span>
<span class="line"><span class="hl-comment">/// @param a - </span></span>
<span class="line"><span class="hl-comment">/// @param b </span></span>
<span class="line"><span class="hl-comment">/// @param c </span></span>
<span class="line"><span class="hl-comment">/// @return </span></span>
<span class="line"><span class="hl-comment">///</span></span>
<span class="line"><span class="hl-type">int</span> <span class="hl-title function_">max_of</span><span class="hl-params">(<span class="hl-type">int</span> a, <span class="hl-type">int</span> b, <span class="hl-type">int</span> c)</span> {</span>
<span class="line">    <span class="hl-type">int</span> max_of_ab = (a &gt; b) ? a : b;</span>
<span class="line">    <span class="hl-keyword">return</span> (max_of_ab &gt; c) ? max_of_ab : c;</span>
<span class="line">}</span>
<span class="line"></span>
<span class="line"><span class="hl-comment">/// @brief calculates match/alignment Score</span></span>
<span class="line"><span class="hl-comment">/// @param a first nucleotide (a) to be compared to another (b)</span></span>
<span class="line"><span class="hl-comment">/// @param b second nucleotide (b) to be compared with a</span></span>
<span class="line"><span class="hl-comment">/// @return match or mismatch score</span></span>
<span class="line"><span class="hl-type">int</span> <span class="hl-title function_">calculateScore</span><span class="hl-params">(<span class="hl-type">char</span> a, <span class="hl-type">char</span> b)</span> {</span>
<span class="line">    <span class="hl-keyword">return</span> (a == b) ? MATCH_SCORE : MISMATCH_SCORE;</span>
<span class="line">}</span>
<span class="line"></span>
<span class="line"><span class="hl-comment">/// @brief performs the local alignment</span></span>
<span class="line"><span class="hl-comment">/// @param seq1 sequence 1</span></span>
<span class="line"><span class="hl-comment">/// @param seq2 sequence 2 or reference sequence</span></span>
<span class="line"><span class="hl-type">void</span> <span class="hl-title function_">simpleLocalAlignment</span><span class="hl-params">(<span class="hl-type">char</span>* seq1, <span class="hl-type">char</span>* seq2)</span> {</span>
<span class="line">    <span class="hl-type">size_t</span> len1 = <span class="hl-built_in">strlen</span>(seq1);</span>
<span class="line">    <span class="hl-type">size_t</span> len2 = <span class="hl-built_in">strlen</span>(seq2);</span>
<span class="line">    <span class="hl-comment">//create our dp matrix and allocate memory for it...</span></span>
<span class="line">    <span class="hl-comment">//we will use it to store scores as we compute</span></span>
<span class="line">    <span class="hl-type">int</span>** dp = (<span class="hl-type">int</span>**)<span class="hl-built_in">malloc</span>((len1 + <span class="hl-number">1</span>) * <span class="hl-keyword">sizeof</span>(<span class="hl-type">int</span>*));</span>
<span class="line">    <span class="hl-keyword">for</span> (<span class="hl-type">size_t</span> i = <span class="hl-number">0</span>; i &lt; len1; ++i) {</span>
<span class="line">        dp[i] = (<span class="hl-type">int</span>*)<span class="hl-built_in">malloc</span>((len2 + <span class="hl-number">1</span>) * <span class="hl-keyword">sizeof</span>(<span class="hl-type">int</span>));</span>
<span class="line">    }</span>
<span class="line"></span>
<span class="line">    <span class="hl-type">int</span> maxScore = <span class="hl-number">0</span>;</span>
<span class="line">    <span class="hl-type">int</span> endRow, endCol = <span class="hl-number">0</span>;</span>
<span class="line"></span>
<span class="line">    <span class="hl-comment">//init alignment matrix</span></span>
<span class="line">    <span class="hl-keyword">for</span> (<span class="hl-type">size_t</span> row = <span class="hl-number">0</span>; row &lt; len1; ++row) {</span>
<span class="line">        <span class="hl-keyword">for</span> (<span class="hl-type">size_t</span> col = <span class="hl-number">0</span>; col &lt; len2; ++col) {</span>
<span class="line">            <span class="hl-keyword">if</span> (row == <span class="hl-number">0</span> || col == <span class="hl-number">0</span>) {</span>
<span class="line">                </span>
<span class="line">                <span class="hl-keyword">if</span> (row &lt;= len1 &amp;&amp; col &lt;= len2) {</span>
<span class="line">                    dp[row][col] = <span class="hl-number">0</span>;</span>
<span class="line">                }</span>
<span class="line">                <span class="hl-keyword">else</span> {</span>
<span class="line">                    <span class="hl-keyword">return</span> <span class="hl-number">1</span>;</span>
<span class="line">                }</span>
<span class="line">            }</span>
<span class="line">            <span class="hl-keyword">else</span> {</span>
<span class="line">                <span class="hl-type">int</span> match = dp[row - <span class="hl-number">1</span>][col - <span class="hl-number">1</span>] + calculateScore(seq1[row - <span class="hl-number">1</span>], seq2[col - <span class="hl-number">1</span>]);</span>
<span class="line">                <span class="hl-type">int</span> delete = dp[row - <span class="hl-number">1</span>][col] + GAP_PENALTY;</span>
<span class="line">                <span class="hl-type">int</span> insert = dp[row][col - <span class="hl-number">1</span>] + GAP_PENALTY;</span>
<span class="line">                dp[row][col] = max(match, delete, insert);</span>
<span class="line"></span>
<span class="line">                <span class="hl-keyword">if</span> (dp[row][col] &gt; maxScore) {</span>
<span class="line">                    maxScore = dp[row][col];</span>
<span class="line">                    endRow = row;</span>
<span class="line">                    endCol = col;</span>
<span class="line">                }</span>
<span class="line">            }</span>
<span class="line">        }</span>
<span class="line">    }</span>
<span class="line"></span>
<span class="line">    <span class="hl-comment">//find &amp;&amp; print new alignment</span></span>
<span class="line">    <span class="hl-type">int</span> i = endRow;</span>
<span class="line">    <span class="hl-type">int</span> j = endCol;</span>
<span class="line">    <span class="hl-keyword">while</span> (i &gt; <span class="hl-number">0</span> &amp;&amp; j &gt; <span class="hl-number">0</span> &amp;&amp; dp[i][j] != <span class="hl-number">0</span>) {</span>
<span class="line">        <span class="hl-type">int</span> score = dp[i][j];</span>
<span class="line">        <span class="hl-type">int</span> diagonal = dp[i - <span class="hl-number">1</span>][j - <span class="hl-number">1</span>];</span>
<span class="line">        <span class="hl-type">int</span> left = dp[i][j - <span class="hl-number">1</span>];</span>
<span class="line">        <span class="hl-type">int</span> up = dp[i - <span class="hl-number">1</span>][j];</span>
<span class="line"></span>
<span class="line">        <span class="hl-keyword">if</span> (score == diagonal + calculateScore(seq1[i - <span class="hl-number">1</span>], seq2[j - <span class="hl-number">1</span>])) {</span>
<span class="line">            <span class="hl-built_in">printf</span>(<span class="hl-string">&quot;%c&quot;</span>, seq1[i - <span class="hl-number">1</span>]);</span>
<span class="line">            i--;</span>
<span class="line">            j--;</span>
<span class="line">        }</span>
<span class="line">        <span class="hl-keyword">else</span> <span class="hl-keyword">if</span> (score == up + GAP_PENALTY) {</span>
<span class="line">            <span class="hl-built_in">printf</span>(<span class="hl-string">&quot;-&quot;</span>); <span class="hl-comment">//</span></span>
<span class="line">            i--;</span>
<span class="line">        }</span>
<span class="line">        <span class="hl-keyword">else</span> {</span>
<span class="line">            <span class="hl-built_in">printf</span>(<span class="hl-string">&quot;-&quot;</span>);</span>
<span class="line">            j--;</span>
<span class="line">        }</span>
<span class="line"></span>
<span class="line">    }</span>
<span class="line"></span>
<span class="line">    <span class="hl-comment">//free</span></span>
<span class="line">    <span class="hl-keyword">for</span> (<span class="hl-type">size_t</span> i = <span class="hl-number">0</span>; i &lt; len1; ++i) {</span>
<span class="line">        <span class="hl-built_in">free</span>(dp[i]);</span>
<span class="line">    }</span>
<span class="line"></span>
<span class="line">    <span class="hl-built_in">free</span>(dp);</span>
<span class="line"></span>
<span class="line"></span>
<span class="line">}</span></code></pre>

</figure>
<p><strong><strong><span>Entry module - main.c</span></strong></strong></p>

<figure class="code-block">


<pre><code><span class="line"></span>
<span class="line"><span class="hl-comment">/****************************************************************************</span></span>
<span class="line"><span class="hl-comment">* Filename: main.c</span></span>
<span class="line"><span class="hl-comment">* Original Author: Faith E. Olusegun (propenster)</span></span>
<span class="line"><span class="hl-comment">* File Creation Date: December 2nd, 2023</span></span>
<span class="line"><span class="hl-comment">* Description: Entry to SLAST Dynamic programming-based sequence alignment algorithm</span></span>
<span class="line"><span class="hl-comment">* LICENSE: MIT</span></span>
<span class="line"><span class="hl-comment">*************************************************************************************/</span></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span class="hl-meta">#<span class="hl-keyword">include</span> <span class="hl-string">&lt;stdio.h&gt;</span></span></span>
<span class="line"><span class="hl-meta">#<span class="hl-keyword">include</span> <span class="hl-string">&quot;slast.h&quot;</span></span></span>
<span class="line"></span>
<span class="line"><span class="hl-type">int</span> <span class="hl-title function_">main</span><span class="hl-params">(<span class="hl-type">int</span> argc, <span class="hl-type">char</span> <span class="hl-type">const</span>* argv[])</span></span>
<span class="line">{</span>
<span class="line">    <span class="hl-built_in">printf</span>(<span class="hl-string">&quot;Welcome to SLAST (Simple Local Alignment Search Tool in C\n&quot;</span>);</span>
<span class="line"></span>
<span class="line">    <span class="hl-type">char</span> seq1[] = <span class="hl-string">&quot;ACTCCGAT&quot;</span>;</span>
<span class="line">    <span class="hl-type">char</span> seq2[] = <span class="hl-string">&quot;GCTAAGAT&quot;</span>;</span>
<span class="line"></span>
<span class="line">    <span class="hl-built_in">printf</span>(<span class="hl-string">&quot;Sequence 1 to be aligned: %s\n&quot;</span>, seq1);</span>
<span class="line">    <span class="hl-built_in">printf</span>(<span class="hl-string">&quot;Sequence 1 to be aligned: %s\n&quot;</span>, seq2);</span>
<span class="line"></span>
<span class="line">    <span class="hl-built_in">printf</span>(<span class="hl-string">&quot;Alignment: \n&quot;</span>);</span>
<span class="line"></span>
<span class="line">    simpleLocalAlignment(seq1, seq2);</span>
<span class="line"></span>
<span class="line">    <span class="hl-keyword">return</span> <span class="hl-number">0</span>;</span>
<span class="line">}</span></code></pre>

</figure>
<p><span>So that is it, thank you for staying with me through this.</span></p>
<p><span>Till next time,</span>
<span>propenster</span></p>
</section>
]]></content>
</entry>

<entry>
<title type="text">Power Enums Option type but for csharp</title>
<link href="https://propenster.github.io/2023/11/22/power-enums-option-type-but-for-csharp.html" rel="alternate" type="text/html" title="Power Enums Option type but for csharp" />
<published>2023-11-22T00:00:00+00:00</published>
<updated>2023-11-22T00:00:00+00:00</updated>
<id>https://propenster.github.io/2023/11/22/power-enums-option-type-but-for-csharp</id>
<author><name>Faith Olusegun</name></author>
<summary type="html"><![CDATA[Let's talk about PowerEnums. A new C# library that I started cooking yesterday.]]></summary>
<content type="html" xml:base="https://propenster.github.io/2023/11/22/power-enums-option-type-but-for-csharp.html"><![CDATA[
    <h1>
    <a href="#Power-Enums-Option-type-but-for-csharp"><span>Power Enums Option type but for csharp</span> <time datetime="2023-11-22">Nov 22, 2023</time></a>
    </h1>
<p><span>Let</span>&rsquo;<span>s talk about </span><a href="https://github.com/propenster/powerenums"><span>PowerEnums</span></a><span>. A new C# library that I started cooking yesterday.</span></p>
<p><span>It</span>&rsquo;<span>s been over a year since I started writing Rust and I found it an intriguing language. Besides the promises of top-notch performance and fearless concurrency, I also found rust to be an easy-to-learn systems language for me. This is coming from me who had a bit of flirt with C while in the university.</span></p>
<p><span>One of rust</span>&rsquo;<span>s main selling point for me is how clear and easy the type system is. You have a straightforward type system, generics, pattern matching (which I love so much) and traits. All of these I was able to learn in a bit of time and the ease at which I was able to pick up rust was surprising to me. </span>
<span>Rust for me is just like python but with extra invincibility of systems languages like C and C++. It</span>&rsquo;<span>s almost as powerful (if not as powerful) as C and C++ and it has plain old english-like syntax like python. Oh and rust</span>&rsquo;<span>s getting into both the windows and linux kernel already which is a W for me.</span></p>
<p><span>Now to the main theme of this article, Option enum type in rust is an enum type in the rust standard library that gives us the idea of optional values. That is, value types can be seen in a basis of whether they are present or absent - present as in Some(T) or absent as in None. </span>
<span>This is in fact rust</span>&rsquo;<span>s intuitive way of prevent Null-Reference exceptions and allied problems in contrast to C# which I have been used to and written for over 7 years already. This means that Option in C# would make us have less of </span>&lsquo;<span>ObjectReferenceException: Object Reference Not Set to An Instance of an Object</span>&rsquo;<span> - every C# developer has probably seen this countless number of times.</span></p>
<p><span>In Rust, an Option&lt;T&gt; defines an optional type in which the enclosed generic type could be any data type from primitives to reference types. The Option&lt;T&gt; type in rust could be matched with pattern machine to create more elegant control flow. </span>
<span>It can be combined with other constructs like If-Let, Match and While let all of which allow for destructuring of the optional into Some(T).</span></p>
<p><span>See below:</span></p>
<p><strong><strong><span>With match expression</span></strong></strong></p>

<figure class="code-block">


<pre><code><span class="line"><span class="hl-comment">// Make `optional` of type `Option&lt;i32&gt;`</span></span>
<span class="line"><span class="hl-keyword">let</span> <span class="hl-variable">optional</span> = <span class="hl-title function_ invoke__">Some</span>(<span class="hl-number">7</span>);</span>
<span class="line"></span>
<span class="line"><span class="hl-keyword">match</span> optional {</span>
<span class="line">    <span class="hl-title function_ invoke__">Some</span>(i) =&gt; { <span class="hl-comment">//see the declare 7 i32 destructed into i</span></span>
<span class="line">        <span class="hl-built_in">println!</span>(<span class="hl-string">&quot;This is a really long string and `{:?}`&quot;</span>, i);</span>
<span class="line">    },</span>
<span class="line">    _ =&gt; {},</span>
<span class="line">};</span></code></pre>

</figure>
<p><strong><strong><span>With if-let</span></strong></strong></p>

<figure class="code-block">


<pre><code><span class="line"><span class="hl-keyword">let</span> <span class="hl-variable">number</span> = <span class="hl-title function_ invoke__">Some</span>(<span class="hl-number">7</span>);</span>
<span class="line"></span>
<span class="line"><span class="hl-comment">// The `if let` construct reads: &quot;if `let` destructures `number` into</span></span>
<span class="line"><span class="hl-comment">// `Some(i)`, evaluate the block (`{}`).</span></span>
<span class="line"><span class="hl-keyword">if</span> <span class="hl-keyword">let</span> <span class="hl-variable">Some</span>(i) = number {</span>
<span class="line">    <span class="hl-built_in">println!</span>(<span class="hl-string">&quot;Matched {:?}!&quot;</span>, i);</span>
<span class="line">}</span>
<span class="line"></span>
<span class="line"><span class="hl-comment">//or</span></span>
<span class="line"><span class="hl-keyword">if</span> <span class="hl-keyword">let</span> <span class="hl-variable">Some</span>(i) = number{</span>
<span class="line">    <span class="hl-built_in">println!</span>(<span class="hl-string">&quot;Retrieved destructured number i32 successfully!&quot;</span>);</span>
<span class="line">}<span class="hl-keyword">else</span>{</span>
<span class="line">    <span class="hl-built_in">println!</span>(<span class="hl-string">&quot;number destructure failed. number is not present&quot;</span>);</span>
<span class="line">}</span></code></pre>

</figure>
<p><strong><strong><span>With while-let</span></strong></strong></p>

<figure class="code-block">


<pre><code><span class="line"><span class="hl-comment">// Make `optional` of type `Option&lt;i32&gt;`</span></span>
<span class="line"><span class="hl-keyword">let</span> <span class="hl-keyword">mut </span><span class="hl-variable">optional</span> = <span class="hl-title function_ invoke__">Some</span>(<span class="hl-number">0</span>);</span>
<span class="line"></span>
<span class="line"><span class="hl-comment">// This reads: &quot;while `let` destructures `optional` into</span></span>
<span class="line"><span class="hl-comment">// `Some(i)`, evaluate the block (`{}`). Else `break`.</span></span>
<span class="line"><span class="hl-keyword">while</span> <span class="hl-keyword">let</span> <span class="hl-variable">Some</span>(i) = optional {</span>
<span class="line">    <span class="hl-keyword">if</span> i &gt; <span class="hl-number">9</span> {</span>
<span class="line">        <span class="hl-built_in">println!</span>(<span class="hl-string">&quot;Greater than 9, quit!&quot;</span>);</span>
<span class="line">        optional = <span class="hl-literal">None</span>;</span>
<span class="line">    } <span class="hl-keyword">else</span> {</span>
<span class="line">        <span class="hl-built_in">println!</span>(<span class="hl-string">&quot;`i` is `{:?}`. Try again.&quot;</span>, i);</span>
<span class="line">        optional = <span class="hl-title function_ invoke__">Some</span>(i + <span class="hl-number">1</span>);</span>
<span class="line">    }</span>
<span class="line">}</span></code></pre>

</figure>
<section id="C-implementation">

    <h3>
    <a href="#C-implementation"><span>C# implementation</span> </a>
    </h3>
<p><span>The C# implementation that I</span>&rsquo;<span>ve just made is quite similar, we have an Option&lt;T&gt; type which can enclose the value of interest into either of a Some(T) or None(T).</span>
<span>I call it PowerEnums and it</span>&rsquo;<span>s already published to nuget.org as a .NET C# library.</span></p>
<p><span>See the code references below:</span></p>
<p><strong><strong><span>Simple Option - Some&lt;T&gt;</span></strong></strong></p>

<figure class="code-block">


<pre><code><span class="line"><span class="hl-built_in">int</span> <span class="hl-keyword">value</span> = <span class="hl-number">50</span>;</span>
<span class="line"><span class="hl-keyword">var</span> option = <span class="hl-keyword">new</span> Some&lt;<span class="hl-built_in">int</span>&gt;(<span class="hl-keyword">value</span>);</span>
<span class="line">Console.WriteLine(option?.ValueOrDefault());</span>
<span class="line"></span>
<span class="line">Assert.Equal(<span class="hl-keyword">value</span>, option?.ValueOrDefault());</span>
<span class="line">Assert.NotNull(option);</span>
<span class="line">Assert.IsType&lt;Some&lt;<span class="hl-built_in">int</span>&gt;&gt;(option);</span>
<span class="line">Assert.IsType&lt;<span class="hl-built_in">int</span>&gt;(option?.ValueOrDefault());</span></code></pre>

</figure>
<p><strong><strong><span>Simple Option - None&lt;T&gt;</span></strong></strong></p>

<figure class="code-block">


<pre><code><span class="line"><span class="hl-keyword">var</span> noneReturningOption = <span class="hl-keyword">new</span> None&lt;<span class="hl-built_in">int</span>&gt;();</span>
<span class="line">Assert.NotNull(noneReturningOption);</span>
<span class="line">Assert.Equal(<span class="hl-number">0</span>, noneReturningOption?.ValueOrDefault());</span>
<span class="line">Assert.Equal(<span class="hl-number">0</span>, noneReturningOption?.Value);</span>
<span class="line">Assert.Equal(<span class="hl-literal">false</span>, noneReturningOption?.IsSome());</span>
<span class="line">Assert.Equal(<span class="hl-literal">true</span>, noneReturningOption?.IsNone());</span>
<span class="line">Assert.IsType&lt;None&lt;<span class="hl-built_in">int</span>&gt;&gt;(noneReturningOption);</span>
<span class="line"><span class="hl-comment">//it doesn&#x27;t lose it&#x27;s enclosed primitive type though it still came as None</span></span>
<span class="line">Assert.IsType&lt;<span class="hl-built_in">int</span>&gt;(noneReturningOption?.ValueOrDefault()); </span>
<span class="line">Assert.IsAssignableFrom&lt;<span class="hl-built_in">int</span>&gt;(noneReturningOption?.ValueOrDefault());</span></code></pre>

</figure>
<p><strong><strong><span>Option-returning methods Option&lt;T&gt;</span></strong></strong></p>

<figure class="code-block">


<pre><code><span class="line"><span class="hl-function"><span class="hl-keyword">private</span> <span class="hl-keyword">static</span> Option&lt;<span class="hl-built_in">decimal</span>&gt; <span class="hl-title">DecimalReturningOptionMethod</span>()</span></span>
<span class="line">{</span>
<span class="line"><span class="hl-built_in">decimal</span> d = <span class="hl-built_in">decimal</span>.MaxValue;</span>
<span class="line"><span class="hl-keyword">return</span> <span class="hl-keyword">new</span> Some&lt;<span class="hl-built_in">decimal</span>&gt;(d);</span>
<span class="line">}</span>
<span class="line"></span>
<span class="line"><span class="hl-function"><span class="hl-keyword">private</span> Option&lt;Person&gt; <span class="hl-title">GetPerson_Some_Or_None</span>()</span></span>
<span class="line">{</span>
<span class="line"><span class="hl-keyword">var</span> person = <span class="hl-keyword">new</span> Person { Name = <span class="hl-string">&quot;Willelm Rudenmalm&quot;</span>, Age = <span class="hl-number">28</span> };</span>
<span class="line"><span class="hl-keyword">return</span> <span class="hl-keyword">new</span> Some&lt;Person&gt;(person) ?? <span class="hl-keyword">new</span> None&lt;Person&gt;();</span>
<span class="line">}</span></code></pre>

</figure>
<p><strong><strong><span>Option&lt;T&gt;().ValueOrError() with error message</span></strong></strong></p>

<figure class="code-block">


<pre><code><span class="line"><span class="hl-keyword">var</span> option = <span class="hl-keyword">new</span> None&lt;<span class="hl-built_in">int</span>&gt;();</span>
<span class="line">Assert.Throws&lt;Exception&gt;(() =&gt; option.ValueOrError(<span class="hl-string">&quot;Error could not retrieve item , item is null or default&quot;</span>));</span></code></pre>

</figure>
<p><strong><strong><span>Option&lt;T&gt;().ValueOrError() with error callback</span></strong></strong></p>

<figure class="code-block">


<pre><code><span class="line"><span class="hl-keyword">var</span> option = <span class="hl-keyword">new</span> None&lt;<span class="hl-built_in">int</span>&gt;();</span>
<span class="line">Assert.Throws&lt;MyCustomException&gt;(() =&gt; option.ValueOrError(() =&gt; <span class="hl-keyword">throw</span> <span class="hl-keyword">new</span> MyCustomException(<span class="hl-string">&quot;Error could not find item&quot;</span>)));</span></code></pre>

</figure>
<p><strong><strong><span>Check IsSome() or IsNone()</span></strong></strong></p>

<figure class="code-block">


<pre><code><span class="line"><span class="hl-keyword">var</span> option = <span class="hl-keyword">new</span> Some&lt;<span class="hl-built_in">double</span>&gt;(<span class="hl-number">2.58</span>);</span>
<span class="line"><span class="hl-keyword">if</span>(option.IsSome()){</span>
<span class="line">Console.WriteLine(<span class="hl-string">$&quot;Option is Some and it&#x27;s value is <span class="hl-subst">{option.ValueOrDefault()}</span>&quot;</span>);</span>
<span class="line"><span class="hl-comment">//OR destroy everything.</span></span>
<span class="line"><span class="hl-comment">//without saying, this throws a bomb (an Exception) if option is None&lt;T&gt;</span></span>
<span class="line"><span class="hl-keyword">var</span> valueOrMakeAMess = option.ValueOrError(<span class="hl-string">&quot;This double is supposed to be here now I&#x27;m going to have to throw an exception&quot;</span>); </span>
<span class="line"><span class="hl-comment">//OR pass an Exception callback with your own customer Exception</span></span>
<span class="line"><span class="hl-comment">//without saying, this throws a bomb (a YourMessyCustomException) if option is None&lt;T&gt;</span></span>
<span class="line"><span class="hl-keyword">var</span> valueOrMakeAMess = option.ValueOrError(() =&gt; <span class="hl-keyword">throw</span> <span class="hl-keyword">new</span> YourMessyCustomException(<span class="hl-string">&quot;You must never not have this double&quot;</span>)); </span>
<span class="line">}<span class="hl-keyword">else</span>{</span>
<span class="line">Console.WriteLine(<span class="hl-string">&quot;Option is None&quot;</span>);</span>
<span class="line">}</span></code></pre>

</figure>
</section>
]]></content>
</entry>

<entry>
<title type="text">In the beginning</title>
<link href="https://propenster.github.io/2023/11/13/in-the-beginning.html" rel="alternate" type="text/html" title="In the beginning" />
<published>2023-11-13T00:00:00+00:00</published>
<updated>2023-11-13T00:00:00+00:00</updated>
<id>https://propenster.github.io/2023/11/13/in-the-beginning</id>
<author><name>Faith Olusegun</name></author>
<summary type="html"><![CDATA[This is where it all starts...]]></summary>
<content type="html" xml:base="https://propenster.github.io/2023/11/13/in-the-beginning.html"><![CDATA[
    <h1>
    <a href="#In-the-beginning"><span>In the beginning</span> <time datetime="2023-11-13">Nov 13, 2023</time></a>
    </h1>
<p><span>This is where it all starts</span>&hellip;</p>
<p><span>git clone matklad</span>&rsquo;<span>s personal blog https://github.com/matklad/matklad.github.io well because he</span>&rsquo;<span>s one of my rust programmer </span>
<span>inspiration and because it has open license</span></p>
]]></content>
</entry>

</feed>
