Git Product home page Git Product logo

crisp's Introduction

crisp

absolutely useless Lisp-like interpreter written in Python

What's this?

A small Lisp-like language implemented in Python. Just because.

What's implemented?

  • Primitives: (true false nil SymbolReferences 'Symbols 42 1.6666 "strings")
  • Variables and constants:
    ((let (x (y 0)))
     (const ((z 1.25)))
     (= x nil)                  ;; true
     (set x 3)                  ;; 3
     (set y (* 2 x z))          ;; 7.5
  • Floating-point arithmetic: + - * /
  • Real comparison: < <= > >=
  • Expr comparison: = !=
  • Bool operators: ! && ||
  • Bitwise operators on integer Real values: ~ & |
  • λ-expressions:
    ((let ((add (lambda (a b) (+ a b)))))
     (add 3 2)                  ;; 5
     (defun sub (a b) (- a b))  ;; shorthand form
     (sub 5 3)                  ;; 2
  • while loops:
    ((let ((i 0) (M 5)))
     (while (< i M)                ;; (nil 1 nil 2 nil 3 nil 4 nil 5)
      (send "%d. Hello!" (+ 1 i))  ;; nil
      (set i (+ 1 i))))            ;; (+ 1 i)
  • Conditional expressions
  • &optional and &rest parameters
  • Proper quote/' on any Expr, not only Symbols
  • Selector expressions:
    ((let ((my-list (1 2 3))
           (fake-dict ('i 0 'j 1 'k 2))
           (my-string "hello \"world\"!"))
     ([0] my-list)             ;; 1
     ([rev (rg 0 2)] my-list)  ;; (3 2 1)
     (['i 'k] fake-dict)
     ([.length 0] my-string))  ;; (14 "h")
  • Python interop

Some fancy perks

lisp.errors.LispError: el nombre de la función no puede ser un símbolo literal. Utiliza la notación `(lambda (a b) (+ a b))` para declarar una función anónima en la línea 4, columna 16
   4          (defun '+ (a b) (+ a b))
   \-----------------^^
  • Exception messages intend to be actually useful.
  • Works at least 68% of the time!!

crisp's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.