Cheat sheet for Lisp dialects (Common Lisp, Scheme, Clojure, Emacs Lisp)
hyperpolyglot.wikidot.com
hyperpolyglot.wikidot.com
And of course, there is the assumption that you're programming in EMACS right from the second row. EMACS is not actually obligatory for programming. Maybe I'm an old man with carpal tunnel and have to use vi to avoid aggravating it. Some readers could be tiny toddlers still suckling on Eclipse or something.
I like the Clojure comment "cons cannot make a cons cell." Of course, Clojure is revolutionary in being a Lisp without lists so there are no cons cells.
There are some mistakes. dotimes does exist in Clojure and works fairly similarly. Clojure's loop is recursive by nature like Scheme and CL's loop example shows none of its horrible ugly glory. Clojure has lazy stream evaluation just like Scheme's built in but is listed without it. Scheme is listed with an optional arguments idea that is not standard Scheme.
Don't get me wrong; it's mostly right but I'm still finding more errors
Overall, I like it.
It needs to be a wiki, though, so non-CL'ers can fix the errors for their dialects.
Uh, (typep foo 'vector)?
* missing equalp
* very non-idiomatic loop
=============arc (2008)=============
version used Arc 3.1
version
repl mzscheme -f as.scm
arc.sh
M-x run-arc
shebang
cell types
case sensitive yes
argument whitespace
separator
falsehoods nil ()
true, is true t, yes
symbol?
nil, is () null?, nil
is () symbol?
type-of type
type predicates (is (type x) 'int)
(is (type x) 'sym)
etc.
set property none
get property none
remove none
property
comment (+ 1 1) ; adding
============ten primitives==========
atom (or list?) atom
quote quote
eq is
car car
cdr cdr
cons cons
cond (if (> x 0) 1
(is x 0) 0
-1)
lambda (fn (x) (* x x))
[* _ _]
label =
apply ((fn (x) (* x x) 2)
([* _ _] 2)
=============arithmetic=============
==============strings===============
==========execution control=========
=========functions and scope========
==============lists=================
list literal '(1 2 3)
pair literal '(1 2)
(car '()) nil
(cdr '()) nil
(eval '()) nil
list functions list alist len append rev
nth ('(0 1 2 3) 3)
last butlast (last l)
(firstn (- (length l) 1) l)
sort (sort < '(3 2 1 0))
assoc (assoc 3 '((1 2) (3 4)))
getf none
map (map [* _ _] '(1 2 3))
filter (keep [* _ _] '(1 2 3))
reduce (reduce + '(1 2 3))
push and pop (= x '(1 2 3))
(push 4 x)
(pop x)
============sequences===============
predicate alist
===========other containers=========
=========i/o and environment========
format string (pr "Spain" 7 ": " 13.7)
to stdout
external (system "ls /etc")
command
open file (= in (infile "/etc/passwd"))
read line (readline in)
close file (close in)
=======libraries and namespaces=====
loading a file (load "a.arc")
============compilation=============
==============macros================
backquote and (def op +)
comma (eval `(,op 1 1))
defmacro (mac rpn (arg1 arg2 op)
(list op arg1 arg2))
defmacro w/ (mac rpn (arg1 arg2 op)
backquote `(,op arg1 arg2))
recursive (macex '(rpn 1 2 +))
macroexpand
single (macex1 '(rpn 1 2 +))
macroexpand
splice quote (mac add (args)
`(+ ,@args))
hygenic? no
local values using gensym
==============classes===============
=============concurrency============
create thread (thread)
==========java interoperation=======
version used jarc
on jvmThere are a few items missing (eg regex substitution in Emacs Lisp). But in general, a nice resource, thanks!
quote