0.1.14 |
|
---|---|
0.1.13 |
|
#18 in #adventure
42 downloads per month
165KB
4.5K
SLoC
JoJo's Bizarre Programming Adventure
DIO: ZA WARUDO is full of languages without good type system, we don't need anymore!
JOJO: Just one more!
DIO: Do you care about HUMANITY! JOJO?
JOJO: I REJECT MY HUMANITY, DIO!
Features
A dynamic language for learning, teaching and prototyping.
- 🚧 simply typed with subtype
- object oriented, but no side-effect over objects
- implemented in rust by a dynamic threaded code interpreter
- uses rust's Arc as garbage collector
- sexp as syntax -- enabling a lisp-like macro system
- 🚧 pattern matching
- 🚧 simple FFI to rust library
- 🚧 forth like threading macro
drop dup over tuck swap
- Oh tis so bizarre ~
Getting start
With nightly rust toolchain :
cargo install jojo
Contributing
Contributions are welcome! (The code base is still simple for now.)
- Give suggestions in issues.
- Or simply throw pull requests to me!
I will write style-guide and hacking-guide for my contributors :)
See jojo-history for history of this project.
Examples
Square Roots by Newton's Method
(square x) = (mul x x)
(average x y) = (div (add x y) 2)
(= (sqrt-iter guess x)
(if (good-enough-p guess x)
guess
(sqrt-iter (improve guess x) x)))
(improve guess x) = (average guess (div x guess))
(good-enough-p guess x) = (lt (abs (sub (square guess) x)) 0.001)
(sqrt x) = (sqrt-iter 1 x)
(sqrt 9)
(sqrt (add 100 21))
(square (sqrt 1000))
Simpson's Rule for numerical integration
(cube x) = (mul x (mul x x))
(= (sum term a next b)
(if (gt a b)
0
(add (term a)
(sum term (next a) next b))))
(= (simpson-integral f a b n)
(= h (div (sub b a) n))
(= (simpson-coefficient k)
(cond [(or (eq 0 k) (eq n k)) 1]
[(odd-p k) 4]
[(even-p k) 2]))
(= (simpson-term k)
(mul (simpson-coefficient k)
(f (add a (mul k h)))))
(mul (sum simpson-term 0 inc n)
(div h 3)))
(= assert-delta
(macro [body]
(= delta (car body))
(= a (car (cdr body)))
(= b (car (cdr (cdr body))))
`(assert (lt (abs (sub ~a ~b)) ~delta))))
(assert-delta 0.0001
(simpson-integral cube 0 1 100)
(div 1 4))
Notes
- 🚧 (2018-07-22) Semantic of De Bruijn Notation and Bizarre Syntax Adventure
- Discussions about syntax design of programming language.
🚢 ✈ ADVENTURE️ ⛴️ ⛵
See adventure for more code examples.
LICENSE
Dependencies
~7MB
~140K SLoC