Skip to content

Commit

Permalink
Improve examples
Browse files Browse the repository at this point in the history
Only 3 examples are shown in the manual, so move the various cons adding
examples later since they are not helpful. As such, show an `interactive'
example, a Docstring result example and a square bracket args example.

Rename `example/add-cons' -> `example/interactive'.
  • Loading branch information
nbfalcon committed Mar 22, 2021
1 parent 8ac91de commit 66f513e
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions dev/examples.el
Expand Up @@ -1260,27 +1260,28 @@ new list."
(funcall (-lambda (a (b c)) (+ a b c)) 1 (list 2 3)) => 6)

(defexamples -defun
(progn (-defun example/interactive ((a . b))
"Add the `car' and `cdr' of INPUT0."
(interactive (list (cons 1 2)))
(+ a b))
(command-execute #'example/interactive)) => 3
(progn (-defun example/docstring-result ((&plist :x))
"Docstring and result.")
(example/docstring-result '(:x t))) => t
(progn (-defun example/square-args [&plist :x]
x)
(example/square-args '(:x t))) => t

(progn (-defun example/cdr ((_ . tail)) tail)
(example/cdr '(a . b))) => 'b
(progn (-defun example/car ((cur)) cur)
(example/car '(a . b))) => 'a
(progn (-defun example/add-cons ((a . b))
"Add the `car' and `cdr' of INPUT0."
(interactive (list (cons 1 2)))
(+ a b))
(command-execute #'example/add-cons)) => 3
(progn (-defun example/add-conses-rec (&rest (cur . other))
(if other
(+ (example/add-cons cur)
(apply #'example/add-conses-rec other))
(example/add-cons cur)))
(example/add-conses-rec '(1 . 5) '(5 . 10))) => 21
(progn (-defun example/docstring-result ((&plist :x))
"Docstring and result.")
(example/docstring-result '(:x t))) => t
(progn (-defun example/square-args [&plist :x]
x)
(example/square-args '(:x t))) => t)
(example/add-conses-rec '(1 . 5) '(5 . 10))) => 21)

(defexamples -defmacro
(progn (-defmacro example/ht-query ((_query &as &plist :key) table)
Expand Down

0 comments on commit 66f513e

Please sign in to comment.