rpncalc-v4/tracer/index.html

36 lines
1.7 KiB
HTML

<html>
<style>
textarea {
width: 100%;
height: 30%;
}
code {
background-color:rgb(230, 230, 230);
padding: 0 0.125rem;
}
</style>
<textarea id="inbox"></textarea>
<button id="step">step</button>
<button id="play">play</button>
<button id="load">load</button>
<pre id="insbox"></pre>
<pre id="outbox"></pre>
<script src="./main.js" type="module"></script>
<h3>Documentation</h3>
<p>use <code>(name; value)</code> to define something. the definition can be recursive. <code>value</code> is executed and <code>name</code> is set to the final state of the stack, i.e. <code>(name; 1 3)</code> is possible</p>
<p>use <code>'</code> to push instead of apply to the stack, e.g. <code>'(a -> a)</code>. This is useful for lazyness, i.e. <code>'(->lazy evaluated thing)</code></p>
<ul>
<li><code>+, -, *, /, ^, sqrt</code>: mathematical operations</li>
<li><code>==</code>: equality (automatically derived for all types); returns <code>a b -> a</code> if true, <code>a b -> b</code> if false</li>
<li><code>typeof</code>: returns the type of the object</li>
<li><code>pair, fst, snd</code>: pairs two objects, gets first or second item of pair</li>
<li><code>tuple</code>: used like <code>... 3 tuple</code>; creates an n tuple of n items on the stack</li>
<li><code>!!</code>: index into a tuple</li>
<li><code>len</code>: length of a tuple</li>
<li><code>unsafeCoerce</code>: unsafely transforms one type into another. useage: <code>1 "type unsafeCoerce</code></li>
<li><code>true, false</code>: true/false used in <code>==</code></li>
<li><code>stop</code>: equivalent to <code>"stop</code></li>
<li><code>inv</code>: equivalent to <code>1 x /</code></li>
<li><code>fold</code>: equivalent to <code>x acc fn -> acc '(-> x acc fn 'fn fold) 'x \"stop ==</code></li>
</ul>
</html>