Log In  
Follow
pico8lispr
Pico8Lisp
by
[ :: Read More :: ]

Cart #dragonmountain2-0 | 2023-06-20 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
7

This is a game I made a few years ago for my little kids.
They love saving the dragon.

P#131172 2023-06-20 17:59

[ :: Read More :: ]

Small minesweeper clone.
Keyboard controls: Arrows to move yellow selector. x to flag, z to sweep.
Mouse controls: left click to sweep, right click to flag.

sweeping on already cleared cells auto-flags or auto-sweeps if the solution for the square is clear from the label and adjacent uncleared or flagged cells.

Cart #sweeper-0 | 2022-10-24 | Code ▽ | Embed ▽ | No License

P#119502 2022-10-24 09:15

[ :: Read More :: ]

Cart #picooids-0 | 2022-06-21 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
6

Fun little asteroids clone.
Left and right to turn. Up moves you forward. X fires your cannon.
Destroy all the asteroids to move on to the next level.
Collect blue power ups to recharge your shields.
Collect orange power ups to improve your cannon.
Beware the locals: they are friendly, unless provoked.

P#113445 2022-06-21 16:50

[ :: Read More :: ]

Cart #dragonmountain2-0 | 2023-06-20 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
7

This is a little snake clone, where the user advances the snake manually.
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.
Since then, I've spent some time improving the music and art.

P#104258 2022-01-04 08:15 ( Edited 2023-06-20 17:59)

[ :: Read More :: ]

Pico8lisp is a small lisp interpreter built on PICO-8 virtual machine!

You can find a walkthrough of the programming language features on my github here: https://github.com/andrewguy9/pico8lisp

Try it out!

Cart #pico8lisp1-7 | 2021-09-16 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
14

Using the REPL

You can type commands directly into the shell.

> (+ 1 2)
  3

<return> submits the command.

Press <up> and <down> to scroll through your command history.

Press <left> and <right> to move the cursor.

<backspace> will remove the character to the left of the cursor.

<shift>-d will remove the character to the right of the cursor.

Toggle between insert and replace modes by pressing <shift>-I.

Language Specification:

Literals

Numbers

Literal numbers are just the numbers themselves.

> 123
  123

Symbols

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.

Nil

Nil can be written as nil

> nil
  ()

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!

Boolean

Everything except nil is true.
But we do have a special value to represent truth.

> $t
  $t

Expressions

Calling Functions

The first element of a list is assumed to be a function.

> (+ 1 2)
  3

You can even nest list expressions.

> (+ (+ 1 2) 3)
  6

Supported Numeric Functions

* + plus
* - subtract
* * multiply
* / divide
* % modulus

Clear screen

If your repl gets confusing, clear the screen

(clear)

Lists

You can write a list literal with the quote function.

> (quote (1 2 3))
  (1 2 3)

Quote prevents the list from being evaluated!

There is a special quote operator to make this to read.

> '(1 2 3)
  '(1 2 3)

There are many functions which work with lists

> (empty? ())
  $t
> (len '(1 2 3))
  3
> (first '(1 2 3))
  1
> (second '(1 2 3))
  2
> (nth 2 '(1 2 3))
  3
> (rest '(1 2 3))
  (2 3)
> (reverse '(1 2 3))
  (3 2 1)
> (reduce + 0 '(1 2 3 4))
  10
> (map inc '(1 2 3))
  (2 3 4)
> (filter (fn (x) (= x 1)) '(1 2))
  (1)

Symbols

By default symbols are evaluated, but you can prevent that with quote.

> 'mysymbol
  mysymbol

Def

You can define global symbols with a value.

> (def age 38)
  38

> age
  38

local bindings

While def symbols are globally available, you can make locally scoped definitions with let

> (let (x 3 y 2) (+ x y))
  5

You can define functions

Use defn to make a function globally accessible.

> (defn inc (x) (+ x 1))
  (fn (x) (+ x 1))

> (inc 2)
  3

If statements

Branches are supported by if statements.

> (if (= 1 1) 'happy 'sad)
  happy
> (if (= 1 2) 'happy 'sad)
  sad

If else if..., else statements are supported via cond

> (def x 1)
> (cond (= x 0) 'zero (= x 1) 'one $t 'other)
  one

Supported logic operators:

  • = - equals check
  • ! - not
  • and -logical and
  • or - logical or

Examples

> (= 1 1)
  $t
> (= 1 2)
  ()
> (= '(1 2) '(1 2))
  $t
> (! nil)
  $t
> (! $t)
  nil
> (! 1)
  nil
> (and nil 1)
  ()
> (or nil 1)
  $t
P#96658 2021-08-30 01:34 ( Edited 2021-09-16 07:30)