Fix docstring of -list

* dash.el (-list): Fix doc in the case that the first argument is
already a list.
* dev/examples.el (-list): Expand tests.

* README.md:
* dash.texi: Regenerate docs.

Fixes #225.
master
Basil L. Contovounesios 5 years ago
parent 92393c73e0
commit b3c58ffdb1
No known key found for this signature in database
GPG Key ID: 205AB54A5D5D8CFF
  1. 7
      README.md
  2. 10
      dash.el
  3. 7
      dash.texi
  4. 7
      dev/examples.el

@ -2034,10 +2034,9 @@ if the first element should sort before the second.
#### -list `(&rest args)` #### -list `(&rest args)`
Return a list with `args`. Return a list based on `args`.
If the first item of `args` is already a list, simply return it.
If first item of `args` is already a list, simply return `args`. If Otherwise, return a list with `args` as elements.
not, return a list with `args` as elements.
```el ```el
(-list 1) ;; => '(1) (-list 1) ;; => '(1)

@ -2515,13 +2515,11 @@ if the first element should sort before the second."
`(-sort (lambda (it other) ,form) ,list)) `(-sort (lambda (it other) ,form) ,list))
(defun -list (&rest args) (defun -list (&rest args)
"Return a list with ARGS. "Return a list based on ARGS.
If the first item of ARGS is already a list, simply return it.
If first item of ARGS is already a list, simply return ARGS. If Otherwise, return a list with ARGS as elements."
not, return a list with ARGS as elements."
(declare (pure t) (side-effect-free t)) (declare (pure t) (side-effect-free t))
(let ((arg (car args))) (if (listp (car args)) (car args) args))
(if (listp arg) arg args)))
(defun -repeat (n x) (defun -repeat (n x)
"Return a new list of length N with each element being X. "Return a new list of length N with each element being X.

@ -3116,10 +3116,9 @@ if the first element should sort before the second.
@anchor{-list} @anchor{-list}
@defun -list (&rest args) @defun -list (&rest args)
Return a list with @var{args}. Return a list based on @var{args}.
If the first item of @var{args} is already a list, simply return it.
If first item of @var{args} is already a list, simply return @var{args}. If Otherwise, return a list with @var{args} as elements.
not, return a list with @var{args} as elements.
@example @example
@group @group

@ -926,7 +926,12 @@ value rather than consuming a list to produce a single value."
(-list 1) => '(1) (-list 1) => '(1)
(-list 1 2 3) => '(1 2 3) (-list 1 2 3) => '(1 2 3)
(-list '(1 2 3)) => '(1 2 3) (-list '(1 2 3)) => '(1 2 3)
(-list '((1) (2))) => '((1) (2))) (-list '((1) (2))) => '((1) (2))
(-list) => ()
(-list ()) => ()
(-list () 1) => ()
(-list '(())) => '(())
(-list '(() 1)) => '(() 1))
(defexamples -fix (defexamples -fix
(-fix (lambda (l) (-non-nil (--mapcat (-split-at (/ (length it) 2) it) l))) '((1 2 3 4 5 6))) => '((1) (2) (3) (4) (5) (6)) (-fix (lambda (l) (-non-nil (--mapcat (-split-at (/ (length it) 2) it) l))) '((1 2 3 4 5 6))) => '((1) (2) (3) (4) (5) (6))

Loading…
Cancel
Save