chickenclisp 0.1.1
A scheme like programming language and interpreter
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
ChickenClisp
A minimal implementation of Orelang in D.
This program was translated from Orelang_TS
ChickenClisp means an interpreter of extended Orelang and the language itself.
ChickenClisp is just like a Scheme like Lisp.
What's Orelang?
Orelang is simple and minimal programming language declared at the articleプログラミング言語を作る。1時間で
Features
This is an implementation of Orelang and provides more functions
- if/cond expression
- compare functions: >,>=,<,<=
- logics : and(&&), or(||), not(!)
- function definition
- Function/Operator is first-class object
- Lambda Expression (lambda keyword)
- Closure
- List support(and utilities like car, cdr)
This language aims an original scheme like lisp.
Specification of Orelang
This is not an original specification original is can be found at the article.
Grammer
Orelang provide only one grammer.
Expr := (operator args1 args2...) <- this is CallOperator
Expr := value <- this is ImmediateValue
This looks like lisp.
Sample codes
Some sample code can be found at samples/ and sample.d is sample code runner, you can see sample codes have only to run it, but I'll show you some sample codes of ChickenClisp here.
Sum 1 to 10
Procedural impl:
(step
(set i 0)
(set sum 0)
(while (<= i 10)
(step
(set sum (+ i sum))
(set i (+ i 1))))
(println "sum 1 to 10 : " sum))
Functional(use high order function)
; seq(n) creates a sequence of '(0 1 2 ... n)
(println (fold + 0 (seq 11)))
Square 1 to 10 with high order function - map(/foreach)
(println (map (lambda (x) (* x x)) (cdr (seq 11))))
You can define an function to square:
(def square (x) (* x x))
(println (map square (cdr (seq 11))))
As you can see, Function is a first-class Object in ChickenClisp!.
Fibonacci
(def fib (n)
(step
(if (= n 0) 0
(if (= n 1) 1
(+ (fib (- n 1)) (fib (- n 2)))))))
or:
(def fib (n)
(step
(def fib-iter (n a b)
(if (= n 0)
a
(fib-iter (- n 1) b (+ a b))))
(fib-iter n 0 1)))
then:
(println (map fib (seq 10)))
More sample codes
More sample codes are wrote in sample.d
.
Installation
Requirements
- dmd(v2.070 or later)
- dub(1.0.0 or later)
Commands
$ git clone https://github.com/alphaKAI/ChickenClisp
$ cd ChickenClisp
$ dub build
$ ./chickenclisp
License
ChickenClisp is released under the MIT License.
Please see LICENSE
file for details.
Copyright (C) 2016 Akihiro Shoji
- Registered by alphaKAI
- 0.1.1 released 8 years ago
- alphaKAI/chickenclisp
- MIT
- Copyright (C) 2016, Akihiro Shoji
- Authors:
- Dependencies:
- none
- Versions:
-
0.1.8 2016-Nov-20 0.1.7 2016-Nov-18 0.1.6 2016-Nov-18 0.1.5 2016-Nov-17 0.1.4 2016-Nov-17 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
81 downloads total
-
- Score:
- 0.5
- Short URL:
- chickenclisp.dub.pm