A 3-line lisp implementation

Related tags

Miscellaneousnanolisp
Overview

Nanolisp

The download page of many a language harbors deep senses of forboding, of evil lurking in its native lair. You feel that the language is not a friend, that it means to harm you. You wonder what will happen when you click on the download link.

But don't be scared. Nanolisp is a friend in a desert of programming languages. It can fit in a clipboard or an email. A file or a project. Just 3 lines of code long, it really has earned its name. It only relies on standard, cross-platform modules. It is an oasis for many a person.

Installation

Copy and paste. Et viola! You have a complete nanolisp download! Python 3.8 or greater is needed to run the code. But I promise you, it will be worth it.

The examples following this one will assume you have copy-pasted it into a file called nl.py.

Basic Usage

Run python3 nl.py to open up the REPL. There, you can do many operations. Here is a sample session:

$ python3 nl.py
Welcome to Nanolisp 1.0.1!
> (+ 1 1)
2
> (define a 5)
> a
5
> (+ a 5)
10
> (define (inc n)
    (+ n 1))
> (inc 4)
5
> (exit)
$

As you can see, Nanolisp offers a full-featured repl. To run from a file is similarly simple: python3 nl.py . In fact, this repository includes a test file, titled schemetest.scm, which implements an algorithm for square root and runs it on 10 (the algorithm itself was taken from the seminal textbook on Scheme, Structure and Interpretation of Computer Programs).

Advanced Usage

Although I made this for fun, I quickly realized that this could be applied to config files and similar goals. This leads to the fairly large topic of a Domain Specific Language (DSL). Nanolisp is designed to be extensible and easily so. Unfortunately, due to its complex implementation, it's not extensible in all of its aspects.

To be continued...

API

Z (Environment)

Z is the variable used to store the environment. It has a custom type, but it was based off of Peter Norvig's implementation of the environment in lis.py. Why is it called Z? I have no idea.

ev (evaluate)

Evaluate an AST (tuple of tuples).

run

Run a string.

rf (run file)

Open a file and run it (leaks memory, I guess)

repl

Start the actual REPL, as opposed to the banner.

parsers

The name is pretty misleading; this is a list of transformations applied to the lisp code to turn it into valid python code. Feel free to add elements to it if you know what you're doing.

initl (init loader)

Allows you to import scheme files.

Owner
A 9th grader who's interested in coding, math, or really anything.
My custom Fedora ostree build with sway/wayland.

Ramblurr's Sway Desktop This is an rpm-ostree based minimal Fedora developer desktop with the sway window manager and podman/toolbox for doing develop

Casey Link 1 Nov 28, 2021
Waydroid is a container-based approach to boot a full Android system on a regular GNU/Linux system like Ubuntu.

Waydroid is a container-based approach to boot a full Android system on a regular GNU/Linux system like Ubuntu.

WayDroid 4.7k Jan 08, 2023
This is some simple code to scrape vistbook's system to get an overview of the different cabins availability.

DNT_cabin_availability_system This is some simple code to scrape visbook's system to get an overview of the different cabins availability. The system

Andreas Lorentzen 1 Sep 25, 2022
ChainJacking is a tool to find which of your Go lang direct GitHub dependencies is susceptible to ChainJacking attack.

ChainJacking is a tool to find which of your Go lang direct GitHub dependencies is susceptible to ChainJacking attack.

Checkmarx 36 Nov 02, 2022
RFDesign - Protein hallucination and inpainting with RoseTTAFold

RFDesign: Protein hallucination and inpainting with RoseTTAFold Jue Wang (juewan

139 Jan 06, 2023
Webcash is an experimental e-cash (electronic cash)

Webcash Webcash is an experimental new electronic cash ("e-cash") that enables decentralized and instant payments to anyone, anywhere in the world. Us

Mark Friedenbach 0 Feb 26, 2022
Modern API wrapper for Genshin Impact built on asyncio and pydantic.

genshin.py Modern API wrapper for Genshin Impact built on asyncio and pydantic.

sadru 212 Jan 06, 2023
Url-check-migration-python - A python script using Apica API's to migrate URL checks between environments

url-check-migration-python A python script using Apica API's to migrate URL chec

Angelo Aquino 1 Feb 16, 2022
A fishing bot script written in Python!

A fishing bot script written in Python!

Anel Drocic 3 Nov 03, 2021
Structured Exceptions for Python

XC: Structured exceptions for Python XC encourages a structured, disciplined approach to use of exceptions: it reduces the overhead of declaring excep

Bob Gautier 2 May 28, 2021
A simple streamlit webapp with multiple functionality

A simple streamlit webapp with multiple functionality

Omkar Pramod Hankare 2 Nov 24, 2021
Calculate the efficient frontier

关于 代码主要参考Fábio Neves的文章,你可以在他的文章中找到一些细节性的解释

Wyman Lin 104 Nov 11, 2022
Fiber implements an proof-of-concept Python decorator that rewrites a function

Fiber implements an proof-of-concept Python decorator that rewrites a function so that it can be paused and resumed (by moving stack variables to a heap frame and adding if statements to simulate jum

Tyler Hou 225 Dec 13, 2022
Alternative StdLib for Nim for Python targets

Alternative StdLib for Nim for Python targets, hijacks Python StdLib for Nim

Juan Carlos 100 Jan 01, 2023
A student information management system in Python

Student-information-management-system 本项目是一个学生信息管理系统,这个项目是用Python语言实现的,也实现了图形化界面的显示,同时也实现了管理员端,学生端两个登陆入口,同时底层使用的是Redis做的数据持久化。 This project is a stude

liuyunfei 7 Nov 15, 2022
Free components that wrap up Python into Delphi and Lazarus (FPC)

Python for Delphi (P4D) is a set of free components that wrap up the Python DLL into Delphi and Lazarus (FPC). They let you easily execute Python scri

747 Jan 02, 2023
Hypothesis strategies for generating Python programs, something like CSmith

hypothesmith Hypothesis strategies for generating Python programs, something like CSmith. This is definitely pre-alpha, but if you want to play with i

Zac Hatfield-Dodds 73 Dec 14, 2022
This synchronizes my appearances with my calendar

Josh's Schedule Synchronizer Here's the "problem:" I use a Google Sheets spreadsheet to maintain all my public appearances.

Developer Advocacy 2 Oct 18, 2021
To check my COVID-19 vaccine appointment, I wrote an infinite loop that sends me a Whatsapp message hourly using Twilio and Selenium. It works on my Raspberry Pi computer.

COVID-19_vaccine_appointment To check my COVID-19 vaccine appointment, I wrote an infinite loop that sends me a Whatsapp message hourly using Twilio a

Ayyuce Demirbas 24 Dec 17, 2022
YourX: URL Clusterer With Python

YourX | URL Clusterer Screenshots Instructions for running Install requirements

ARPSyndicate 1 Mar 11, 2022