<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Siverv]]></title><description><![CDATA[Thoughts, stories and ideas.]]></description><link>https://svrv.net/</link><image><url>https://svrv.net/favicon.png</url><title>Siverv</title><link>https://svrv.net/</link></image><generator>Ghost 2.9</generator><lastBuildDate>Fri, 08 May 2020 22:38:01 GMT</lastBuildDate><atom:link href="https://svrv.net/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Both function and value]]></title><description><![CDATA[Perhaps my favourite discovery in JavaScript was that functions may have another value when it is evaluated without calling. Manipulating .valueOf or .toString makes for fun but somewhat unreadable code...]]></description><link>https://ghost.siverv.no/both-function-and-value-3/</link><guid isPermaLink="false">Ghost__Post__5eb5ba2327759304370628c0</guid><category><![CDATA[javascript]]></category><dc:creator><![CDATA[Siver K. Volle]]></dc:creator><pubDate>Sun, 31 Aug 2014 19:59:00 GMT</pubDate><content:encoded><![CDATA[<p>Perhaps my favourite discovery in JavaScript was that  functions may have another value when it is evaluated without calling.  Manipulating .valueOf or .toString makes for fun but somewhat unreadable  code. </p><!--kg-card-begin: markdown--><pre><code>function A(){return 3}
A.valueOf = function(){return 2}
console.log(A,A(),A()*A)
</code></pre>
<!--kg-card-end: markdown--><p>This, together with bind, was heavily used in my <a href="http://svrv.net/e/xperiments/Rami/introduction.html">Rami</a> language. Thanks to this duality of function and value, I could easily create a JS evaluator which kept the syntax. <code>mult(add(2)(4)(6))(4)</code>. A kind of polish notation JavaScript.</p>]]></content:encoded></item><item><title><![CDATA[Lambda CalculuJS]]></title><description><![CDATA[I have made a lambda calculus to javascript converter and visualizer. The converter is finished, but the visualizer lacks the polish necessary for me to publish it. Both λ and...]]></description><link>https://ghost.siverv.no/lambda-calculujs/</link><guid isPermaLink="false">Ghost__Post__5eb5ba9227759304370628cd</guid><category><![CDATA[math]]></category><category><![CDATA[javascript]]></category><category><![CDATA[lambda calculus]]></category><dc:creator><![CDATA[Siver K. Volle]]></dc:creator><pubDate>Tue, 19 Aug 2014 20:01:00 GMT</pubDate><content:encoded><![CDATA[<p>I have made a <a href="http://svrv.net/dev/lambda/lambda.html">lambda calculus to javascript converter and visualizer</a>. The converter is finished, but the visualizer lacks the polish necessary for me to publish it.</p><p>Both <code>λ</code> and <code>\</code> works as lambda and short-hand for multiple arguments must be separated with space (eg. <code>\x y. y</code>).  Recursive function with an if-test must use lazy evaluation in order to  work, made possible by wrapping the clauses in a function evaluated on  the outside of the if (eq. <code>if(\_.A)(\_.B)(_)</code>)</p><p>Because the code inludes a lot of pointless fluff, here's a small  standalone evaluator. Beneath is an example. By running, it should  evaluate to 120, the factorial of 5.</p><!--kg-card-begin: markdown--><pre><code>function λCalculus(calculus){
    var nextLambda = calculus.search(/[#λ\\]/)
    if(nextLambda == 0){
        var delim = calculus.search(/[.:]/);
        if(!~delim) throw Error(&quot;Missing body delimiter&quot;);
        var head = calculus.slice(1,delim)  
                           .split(/[^a-zA-Z0-9]+[0-9]*/);
        var body = λCalculus(calculus.slice(delim+1))
        var func = &quot;#2#&quot;
        for(var i in head){
            func = func.replace(/#2#/,
                   &quot;function anonymous(#1#){ return #2#; }&quot;
                   .replace(/#1#/,head[i]));
        }
        return func.replace(/#2#/,body);
    } else if(nextLambda &gt; 0){
        var left = 1;
        var i = nextLambda;
        while(left&gt;0&amp;&amp;++i&lt;calculus.length){
            if(calculus[i] == &quot;(&quot;) left++;
            else if(calculus[i] == &quot;)&quot;) left--;
        }
        return calculus.slice(0,nextLambda)
             + λCalculus(calculus.slice(nextLambda,i))
             + λCalculus(calculus.slice(i));
    }
    return calculus;
}

// Some lambdas
var wrapper = &quot;(λR cond zerop succ pred mult T F.@)(λx.x(x))(λc a b.c(a)(b))(λn.n(λx a b.b)(λa b.a))(λn f x. n(f)(f(x)))(λn f x. n(λg h.h(g(f)))(λu.x)(λu.u))(λa b c d.a(b(c))(d))(λx y.x)(λx y.y)&quot;
var fac = wrapper.replace(/@/,&quot;(λfac.fac)(R(λself n.cond(zerop(n))(λblank.succ(F))(λblank.mult(n)(R(self)(pred(n))))(0)))&quot;)
var three = &quot;(λf x.f(f(f(x))))&quot;
var five = &quot;(λf x.f(f(f(f(f(x))))))&quot;

// evaluation of (5!)
var js = λCalculus(&quot;(&quot;+fac+&quot;)&quot;+&quot;(λf x.f(f(f(f(f(x))))))&quot;)
function evalAsInteger(a){ return a(increment)(0); }
function increment(a){ return (a-0||0) + 1; }
console.log(js,evalAsInteger(eval(js)))

</code></pre>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Hello World]]></title><description><![CDATA[Long overdue, my site is now new. Not much to say on the design, but the end result is produced using Ghost and Buster for a simple, static, blog-ish setup...]]></description><link>https://ghost.siverv.no/hello-world/</link><guid isPermaLink="false">Ghost__Post__5eb5bb1727759304370628e0</guid><category><![CDATA[meta]]></category><dc:creator><![CDATA[Siver K. Volle]]></dc:creator><pubDate>Wed, 13 Aug 2014 20:04:00 GMT</pubDate><content:encoded><![CDATA[<p>Long overdue, my site is now new. Not much to say on the design, but the end result is produced using <a href="https://ghost.org/">Ghost</a> and <a href="https://github.com/axitkhurana/buster">Buster</a> for a simple, static, blog-ish setup. I seldom have anything to write,  though, so the blog part might not get its potential fully realized.</p><p>It is quite a while since I last updated my site. I've almost done it  multiple times in the last couple of years, but I had yet to actually  implement the changes I made. In order to push myself to do it this  time, I've decided to upload with still unfinished parts.</p><p>After I finish stitching up the code, I'm planning on gradually releasing posts about my earlier projects.</p>]]></content:encoded></item></channel></rss>