Giter Club home page Giter Club logo

cl21's Introduction

CL21 - Common Lisp in the 21st Century.

This is an experimental project redesigning Common Lisp.

Usage

(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)

Features

  • 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)

Deferred List

  • Threads.
  • POSIX.
  • Functions to run shell commands.

Requirements

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.

Installation

(ql-dist:install-dist "http://qldists.8arrow.org/cl21.txt")
(ql:quickload :cl21)

List of major changes from standard CL

See CHANGES . We also have another version of the list at HERE which is automatically generated by a script.

Update to the latest version

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")

Setting the startup package of SLIME

  1. Load CL21 in your Lisp init file.
(ql:quickload :cl21)
  1. 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)

See Also

  • Closer MOP
  • Trivial Types
  • trivial-gray-streams
  • Alexandria
  • CL-Utilities
  • Split-Sequence
  • REPL-Utilities

Author

Copyright

Copyright (c) 2014 Eitarow Fukamachi ([email protected])

License

Licensed under the MIT License.

cl21's People

Contributors

fukamachi avatar guicho271828 avatar snmsts avatar

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.