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.
Python screenshot library, replacement for the Pillow ImageGrab module on Linux.

tldr: Use Pillow The pyscreenshot module is obsolete in most cases. It was created because PIL ImageGrab module worked on Windows only, but now Linux

455 Dec 24, 2022
Small exercises to get you used to reading and writing Python code!

Pythonlings Welcome to Pythonlings, an automated Python tutorial program (inspired by Rustlings and Haskellings). WIP This program is still working in

鹤翔万里 5 Sep 23, 2022
E-Paper display loop with plugins

PaperPi V3 NOTE This version of PaperPi is under heavy development and is not ready for the average user. We are working on adding more screen compati

Aaron Ciuffo 34 Dec 30, 2022
Building an Investment Portfolio for Day Trade with Python

Montando um Portfólio de Investimentos para Day Trade com Python Instruções: Para reproduzir o projeto no Google Colab, faça o download do repositório

Paula Campigotto 9 Oct 26, 2021
Transform Python source code into it's most compact representation

Python Minifier Transforms Python source code into it's most compact representation. Try it out! python-minifier currently supports Python 2.7 and Pyt

Daniel Flook 403 Jan 02, 2023
Automated GitHub profile content using the USGS API, Plotly and GitHub Actions.

Top 20 Largest Earthquakes in the Past 24 Hours Location Mag Date and Time (UTC) 92 km SW of Sechura, Peru 5.2 11-05-2021 23:19:50 113 km NNE of Lobuj

Mr. Phantom 28 Oct 31, 2022
🐍 A Python lib for (de)serializing Python objects to/from JSON

Turn Python objects into dicts or (json)strings and back No changes required to your objects Easily customizable and extendable Works with dataclasses

Ramon Hagenaars 253 Dec 14, 2022
Demo scripts for the Kubernetes Security Webinar

Kubernetes Security Webinar [in Russian] YouTube video (October 13, 2021) Authors: Artem Yushkovsky (LinkedIn, GitHub) Maxim Mosharov @ Whitespots.io

Slurm 34 Dec 06, 2022
A short course on Julia and open-source software development

Advanced Scientific Computing: producing better code This course is taught as a 6-session "nanocourse" at Washington University in St. Louis. See the

Tim Holy 230 Jan 07, 2023
basic tool for NFT. let's spam, this is the easiest way to generate a hell lotta image

NFT generator this is the easiest way to generate a hell lotta image buckle up and follow me! how to first have your image in .png (transparent backgr

34 Nov 18, 2022
Cross-Encoder-with-Bi-Encoder를 활용한 WebPage 데모

Retrieval_Streamlit_Demo Cross-Encoder-with-Bi-Encoder를 활용한

5 Dec 29, 2021
A python package that adds "docs" command to disnake

About This extension's purpose is of adding a "docs" command, its purpose is to help documenting in chat. How To Load It from disnake.ext import comma

7 Jan 03, 2023
Funchacks - Fun module which is a small set of utilities

funchacks 👋 Introduction Funchacks is a fun module that provides a small packag

DenyS 6 Aug 04, 2022
Open source home automation that puts local control and privacy first

Home Assistant Open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiast

Home Assistant 57k Jan 02, 2023
Learning objective: Use React.js, Axios, and CSS to build a responsive YouTube clone app

Learning objective: Use React.js, Axios, and CSS to build a responsive YouTube clone app to search for YouTube videos, channels, playlists, and live events via wrapper around Google YouTube API.

Dillon 0 May 03, 2022
Stocks Trading News Alert Using Python

Stocks-Trading-News-Alert-Using-Python Ever Thought of Buying Shares of your Dream Company, When their stock price got down? But It is not possible to

Ayush Verma 3 Jul 29, 2022
To effectively detect the faulty wafers

wafer_fault_detection Aim of the project: In electronics, a wafer (also called a slice or substrate) is a thin slice of semiconductor, such as crystal

Arun Singh Babal 1 Nov 06, 2021
🛠️ Plugin to integrate Chuy with Poetry

Archived This is bundled with Chuy since v1.3.0. Poetry Chuy Plugin This plugin integrates Chuy with Poetry. Note: This only works in Poetry 1.2.0 or

Eliaz Bobadilla 4 Sep 24, 2021
Quanser Labs Robotic Arm With Python

Quanser-Labs-Robotic-Arm As a team, we programmed a Robotic-Arm in Python on the

1 Jul 11, 2022
This is an implementation of NeuronJ work with python.

NeuronJ This is an implementation of NeuronJ work with python. NeuronJ is a plug-in for ImageJ that allows you to create and edit neurons masks. Image

Mohammad Mahdi Samei 3 Aug 28, 2022