Giter Site home page Giter Site logo

ebell495 / blisp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ytakano/blisp

0.0 0.0 0.0 20.26 MB

A statically typed Lisp like scripting programming language for Rust.

Home Page: https://ytakano.github.io/blisp/

License: MIT License

Common Lisp 0.42% Rust 91.49% TeX 7.93% Makefile 0.07% Dockerfile 0.09%

blisp's Introduction

BLisp

BLisp is a statically typed Lisp like programming language which adopts effect system for no_std environments. BLisp supports higher order RPC like higher order functions of functional programming languages.

This repository provides only a library crate. Please see blisp-repl to use BLisp, and baremetalisp which is a toy OS.

Homepage is here.

Features

  • Algebraic data type
  • Generics
  • Hindley–Milner based type inference
  • Effect system to separate side effects from pure functions
  • Big integer
  • Supporting no_std environments

How to Use

use blisp;

fn main() {
    let code = "(export factorial (n) (Pure (-> (Int) Int))
    (if (<= n 0)
        1
        (* n (factorial (- n 1)))))";
    let exprs = blisp::init(code, vec![]).unwrap();
    let ctx = blisp::typing(exprs).unwrap();

    let e = "(factorial 10)";
    blisp::eval(e, &ctx).unwrap();
}

If Rust compiler or linker says warning of fmod, please add fmod manually as follows.

#[no_mangle]
extern "C" fn fmod(x: f64, y: f64) -> f64 {
    libm::fmod(x, y)
}

Cargo.toml

[dependencies.blisp]
version = "0.4"

Examples

"Hello, World!" ; "Hello, World!"
(+ 0x10 0x20)   ; 48
(+ 0b111 0b101) ; 12
(+ 0o777 0o444) ; 803
(car '(1 2 3))  ; (Some 1)
(cdr '(1 2 3))  ; '(2 3)
(map (lambda (x) (* x 2)) '(8 9 10)) ; '(16 18 20)
(fold + 0 '(1 2 3 4 5 6 7 8 9))      ; 45
(reverse '(1 2 3 4 5 6 7 8 9))       ; '(9 8 7 6 5 4 3 2 1)
(filter (lambda (x) (= (% x 2) 0)) '(1 2 3 4 5 6 7 8 9)) ; '(2 4 6 8)

blisp's People

Contributors

ebell495 avatar fumisaitou avatar syohex avatar ytakano 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.