pico8lispr [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=57925 picooids <p> <table><tr><td> <a href="/bbs/?pid=113445#p"> <img src="/bbs/thumbs/pico8_picooids-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=113445#p"> picooids</a><br><br> by <a href="/bbs/?uid=57925"> pico8lispr</a> <br><br><br> <a href="/bbs/?pid=113445#p"> [Click to Play]</a> </td></tr></table> </p> <p>Fun little asteroids clone.<br /> Left and right to turn. Up moves you forward. X fires your cannon.<br /> Destroy all the asteroids to move on to the next level.<br /> Collect blue power ups to recharge your shields.<br /> Collect orange power ups to improve your cannon.<br /> Beware the locals: they are friendly, unless provoked.</p> https://www.lexaloffle.com/bbs/?tid=48247 https://www.lexaloffle.com/bbs/?tid=48247 Tue, 21 Jun 2022 16:50:57 UTC dragonmountain <p> <table><tr><td> <a href="/bbs/?pid=104258#p"> <img src="/bbs/thumbs/pico8_dragonmountain-1.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=104258#p"> dragonmountain</a><br><br> by <a href="/bbs/?uid=57925"> pico8lispr</a> <br><br><br> <a href="/bbs/?pid=104258#p"> [Click to Play]</a> </td></tr></table> </p> <p>This is a little snake clone, where the user advances the snake manually.<br /> I made it for my 4 year old as a one day build. So far, she's unable to deal with the snake advancing automatically.<br /> Since then, I've spent some time improving the music and art.</p> https://www.lexaloffle.com/bbs/?tid=45990 https://www.lexaloffle.com/bbs/?tid=45990 Tue, 04 Jan 2022 08:15:10 UTC Pico8Lisp <p>Pico8lisp is a small lisp interpreter built on PICO-8 virtual machine!</p> <p>You can find a walkthrough of the programming language features on my github here: <a href="https://github.com/andrewguy9/pico8lisp">https://github.com/andrewguy9/pico8lisp</a></p> <h1>Try it out!</h1> <p> <table><tr><td> <a href="/bbs/?pid=96658#p"> <img src="/bbs/thumbs/pico8_pico8lisp1-7.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=96658#p"> pico8lisp1</a><br><br> by <a href="/bbs/?uid=57925"> pico8lispr</a> <br><br><br> <a href="/bbs/?pid=96658#p"> [Click to Play]</a> </td></tr></table> </p> <h1>Using the REPL</h1> <p>You can type commands directly into the shell.</p> <div> <div style="max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>&gt; (+ 1 2) 3</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>&lt;return&gt; submits the command.</p> <p>Press &lt;up&gt; and &lt;down&gt; to scroll through your command history.</p> <p>Press &lt;left&gt; and &lt;right&gt; to move the cursor.</p> <p>&lt;backspace&gt; will remove the character to the left of the cursor.</p> <p>&lt;shift&gt;-d will remove the character to the right of the cursor.</p> <p>Toggle between insert and replace modes by pressing &lt;shift&gt;-I.</p> <img style="" border=0 src="/media/57925/6_insert.gif" alt="" /> <img style="" border=0 src="/media/57925/replace.gif" alt="" /> <h1>Language Specification:</h1> <h2>Literals</h2> <h3>Numbers</h3> <p>Literal numbers are just the numbers themselves.</p> <div> <div style="max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>&gt; 123 123</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <h3>Symbols</h3> <p>Symbols are used as names for forms/functions/constants/just about anything. Symbols can be written as series of letters a-z. More on that later.</p> <h3>Nil</h3> <p>Nil can be written as nil</p> <div> <div style="max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>&gt; nil ()</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Note that nil evaluated to an empty list (). That's because the symbol nil is bound to the empty list. This is the only false value in picolisp!</p> <h3>Boolean</h3> <p>Everything except nil is true.<br /> But we do have a special value to represent truth.</p> <div> <div style="max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>&gt; $t $t</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <h2>Expressions</h2> <h3>Calling Functions</h3> <p>The first element of a list is assumed to be a function.</p> <div> <div style="max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>&gt; (+ 1 2) 3</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>You can even nest list expressions.</p> <div> <div style="max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>&gt; (+ (+ 1 2) 3) 6</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Supported Numeric Functions</p> <div> <div style="max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>* + plus * - subtract * * multiply * / divide * % modulus</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <h3>Clear screen</h3> <p>If your repl gets confusing, clear the screen</p> <div> <div style="max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>(clear)</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <h3>Lists</h3> <p>You can write a list literal with the quote function.</p> <div> <div style="max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>&gt; (quote (1 2 3)) (1 2 3)</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Quote prevents the list from being evaluated!</p> <p>There is a special quote operator to make this to read.</p> <div> <div style="max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>&gt; '(1 2 3) '(1 2 3)</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>There are many functions which work with lists</p> <div> <div style="max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>&gt; (empty? ()) $t &gt; (len '(1 2 3)) 3 &gt; (first '(1 2 3)) 1 &gt; (second '(1 2 3)) 2 &gt; (nth 2 '(1 2 3)) 3 &gt; (rest '(1 2 3)) (2 3) &gt; (reverse '(1 2 3)) (3 2 1) &gt; (reduce + 0 '(1 2 3 4)) 10 &gt; (map inc '(1 2 3)) (2 3 4) &gt; (filter (fn (x) (= x 1)) '(1 2)) (1)</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <h3>Symbols</h3> <p>By default symbols are evaluated, but you can prevent that with quote.</p> <div> <div style="max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>&gt; 'mysymbol mysymbol</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <h3>Def</h3> <p>You can define global symbols with a value.</p> <div> <div style="max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>&gt; (def age 38) 38 &gt; age 38</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <h3>local bindings</h3> <p>While def symbols are globally available, you can make locally scoped definitions with let</p> <div> <div style="max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>&gt; (let (x 3 y 2) (+ x y)) 5</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <h3>You can define functions</h3> <p>Use defn to make a function globally accessible.</p> <div> <div style="max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>&gt; (defn inc (x) (+ x 1)) (fn (x) (+ x 1)) &gt; (inc 2) 3</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <h3>If statements</h3> <p>Branches are supported by if statements.</p> <div> <div style="max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>&gt; (if (= 1 1) 'happy 'sad) happy &gt; (if (= 1 2) 'happy 'sad) sad</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>If else if..., else statements are supported via cond</p> <div> <div style="max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>&gt; (def x 1) &gt; (cond (= x 0) 'zero (= x 1) 'one $t 'other) one</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Supported logic operators:</p> <ul> <li>= - equals check</li> <li>! - not</li> <li>and -logical and</li> <li>or - logical or</li> </ul> <p>Examples</p> <div> <div style="max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>&gt; (= 1 1) $t &gt; (= 1 2) () &gt; (= '(1 2) '(1 2)) $t &gt; (! nil) $t &gt; (! $t) nil &gt; (! 1) nil &gt; (and nil 1) () &gt; (or nil 1) $t</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> https://www.lexaloffle.com/bbs/?tid=44438 https://www.lexaloffle.com/bbs/?tid=44438 Mon, 30 Aug 2021 01:34:52 UTC