This is an experimental project redesigning Common Lisp.
(in-package :cl21-user)
(defpackage myapp
(:use :cl21))
(in-package :myapp)
;;
;; Hello, World!
(princ "Hello, World!\n")
;-> Hello, World!
;=> "Hello, World!
; "
(let ((name "John"))
(princ "Hello, ${name}!"))
;-> Hello, John!
;=> "Hello, John!"
;;
;; Hash Table
(defvar *hash* #{})
(getf *hash* :name)
;=> NIL
(setf (getf *hash* :name) "Eitarow Fukamachi")
;=> "Eitarow Fukamachi"
(setf (getf *hash* :living) "Japan")
;=> "Japan"
(getf *hash* :name)
;=> "Eitarow Fukamachi"
(coerce *hash* 'plist)
;=> (:LIVING "Japan" :NAME "Eitarow Fukamachi")
;;
;; Vector
(defvar *vector* #())
(push 1 *vector*)
(elt *vector* 0)
;=> 1
(push 3 *vector*)
(elt *vector* 1)
;=> 3
(pop *vector*)
;=> 3
(pop *vector*)
;=> 1
;;
;; Iteration
;;
;; `doeach` is similar to `dolist`, but it can be used with all sequences.
;;
(collecting
(doeach (x '("al" "bob" "joe"))
(when (> (length x) 2)
(collect x))))
;=> ("bob" "joe")
;;
;; Functional programming
(mapcar (compose #'sin #'1+) '(1 2 3))
;=> (0.9092974 0.14112 -0.7568025)
(keep-if (conjoin #'integerp #'evenp) '(1 2 3 2.0 4))
;=> (2 4)
(keep-if (disjoin #'oddp #'zerop) (0.. 10))
;=> (0 1 3 5 7 9)
;; Sharpsign quote (#') is overwritten.
(keep-if #'(and integerp evenp) '(1 2 3 2.0 4))
;=> (2 4)
(keep-if #'(and integerp (or oddp zerop)) (0.. 10))
;=> (0 1 3 5 7 9)
;;
;; Regular Expression
(use-package :cl21.re)
;; #/.../ is a literal regular expression.
(re-match #/^Hello, (.+?)!$/ "Hello, World!")
;=> "Hello, World!"
; #("World")
;; Regular expression can be called like a function.
(#/^(\d{4})-(\d{2})-(\d{2})$/ "2014-01-23")
;=> "2014-01-23"
; #("2014" "01" "23")
(re-replace #/a/g "Eitarow Fukamachi" "α")
;=> "Eitαrow Fukαmαchi"
; T
;;
;; Lazy Sequence
(use-package :cl21.lazy)
(defun fib-seq ()
(labels ((rec (a b)
(lazy-sequence (cons a (rec b (+ a b))))))
(rec 0 1)))
(take 20 (fib-seq))
;=> (0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181)
(take 3 (drop-while (lambda (x) (< x 500)) (fib-seq)))
;=> (610 987 1597)
- Can completely cooperate with existing Common Lisp applications/libraries.
- More object oriented.
- Add more functional programming facilities.
- Organize symbols into several packages.
- Include MOP.
- Include trivial-gray-streams.
- Literal regular expression.
- Package local nicknames. (experimental)
- Threads.
- POSIX.
- Functions to run shell commands.
CL21 is written in pure Common Lisp and intended to run on a Common Lisp implementation.
It is tested on the latest version of SBCL, Clozure CL, GNU CLISP and Allegro CL.
(ql-dist:install-dist "http://qldists.8arrow.org/cl21.txt")
(ql:quickload :cl21)
See CHANGES . We also have another version of the list at HERE which is automatically generated by a script.
CL21 is continuously released at 1:00 JST (= 16:00 UTC). You can update to the HEAD version by this command.
(ql:update-dist "cl21")
- Load CL21 in your Lisp init file.
(ql:quickload :cl21)
- Add this to you .emacs.el.
(add-hook 'slime-connected-hook (lambda ()
(when (slime-eval `(cl:if (cl:find-package :cl21-user) t))
(slime-repl-set-package :cl21-user))) t)
- Closer MOP
- Trivial Types
- trivial-gray-streams
- Alexandria
- CL-Utilities
- Split-Sequence
- REPL-Utilities
- Eitarow Fukamachi ([email protected])
Copyright (c) 2014 Eitarow Fukamachi ([email protected])
Licensed under the MIT License.