Personal emacs config
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4656 lines
186 KiB

5 years ago
  1. This is dash.info, produced by makeinfo version 6.5 from dash.texi.
  2. This manual is for Dash version 2.18.0.
  3. Copyright © 2012–2021 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this
  5. document under the terms of the GNU Free Documentation License,
  6. Version 1.3 or any later version published by the Free Software
  7. Foundation; with the Invariant Sections being “GNU General Public
  8. License,” and no Front-Cover Texts or Back-Cover Texts. A copy of
  9. the license is included in the section entitled “GNU Free
  10. Documentation License”.
  11. INFO-DIR-SECTION Emacs
  12. START-INFO-DIR-ENTRY
  13. * Dash: (dash.info). A modern list library for GNU Emacs.
  14. END-INFO-DIR-ENTRY
  15. 
  16. File: dash.info, Node: Top, Next: Installation, Up: (dir)
  17. Dash
  18. ****
  19. This manual is for Dash version 2.18.0.
  20. Copyright © 2012–2021 Free Software Foundation, Inc.
  21. Permission is granted to copy, distribute and/or modify this
  22. document under the terms of the GNU Free Documentation License,
  23. Version 1.3 or any later version published by the Free Software
  24. Foundation; with the Invariant Sections being “GNU General Public
  25. License,” and no Front-Cover Texts or Back-Cover Texts. A copy of
  26. the license is included in the section entitled “GNU Free
  27. Documentation License”.
  28. * Menu:
  29. * Installation:: Installing and configuring Dash.
  30. * Functions:: Dash API reference.
  31. * Development:: Contributing to Dash development.
  32. Appendices
  33. * FDL:: The license for this documentation.
  34. * GPL:: Conditions for copying and changing Dash.
  35. * Index:: Index including functions and macros.
  36. — The Detailed Node Listing —
  37. Installation
  38. * Using in a package:: Listing Dash as a package dependency.
  39. * Fontification of special variables:: Font Lock of anaphoric macro variables.
  40. * Info symbol lookup:: Looking up Dash symbols in this manual.
  41. Functions
  42. * Maps::
  43. * Sublist selection::
  44. * List to list::
  45. * Reductions::
  46. * Unfolding::
  47. * Predicates::
  48. * Partitioning::
  49. * Indexing::
  50. * Set operations::
  51. * Other list operations::
  52. * Tree operations::
  53. * Threading macros::
  54. * Binding::
  55. * Side effects::
  56. * Destructive operations::
  57. * Function combinators::
  58. Development
  59. * Contribute:: How to contribute.
  60. * Contributors:: List of contributors.
  61. 
  62. File: dash.info, Node: Installation, Next: Functions, Prev: Top, Up: Top
  63. 1 Installation
  64. **************
  65. Dash is available on GNU ELPA (https://elpa.gnu.org/) and MELPA
  66. (https://melpa.org/), and can be installed with the standard command
  67. ‘package-install’ (*note (emacs)Package Installation::).
  68. ‘M-x package-install <RET> dash <RET>’
  69. Install the Dash library.
  70. Alternatively, you can just dump ‘dash.el’ in your ‘load-path’
  71. somewhere (*note (emacs)Lisp Libraries::).
  72. * Menu:
  73. * Using in a package:: Listing Dash as a package dependency.
  74. * Fontification of special variables:: Font Lock of anaphoric macro variables.
  75. * Info symbol lookup:: Looking up Dash symbols in this manual.
  76. 
  77. File: dash.info, Node: Using in a package, Next: Fontification of special variables, Up: Installation
  78. 1.1 Using in a package
  79. ======================
  80. If you use Dash in your own package, be sure to list it as a dependency
  81. in the library’s headers as follows (*note (elisp)Library Headers::).
  82. ;; Package-Requires: ((dash "2.18.0"))
  83. 
  84. File: dash.info, Node: Fontification of special variables, Next: Info symbol lookup, Prev: Using in a package, Up: Installation
  85. 1.2 Fontification of special variables
  86. ======================================
  87. The autoloaded minor mode ‘dash-fontify-mode’ is provided for optional
  88. fontification of anaphoric Dash variables (‘it’, ‘acc’, etc.) in Emacs
  89. Lisp buffers using search-based Font Lock (*note (emacs)Font Lock::).
  90. In older Emacs versions which do not dynamically detect macros, the
  91. minor mode also fontifies calls to Dash macros.
  92. To automatically enable the minor mode in all Emacs Lisp buffers,
  93. just call its autoloaded global counterpart ‘global-dash-fontify-mode’,
  94. either interactively or from your ‘user-init-file’:
  95. (global-dash-fontify-mode)
  96. 
  97. File: dash.info, Node: Info symbol lookup, Prev: Fontification of special variables, Up: Installation
  98. 1.3 Info symbol lookup
  99. ======================
  100. While editing Elisp files, you can use ‘C-h S’ (‘info-lookup-symbol’) to
  101. look up Elisp symbols in the relevant Info manuals (*note (emacs)Info
  102. Lookup::). To enable the same for Dash symbols, use the command
  103. ‘dash-register-info-lookup’. It can be called directly when needed, or
  104. automatically from your ‘user-init-file’. For example:
  105. (with-eval-after-load 'info-look
  106. (dash-register-info-lookup))
  107. 
  108. File: dash.info, Node: Functions, Next: Development, Prev: Installation, Up: Top
  109. 2 Functions
  110. ***********
  111. This chapter contains reference documentation for the Dash API
  112. (Application Programming Interface). The names of all public functions
  113. defined in the library are prefixed with a dash character (‘-’).
  114. The library also provides anaphoric macro versions of functions where
  115. that makes sense. The names of these macros are prefixed with two
  116. dashes (‘--’) instead of one.
  117. For instance, while the function ‘-map’ applies a function to each
  118. element of a list, its anaphoric counterpart ‘--map’ evaluates a form
  119. with the local variable ‘it’ temporarily bound to the current list
  120. element instead.
  121. ;; Normal version.
  122. (-map (lambda (n) (* n n)) '(1 2 3 4))
  123. ⇒ (1 4 9 16)
  124. ;; Anaphoric version.
  125. (--map (* it it) '(1 2 3 4))
  126. ⇒ (1 4 9 16)
  127. The normal version can, of course, also be written as in the
  128. following example, which demonstrates the utility of both versions.
  129. (defun my-square (n)
  130. "Return N multiplied by itself."
  131. (* n n))
  132. (-map #'my-square '(1 2 3 4))
  133. ⇒ (1 4 9 16)
  134. * Menu:
  135. * Maps::
  136. * Sublist selection::
  137. * List to list::
  138. * Reductions::
  139. * Unfolding::
  140. * Predicates::
  141. * Partitioning::
  142. * Indexing::
  143. * Set operations::
  144. * Other list operations::
  145. * Tree operations::
  146. * Threading macros::
  147. * Binding::
  148. * Side effects::
  149. * Destructive operations::
  150. * Function combinators::
  151. 
  152. File: dash.info, Node: Maps, Next: Sublist selection, Up: Functions
  153. 2.1 Maps
  154. ========
  155. Functions in this category take a transforming function, which is then
  156. applied sequentially to each or selected elements of the input list.
  157. The results are collected in order and returned as a new list.
  158. -- Function: -map (fn list)
  159. Apply FN to each item in LIST and return the list of results.
  160. This function’s anaphoric counterpart is ‘--map’.
  161. (-map (lambda (num) (* num num)) '(1 2 3 4))
  162. ⇒ (1 4 9 16)
  163. (-map #'1+ '(1 2 3 4))
  164. ⇒ (2 3 4 5)
  165. (--map (* it it) '(1 2 3 4))
  166. ⇒ (1 4 9 16)
  167. -- Function: -map-when (pred rep list)
  168. Return a new list where the elements in LIST that do not match the
  169. PRED function are unchanged, and where the elements in LIST that do
  170. match the PRED function are mapped through the REP function.
  171. Alias: ‘-replace-where’
  172. See also: ‘-update-at’ (*note -update-at::)
  173. (-map-when 'even? 'square '(1 2 3 4))
  174. ⇒ (1 4 3 16)
  175. (--map-when (> it 2) (* it it) '(1 2 3 4))
  176. ⇒ (1 2 9 16)
  177. (--map-when (= it 2) 17 '(1 2 3 4))
  178. ⇒ (1 17 3 4)
  179. -- Function: -map-first (pred rep list)
  180. Replace first item in LIST satisfying PRED with result of REP
  181. called on this item.
  182. See also: ‘-map-when’ (*note -map-when::), ‘-replace-first’ (*note
  183. -replace-first::)
  184. (-map-first 'even? 'square '(1 2 3 4))
  185. ⇒ (1 4 3 4)
  186. (--map-first (> it 2) (* it it) '(1 2 3 4))
  187. ⇒ (1 2 9 4)
  188. (--map-first (= it 2) 17 '(1 2 3 2))
  189. ⇒ (1 17 3 2)
  190. -- Function: -map-last (pred rep list)
  191. Replace last item in LIST satisfying PRED with result of REP called
  192. on this item.
  193. See also: ‘-map-when’ (*note -map-when::), ‘-replace-last’ (*note
  194. -replace-last::)
  195. (-map-last 'even? 'square '(1 2 3 4))
  196. ⇒ (1 2 3 16)
  197. (--map-last (> it 2) (* it it) '(1 2 3 4))
  198. ⇒ (1 2 3 16)
  199. (--map-last (= it 2) 17 '(1 2 3 2))
  200. ⇒ (1 2 3 17)
  201. -- Function: -map-indexed (fn list)
  202. Apply FN to each index and item in LIST and return the list of
  203. results. This is like ‘-map’ (*note -map::), but FN takes two
  204. arguments: the index of the current element within LIST, and the
  205. element itself.
  206. This function’s anaphoric counterpart is ‘--map-indexed’.
  207. For a side-effecting variant, see also ‘-each-indexed’ (*note
  208. -each-indexed::).
  209. (-map-indexed (lambda (index item) (- item index)) '(1 2 3 4))
  210. ⇒ (1 1 1 1)
  211. (--map-indexed (- it it-index) '(1 2 3 4))
  212. ⇒ (1 1 1 1)
  213. (-map-indexed #'* '(1 2 3 4))
  214. ⇒ (0 2 6 12)
  215. -- Function: -annotate (fn list)
  216. Return a list of cons cells where each cell is FN applied to each
  217. element of LIST paired with the unmodified element of LIST.
  218. (-annotate '1+ '(1 2 3))
  219. ⇒ ((2 . 1) (3 . 2) (4 . 3))
  220. (-annotate 'length '(("h" "e" "l" "l" "o") ("hello" "world")))
  221. ⇒ ((5 "h" "e" "l" "l" "o") (2 "hello" "world"))
  222. (--annotate (< 1 it) '(0 1 2 3))
  223. ⇒ ((nil . 0) (nil . 1) (t . 2) (t . 3))
  224. -- Function: -splice (pred fun list)
  225. Splice lists generated by FUN in place of elements matching PRED in
  226. LIST.
  227. FUN takes the element matching PRED as input.
  228. This function can be used as replacement for ‘,@’ in case you need
  229. to splice several lists at marked positions (for example with
  230. keywords).
  231. See also: ‘-splice-list’ (*note -splice-list::), ‘-insert-at’
  232. (*note -insert-at::)
  233. (-splice 'even? (lambda (x) (list x x)) '(1 2 3 4))
  234. ⇒ (1 2 2 3 4 4)
  235. (--splice 't (list it it) '(1 2 3 4))
  236. ⇒ (1 1 2 2 3 3 4 4)
  237. (--splice (equal it :magic) '((list of) (magical) (code)) '((foo) (bar) :magic (baz)))
  238. ⇒ ((foo) (bar) (list of) (magical) (code) (baz))
  239. -- Function: -splice-list (pred new-list list)
  240. Splice NEW-LIST in place of elements matching PRED in LIST.
  241. See also: ‘-splice’ (*note -splice::), ‘-insert-at’ (*note
  242. -insert-at::)
  243. (-splice-list 'keywordp '(a b c) '(1 :foo 2))
  244. ⇒ (1 a b c 2)
  245. (-splice-list 'keywordp nil '(1 :foo 2))
  246. ⇒ (1 2)
  247. (--splice-list (keywordp it) '(a b c) '(1 :foo 2))
  248. ⇒ (1 a b c 2)
  249. -- Function: -mapcat (fn list)
  250. Return the concatenation of the result of mapping FN over LIST.
  251. Thus function FN should return a list.
  252. (-mapcat 'list '(1 2 3))
  253. ⇒ (1 2 3)
  254. (-mapcat (lambda (item) (list 0 item)) '(1 2 3))
  255. ⇒ (0 1 0 2 0 3)
  256. (--mapcat (list 0 it) '(1 2 3))
  257. ⇒ (0 1 0 2 0 3)
  258. -- Function: -copy (list)
  259. Create a shallow copy of LIST.
  260. (-copy '(1 2 3))
  261. ⇒ (1 2 3)
  262. (let ((a '(1 2 3))) (eq a (-copy a)))
  263. ⇒ nil
  264. 
  265. File: dash.info, Node: Sublist selection, Next: List to list, Prev: Maps, Up: Functions
  266. 2.2 Sublist selection
  267. =====================
  268. Functions returning a sublist of the original list.
  269. -- Function: -filter (pred list)
  270. Return a new list of the items in LIST for which PRED returns
  271. non-nil.
  272. Alias: ‘-select’.
  273. This function’s anaphoric counterpart is ‘--filter’.
  274. For similar operations, see also ‘-keep’ (*note -keep::) and
  275. ‘-remove’ (*note -remove::).
  276. (-filter (lambda (num) (= 0 (% num 2))) '(1 2 3 4))
  277. ⇒ (2 4)
  278. (-filter #'natnump '(-2 -1 0 1 2))
  279. ⇒ (0 1 2)
  280. (--filter (= 0 (% it 2)) '(1 2 3 4))
  281. ⇒ (2 4)
  282. -- Function: -remove (pred list)
  283. Return a new list of the items in LIST for which PRED returns nil.
  284. Alias: ‘-reject’.
  285. This function’s anaphoric counterpart is ‘--remove’.
  286. For similar operations, see also ‘-keep’ (*note -keep::) and
  287. ‘-filter’ (*note -filter::).
  288. (-remove (lambda (num) (= 0 (% num 2))) '(1 2 3 4))
  289. ⇒ (1 3)
  290. (-remove #'natnump '(-2 -1 0 1 2))
  291. ⇒ (-2 -1)
  292. (--remove (= 0 (% it 2)) '(1 2 3 4))
  293. ⇒ (1 3)
  294. -- Function: -remove-first (pred list)
  295. Remove the first item from LIST for which PRED returns non-nil.
  296. This is a non-destructive operation, but only the front of LIST
  297. leading up to the removed item is a copy; the rest is LIST’s
  298. original tail. If no item is removed, then the result is a
  299. complete copy.
  300. Alias: ‘-reject-first’.
  301. This function’s anaphoric counterpart is ‘--remove-first’.
  302. See also ‘-map-first’ (*note -map-first::), ‘-remove-item’ (*note
  303. -remove-item::), and ‘-remove-last’ (*note -remove-last::).
  304. (-remove-first #'natnump '(-2 -1 0 1 2))
  305. ⇒ (-2 -1 1 2)
  306. (-remove-first #'stringp '(1 2 "first" "second"))
  307. ⇒ (1 2 "second")
  308. (--remove-first (> it 3) '(1 2 3 4 5 6))
  309. ⇒ (1 2 3 5 6)
  310. -- Function: -remove-last (pred list)
  311. Remove the last item from LIST for which PRED returns non-nil. The
  312. result is a copy of LIST regardless of whether an element is
  313. removed.
  314. Alias: ‘-reject-last’.
  315. This function’s anaphoric counterpart is ‘--remove-last’.
  316. See also ‘-map-last’ (*note -map-last::), ‘-remove-item’ (*note
  317. -remove-item::), and ‘-remove-first’ (*note -remove-first::).
  318. (-remove-last #'natnump '(1 3 5 4 7 8 10 -11))
  319. ⇒ (1 3 5 4 7 8 -11)
  320. (-remove-last #'stringp '(1 2 "last" "second"))
  321. ⇒ (1 2 "last")
  322. (--remove-last (> it 3) '(1 2 3 4 5 6 7 8 9 10))
  323. ⇒ (1 2 3 4 5 6 7 8 9)
  324. -- Function: -remove-item (item list)
  325. Return a copy of LIST with all occurrences of ITEM removed. The
  326. comparison is done with ‘equal’.
  327. (-remove-item 3 '(1 2 3 2 3 4 5 3))
  328. ⇒ (1 2 2 4 5)
  329. (-remove-item 'foo '(foo bar baz foo))
  330. ⇒ (bar baz)
  331. (-remove-item "bob" '("alice" "bob" "eve" "bob"))
  332. ⇒ ("alice" "eve")
  333. -- Function: -non-nil (list)
  334. Return a copy of LIST with all nil items removed.
  335. (-non-nil '(nil 1 nil 2 nil nil 3 4 nil 5 nil))
  336. ⇒ (1 2 3 4 5)
  337. (-non-nil '((nil)))
  338. ⇒ ((nil))
  339. (-non-nil ())
  340. ⇒ ()
  341. -- Function: -slice (list from &optional to step)
  342. Return copy of LIST, starting from index FROM to index TO.
  343. FROM or TO may be negative. These values are then interpreted
  344. modulo the length of the list.
  345. If STEP is a number, only each STEPth item in the resulting section
  346. is returned. Defaults to 1.
  347. (-slice '(1 2 3 4 5) 1)
  348. ⇒ (2 3 4 5)
  349. (-slice '(1 2 3 4 5) 0 3)
  350. ⇒ (1 2 3)
  351. (-slice '(1 2 3 4 5 6 7 8 9) 1 -1 2)
  352. ⇒ (2 4 6 8)
  353. -- Function: -take (n list)
  354. Return a copy of the first N items in LIST. Return a copy of LIST
  355. if it contains N items or fewer. Return nil if N is zero or less.
  356. See also: ‘-take-last’ (*note -take-last::).
  357. (-take 3 '(1 2 3 4 5))
  358. ⇒ (1 2 3)
  359. (-take 17 '(1 2 3 4 5))
  360. ⇒ (1 2 3 4 5)
  361. (-take 0 '(1 2 3 4 5))
  362. ⇒ ()
  363. -- Function: -take-last (n list)
  364. Return a copy of the last N items of LIST in order. Return a copy
  365. of LIST if it contains N items or fewer. Return nil if N is zero
  366. or less.
  367. See also: ‘-take’ (*note -take::).
  368. (-take-last 3 '(1 2 3 4 5))
  369. ⇒ (3 4 5)
  370. (-take-last 17 '(1 2 3 4 5))
  371. ⇒ (1 2 3 4 5)
  372. (-take-last 1 '(1 2 3 4 5))
  373. ⇒ (5)
  374. -- Function: -drop (n list)
  375. Return the tail (not a copy) of LIST without the first N items.
  376. Return nil if LIST contains N items or fewer. Return LIST if N is
  377. zero or less.
  378. For another variant, see also ‘-drop-last’ (*note -drop-last::).
  379. (-drop 3 '(1 2 3 4 5))
  380. ⇒ (4 5)
  381. (-drop 17 '(1 2 3 4 5))
  382. ⇒ ()
  383. (-drop 0 '(1 2 3 4 5))
  384. ⇒ (1 2 3 4 5)
  385. -- Function: -drop-last (n list)
  386. Return a copy of LIST without its last N items. Return a copy of
  387. LIST if N is zero or less. Return nil if LIST contains N items or
  388. fewer.
  389. See also: ‘-drop’ (*note -drop::).
  390. (-drop-last 3 '(1 2 3 4 5))
  391. ⇒ (1 2)
  392. (-drop-last 17 '(1 2 3 4 5))
  393. ⇒ ()
  394. (-drop-last 0 '(1 2 3 4 5))
  395. ⇒ (1 2 3 4 5)
  396. -- Function: -take-while (pred list)
  397. Take successive items from LIST for which PRED returns non-nil.
  398. PRED is a function of one argument. Return a new list of the
  399. successive elements from the start of LIST for which PRED returns
  400. non-nil.
  401. This function’s anaphoric counterpart is ‘--take-while’.
  402. For another variant, see also ‘-drop-while’ (*note -drop-while::).
  403. (-take-while #'even? '(1 2 3 4))
  404. ⇒ ()
  405. (-take-while #'even? '(2 4 5 6))
  406. ⇒ (2 4)
  407. (--take-while (< it 4) '(1 2 3 4 3 2 1))
  408. ⇒ (1 2 3)
  409. -- Function: -drop-while (pred list)
  410. Drop successive items from LIST for which PRED returns non-nil.
  411. PRED is a function of one argument. Return the tail (not a copy)
  412. of LIST starting from its first element for which PRED returns nil.
  413. This function’s anaphoric counterpart is ‘--drop-while’.
  414. For another variant, see also ‘-take-while’ (*note -take-while::).
  415. (-drop-while #'even? '(1 2 3 4))
  416. ⇒ (1 2 3 4)
  417. (-drop-while #'even? '(2 4 5 6))
  418. ⇒ (5 6)
  419. (--drop-while (< it 4) '(1 2 3 4 3 2 1))
  420. ⇒ (4 3 2 1)
  421. -- Function: -select-by-indices (indices list)
  422. Return a list whose elements are elements from LIST selected as
  423. ‘(nth i list)‘ for all i from INDICES.
  424. (-select-by-indices '(4 10 2 3 6) '("v" "e" "l" "o" "c" "i" "r" "a" "p" "t" "o" "r"))
  425. ⇒ ("c" "o" "l" "o" "r")
  426. (-select-by-indices '(2 1 0) '("a" "b" "c"))
  427. ⇒ ("c" "b" "a")
  428. (-select-by-indices '(0 1 2 0 1 3 3 1) '("f" "a" "r" "l"))
  429. ⇒ ("f" "a" "r" "f" "a" "l" "l" "a")
  430. -- Function: -select-columns (columns table)
  431. Select COLUMNS from TABLE.
  432. TABLE is a list of lists where each element represents one row. It
  433. is assumed each row has the same length.
  434. Each row is transformed such that only the specified COLUMNS are
  435. selected.
  436. See also: ‘-select-column’ (*note -select-column::),
  437. ‘-select-by-indices’ (*note -select-by-indices::)
  438. (-select-columns '(0 2) '((1 2 3) (a b c) (:a :b :c)))
  439. ⇒ ((1 3) (a c) (:a :c))
  440. (-select-columns '(1) '((1 2 3) (a b c) (:a :b :c)))
  441. ⇒ ((2) (b) (:b))
  442. (-select-columns nil '((1 2 3) (a b c) (:a :b :c)))
  443. ⇒ (nil nil nil)
  444. -- Function: -select-column (column table)
  445. Select COLUMN from TABLE.
  446. TABLE is a list of lists where each element represents one row. It
  447. is assumed each row has the same length.
  448. The single selected column is returned as a list.
  449. See also: ‘-select-columns’ (*note -select-columns::),
  450. ‘-select-by-indices’ (*note -select-by-indices::)
  451. (-select-column 1 '((1 2 3) (a b c) (:a :b :c)))
  452. ⇒ (2 b :b)
  453. 
  454. File: dash.info, Node: List to list, Next: Reductions, Prev: Sublist selection, Up: Functions
  455. 2.3 List to list
  456. ================
  457. Functions returning a modified copy of the input list.
  458. -- Function: -keep (fn list)
  459. Return a new list of the non-nil results of applying FN to each
  460. item in LIST. Like ‘-filter’ (*note -filter::), but returns the
  461. non-nil results of FN instead of the corresponding elements of
  462. LIST.
  463. Its anaphoric counterpart is ‘--keep’.
  464. (-keep #'cdr '((1 2 3) (4 5) (6)))
  465. ⇒ ((2 3) (5))
  466. (-keep (lambda (n) (and (> n 3) (* 10 n))) '(1 2 3 4 5 6))
  467. ⇒ (40 50 60)
  468. (--keep (and (> it 3) (* 10 it)) '(1 2 3 4 5 6))
  469. ⇒ (40 50 60)
  470. -- Function: -concat (&rest lists)
  471. Return a new list with the concatenation of the elements in the
  472. supplied LISTS.
  473. (-concat '(1))
  474. ⇒ (1)
  475. (-concat '(1) '(2))
  476. ⇒ (1 2)
  477. (-concat '(1) '(2 3) '(4))
  478. ⇒ (1 2 3 4)
  479. -- Function: -flatten (l)
  480. Take a nested list L and return its contents as a single, flat
  481. list.
  482. Note that because ‘nil’ represents a list of zero elements (an
  483. empty list), any mention of nil in L will disappear after
  484. flattening. If you need to preserve nils, consider ‘-flatten-n’
  485. (*note -flatten-n::) or map them to some unique symbol and then map
  486. them back.
  487. Conses of two atoms are considered "terminals", that is, they
  488. aren’t flattened further.
  489. See also: ‘-flatten-n’ (*note -flatten-n::)
  490. (-flatten '((1)))
  491. ⇒ (1)
  492. (-flatten '((1 (2 3) (((4 (5)))))))
  493. ⇒ (1 2 3 4 5)
  494. (-flatten '(1 2 (3 . 4)))
  495. ⇒ (1 2 (3 . 4))
  496. -- Function: -flatten-n (num list)
  497. Flatten NUM levels of a nested LIST.
  498. See also: ‘-flatten’ (*note -flatten::)
  499. (-flatten-n 1 '((1 2) ((3 4) ((5 6)))))
  500. ⇒ (1 2 (3 4) ((5 6)))
  501. (-flatten-n 2 '((1 2) ((3 4) ((5 6)))))
  502. ⇒ (1 2 3 4 (5 6))
  503. (-flatten-n 3 '((1 2) ((3 4) ((5 6)))))
  504. ⇒ (1 2 3 4 5 6)
  505. -- Function: -replace (old new list)
  506. Replace all OLD items in LIST with NEW.
  507. Elements are compared using ‘equal’.
  508. See also: ‘-replace-at’ (*note -replace-at::)
  509. (-replace 1 "1" '(1 2 3 4 3 2 1))
  510. ⇒ ("1" 2 3 4 3 2 "1")
  511. (-replace "foo" "bar" '("a" "nice" "foo" "sentence" "about" "foo"))
  512. ⇒ ("a" "nice" "bar" "sentence" "about" "bar")
  513. (-replace 1 2 nil)
  514. ⇒ nil
  515. -- Function: -replace-first (old new list)
  516. Replace the first occurrence of OLD with NEW in LIST.
  517. Elements are compared using ‘equal’.
  518. See also: ‘-map-first’ (*note -map-first::)
  519. (-replace-first 1 "1" '(1 2 3 4 3 2 1))
  520. ⇒ ("1" 2 3 4 3 2 1)
  521. (-replace-first "foo" "bar" '("a" "nice" "foo" "sentence" "about" "foo"))
  522. ⇒ ("a" "nice" "bar" "sentence" "about" "foo")
  523. (-replace-first 1 2 nil)
  524. ⇒ nil
  525. -- Function: -replace-last (old new list)
  526. Replace the last occurrence of OLD with NEW in LIST.
  527. Elements are compared using ‘equal’.
  528. See also: ‘-map-last’ (*note -map-last::)
  529. (-replace-last 1 "1" '(1 2 3 4 3 2 1))
  530. ⇒ (1 2 3 4 3 2 "1")
  531. (-replace-last "foo" "bar" '("a" "nice" "foo" "sentence" "about" "foo"))
  532. ⇒ ("a" "nice" "foo" "sentence" "about" "bar")
  533. (-replace-last 1 2 nil)
  534. ⇒ nil
  535. -- Function: -insert-at (n x list)
  536. Return a list with X inserted into LIST at position N.
  537. See also: ‘-splice’ (*note -splice::), ‘-splice-list’ (*note
  538. -splice-list::)
  539. (-insert-at 1 'x '(a b c))
  540. ⇒ (a x b c)
  541. (-insert-at 12 'x '(a b c))
  542. ⇒ (a b c x)
  543. -- Function: -replace-at (n x list)
  544. Return a list with element at Nth position in LIST replaced with X.
  545. See also: ‘-replace’ (*note -replace::)
  546. (-replace-at 0 9 '(0 1 2 3 4 5))
  547. ⇒ (9 1 2 3 4 5)
  548. (-replace-at 1 9 '(0 1 2 3 4 5))
  549. ⇒ (0 9 2 3 4 5)
  550. (-replace-at 4 9 '(0 1 2 3 4 5))
  551. ⇒ (0 1 2 3 9 5)
  552. -- Function: -update-at (n func list)
  553. Return a list with element at Nth position in LIST replaced with
  554. ‘(func (nth n list))‘.
  555. See also: ‘-map-when’ (*note -map-when::)
  556. (-update-at 0 (lambda (x) (+ x 9)) '(0 1 2 3 4 5))
  557. ⇒ (9 1 2 3 4 5)
  558. (-update-at 1 (lambda (x) (+ x 8)) '(0 1 2 3 4 5))
  559. ⇒ (0 9 2 3 4 5)
  560. (--update-at 2 (length it) '("foo" "bar" "baz" "quux"))
  561. ⇒ ("foo" "bar" 3 "quux")
  562. -- Function: -remove-at (n list)
  563. Return a list with element at Nth position in LIST removed.
  564. See also: ‘-remove-at-indices’ (*note -remove-at-indices::),
  565. ‘-remove’ (*note -remove::)
  566. (-remove-at 0 '("0" "1" "2" "3" "4" "5"))
  567. ⇒ ("1" "2" "3" "4" "5")
  568. (-remove-at 1 '("0" "1" "2" "3" "4" "5"))
  569. ⇒ ("0" "2" "3" "4" "5")
  570. (-remove-at 2 '("0" "1" "2" "3" "4" "5"))
  571. ⇒ ("0" "1" "3" "4" "5")
  572. -- Function: -remove-at-indices (indices list)
  573. Return a list whose elements are elements from LIST without
  574. elements selected as ‘(nth i list)‘ for all i from INDICES.
  575. See also: ‘-remove-at’ (*note -remove-at::), ‘-remove’ (*note
  576. -remove::)
  577. (-remove-at-indices '(0) '("0" "1" "2" "3" "4" "5"))
  578. ⇒ ("1" "2" "3" "4" "5")
  579. (-remove-at-indices '(0 2 4) '("0" "1" "2" "3" "4" "5"))
  580. ⇒ ("1" "3" "5")
  581. (-remove-at-indices '(0 5) '("0" "1" "2" "3" "4" "5"))
  582. ⇒ ("1" "2" "3" "4")
  583. 
  584. File: dash.info, Node: Reductions, Next: Unfolding, Prev: List to list, Up: Functions
  585. 2.4 Reductions
  586. ==============
  587. Functions reducing lists to a single value (which may also be a list).
  588. -- Function: -reduce-from (fn init list)
  589. Reduce the function FN across LIST, starting with INIT. Return the
  590. result of applying FN to INIT and the first element of LIST, then
  591. applying FN to that result and the second element, etc. If LIST is
  592. empty, return INIT without calling FN.
  593. This function’s anaphoric counterpart is ‘--reduce-from’.
  594. For other folds, see also ‘-reduce’ (*note -reduce::) and
  595. ‘-reduce-r’ (*note -reduce-r::).
  596. (-reduce-from #'- 10 '(1 2 3))
  597. ⇒ 4
  598. (-reduce-from #'list 10 '(1 2 3))
  599. ⇒ (((10 1) 2) 3)
  600. (--reduce-from (concat acc " " it) "START" '("a" "b" "c"))
  601. ⇒ "START a b c"
  602. -- Function: -reduce-r-from (fn init list)
  603. Reduce the function FN across LIST in reverse, starting with INIT.
  604. Return the result of applying FN to the last element of LIST and
  605. INIT, then applying FN to the second-to-last element and the
  606. previous result of FN, etc. That is, the first argument of FN is
  607. the current element, and its second argument the accumulated value.
  608. If LIST is empty, return INIT without calling FN.
  609. This function is like ‘-reduce-from’ (*note -reduce-from::) but the
  610. operation associates from the right rather than left. In other
  611. words, it starts from the end of LIST and flips the arguments to
  612. FN. Conceptually, it is like replacing the conses in LIST with
  613. applications of FN, and its last link with INIT, and evaluating the
  614. resulting expression.
  615. This function’s anaphoric counterpart is ‘--reduce-r-from’.
  616. For other folds, see also ‘-reduce-r’ (*note -reduce-r::) and
  617. ‘-reduce’ (*note -reduce::).
  618. (-reduce-r-from #'- 10 '(1 2 3))
  619. ⇒ -8
  620. (-reduce-r-from #'list 10 '(1 2 3))
  621. ⇒ (1 (2 (3 10)))
  622. (--reduce-r-from (concat it " " acc) "END" '("a" "b" "c"))
  623. ⇒ "a b c END"
  624. -- Function: -reduce (fn list)
  625. Reduce the function FN across LIST. Return the result of applying
  626. FN to the first two elements of LIST, then applying FN to that
  627. result and the third element, etc. If LIST contains a single
  628. element, return it without calling FN. If LIST is empty, return
  629. the result of calling FN with no arguments.
  630. This function’s anaphoric counterpart is ‘--reduce’.
  631. For other folds, see also ‘-reduce-from’ (*note -reduce-from::) and
  632. ‘-reduce-r’ (*note -reduce-r::).
  633. (-reduce #'- '(1 2 3 4))
  634. ⇒ -8
  635. (-reduce #'list '(1 2 3 4))
  636. ⇒ (((1 2) 3) 4)
  637. (--reduce (format "%s-%d" acc it) '(1 2 3))
  638. ⇒ "1-2-3"
  639. -- Function: -reduce-r (fn list)
  640. Reduce the function FN across LIST in reverse. Return the result
  641. of applying FN to the last two elements of LIST, then applying FN
  642. to the third-to-last element and the previous result of FN, etc.
  643. That is, the first argument of FN is the current element, and its
  644. second argument the accumulated value. If LIST contains a single
  645. element, return it without calling FN. If LIST is empty, return
  646. the result of calling FN with no arguments.
  647. This function is like ‘-reduce’ (*note -reduce::) but the operation
  648. associates from the right rather than left. In other words, it
  649. starts from the end of LIST and flips the arguments to FN.
  650. Conceptually, it is like replacing the conses in LIST with
  651. applications of FN, ignoring its last link, and evaluating the
  652. resulting expression.
  653. This function’s anaphoric counterpart is ‘--reduce-r’.
  654. For other folds, see also ‘-reduce-r-from’ (*note -reduce-r-from::)
  655. and ‘-reduce’ (*note -reduce::).
  656. (-reduce-r #'- '(1 2 3 4))
  657. ⇒ -2
  658. (-reduce-r #'list '(1 2 3 4))
  659. ⇒ (1 (2 (3 4)))
  660. (--reduce-r (format "%s-%d" acc it) '(1 2 3))
  661. ⇒ "3-2-1"
  662. -- Function: -reductions-from (fn init list)
  663. Return a list of FN’s intermediate reductions across LIST. That
  664. is, a list of the intermediate values of the accumulator when
  665. ‘-reduce-from’ (*note -reduce-from::) (which see) is called with
  666. the same arguments.
  667. This function’s anaphoric counterpart is ‘--reductions-from’.
  668. For other folds, see also ‘-reductions’ (*note -reductions::) and
  669. ‘-reductions-r’ (*note -reductions-r::).
  670. (-reductions-from #'max 0 '(2 1 4 3))
  671. ⇒ (0 2 2 4 4)
  672. (-reductions-from #'* 1 '(1 2 3 4))
  673. ⇒ (1 1 2 6 24)
  674. (--reductions-from (format "(FN %s %d)" acc it) "INIT" '(1 2 3))
  675. ⇒ ("INIT" "(FN INIT 1)" "(FN (FN INIT 1) 2)" "(FN (FN (FN INIT 1) 2) 3)")
  676. -- Function: -reductions-r-from (fn init list)
  677. Return a list of FN’s intermediate reductions across reversed LIST.
  678. That is, a list of the intermediate values of the accumulator when
  679. ‘-reduce-r-from’ (*note -reduce-r-from::) (which see) is called
  680. with the same arguments.
  681. This function’s anaphoric counterpart is ‘--reductions-r-from’.
  682. For other folds, see also ‘-reductions’ (*note -reductions::) and
  683. ‘-reductions-r’ (*note -reductions-r::).
  684. (-reductions-r-from #'max 0 '(2 1 4 3))
  685. ⇒ (4 4 4 3 0)
  686. (-reductions-r-from #'* 1 '(1 2 3 4))
  687. ⇒ (24 24 12 4 1)
  688. (--reductions-r-from (format "(FN %d %s)" it acc) "INIT" '(1 2 3))
  689. ⇒ ("(FN 1 (FN 2 (FN 3 INIT)))" "(FN 2 (FN 3 INIT))" "(FN 3 INIT)" "INIT")
  690. -- Function: -reductions (fn list)
  691. Return a list of FN’s intermediate reductions across LIST. That
  692. is, a list of the intermediate values of the accumulator when
  693. ‘-reduce’ (*note -reduce::) (which see) is called with the same
  694. arguments.
  695. This function’s anaphoric counterpart is ‘--reductions’.
  696. For other folds, see also ‘-reductions’ (*note -reductions::) and
  697. ‘-reductions-r’ (*note -reductions-r::).
  698. (-reductions #'+ '(1 2 3 4))
  699. ⇒ (1 3 6 10)
  700. (-reductions #'* '(1 2 3 4))
  701. ⇒ (1 2 6 24)
  702. (--reductions (format "(FN %s %d)" acc it) '(1 2 3))
  703. ⇒ (1 "(FN 1 2)" "(FN (FN 1 2) 3)")
  704. -- Function: -reductions-r (fn list)
  705. Return a list of FN’s intermediate reductions across reversed LIST.
  706. That is, a list of the intermediate values of the accumulator when
  707. ‘-reduce-r’ (*note -reduce-r::) (which see) is called with the same
  708. arguments.
  709. This function’s anaphoric counterpart is ‘--reductions-r’.
  710. For other folds, see also ‘-reductions-r-from’ (*note
  711. -reductions-r-from::) and ‘-reductions’ (*note -reductions::).
  712. (-reductions-r #'+ '(1 2 3 4))
  713. ⇒ (10 9 7 4)
  714. (-reductions-r #'* '(1 2 3 4))
  715. ⇒ (24 24 12 4)
  716. (--reductions-r (format "(FN %d %s)" it acc) '(1 2 3))
  717. ⇒ ("(FN 1 (FN 2 3))" "(FN 2 3)" 3)
  718. -- Function: -count (pred list)
  719. Counts the number of items in LIST where (PRED item) is non-nil.
  720. (-count 'even? '(1 2 3 4 5))
  721. ⇒ 2
  722. (--count (< it 4) '(1 2 3 4))
  723. ⇒ 3
  724. -- Function: -sum (list)
  725. Return the sum of LIST.
  726. (-sum ())
  727. ⇒ 0
  728. (-sum '(1))
  729. ⇒ 1
  730. (-sum '(1 2 3 4))
  731. ⇒ 10
  732. -- Function: -running-sum (list)
  733. Return a list with running sums of items in LIST. LIST must be
  734. non-empty.
  735. (-running-sum '(1 2 3 4))
  736. ⇒ (1 3 6 10)
  737. (-running-sum '(1))
  738. ⇒ (1)
  739. (-running-sum ())
  740. error→ Wrong type argument: consp, nil
  741. -- Function: -product (list)
  742. Return the product of LIST.
  743. (-product ())
  744. ⇒ 1
  745. (-product '(1))
  746. ⇒ 1
  747. (-product '(1 2 3 4))
  748. ⇒ 24
  749. -- Function: -running-product (list)
  750. Return a list with running products of items in LIST. LIST must be
  751. non-empty.
  752. (-running-product '(1 2 3 4))
  753. ⇒ (1 2 6 24)
  754. (-running-product '(1))
  755. ⇒ (1)
  756. (-running-product ())
  757. error→ Wrong type argument: consp, nil
  758. -- Function: -inits (list)
  759. Return all prefixes of LIST.
  760. (-inits '(1 2 3 4))
  761. ⇒ (nil (1) (1 2) (1 2 3) (1 2 3 4))
  762. (-inits nil)
  763. ⇒ (nil)
  764. (-inits '(1))
  765. ⇒ (nil (1))
  766. -- Function: -tails (list)
  767. Return all suffixes of LIST
  768. (-tails '(1 2 3 4))
  769. ⇒ ((1 2 3 4) (2 3 4) (3 4) (4) nil)
  770. (-tails nil)
  771. ⇒ (nil)
  772. (-tails '(1))
  773. ⇒ ((1) nil)
  774. -- Function: -common-prefix (&rest lists)
  775. Return the longest common prefix of LISTS.
  776. (-common-prefix '(1))
  777. ⇒ (1)
  778. (-common-prefix '(1 2) '(3 4) '(1 2))
  779. ⇒ ()
  780. (-common-prefix '(1 2) '(1 2 3) '(1 2 3 4))
  781. ⇒ (1 2)
  782. -- Function: -common-suffix (&rest lists)
  783. Return the longest common suffix of LISTS.
  784. (-common-suffix '(1))
  785. ⇒ (1)
  786. (-common-suffix '(1 2) '(3 4) '(1 2))
  787. ⇒ ()
  788. (-common-suffix '(1 2 3 4) '(2 3 4) '(3 4))
  789. ⇒ (3 4)
  790. -- Function: -min (list)
  791. Return the smallest value from LIST of numbers or markers.
  792. (-min '(0))
  793. ⇒ 0
  794. (-min '(3 2 1))
  795. ⇒ 1
  796. (-min '(1 2 3))
  797. ⇒ 1
  798. -- Function: -min-by (comparator list)
  799. Take a comparison function COMPARATOR and a LIST and return the
  800. least element of the list by the comparison function.
  801. See also combinator ‘-on’ (*note -on::) which can transform the
  802. values before comparing them.
  803. (-min-by '> '(4 3 6 1))
  804. ⇒ 1
  805. (--min-by (> (car it) (car other)) '((1 2 3) (2) (3 2)))
  806. ⇒ (1 2 3)
  807. (--min-by (> (length it) (length other)) '((1 2 3) (2) (3 2)))
  808. ⇒ (2)
  809. -- Function: -max (list)
  810. Return the largest value from LIST of numbers or markers.
  811. (-max '(0))
  812. ⇒ 0
  813. (-max '(3 2 1))
  814. ⇒ 3
  815. (-max '(1 2 3))
  816. ⇒ 3
  817. -- Function: -max-by (comparator list)
  818. Take a comparison function COMPARATOR and a LIST and return the
  819. greatest element of the list by the comparison function.
  820. See also combinator ‘-on’ (*note -on::) which can transform the
  821. values before comparing them.
  822. (-max-by '> '(4 3 6 1))
  823. ⇒ 6
  824. (--max-by (> (car it) (car other)) '((1 2 3) (2) (3 2)))
  825. ⇒ (3 2)
  826. (--max-by (> (length it) (length other)) '((1 2 3) (2) (3 2)))
  827. ⇒ (1 2 3)
  828. 
  829. File: dash.info, Node: Unfolding, Next: Predicates, Prev: Reductions, Up: Functions
  830. 2.5 Unfolding
  831. =============
  832. Operations dual to reductions, building lists from a seed value rather
  833. than consuming a list to produce a single value.
  834. -- Function: -iterate (fun init n)
  835. Return a list of iterated applications of FUN to INIT.
  836. This means a list of the form:
  837. (INIT (FUN INIT) (FUN (FUN INIT)) ...)
  838. N is the length of the returned list.
  839. (-iterate #'1+ 1 10)
  840. ⇒ (1 2 3 4 5 6 7 8 9 10)
  841. (-iterate (lambda (x) (+ x x)) 2 5)
  842. ⇒ (2 4 8 16 32)
  843. (--iterate (* it it) 2 5)
  844. ⇒ (2 4 16 256 65536)
  845. -- Function: -unfold (fun seed)
  846. Build a list from SEED using FUN.
  847. This is "dual" operation to ‘-reduce-r’ (*note -reduce-r::): while
  848. -reduce-r consumes a list to produce a single value, ‘-unfold’
  849. (*note -unfold::) takes a seed value and builds a (potentially
  850. infinite!) list.
  851. FUN should return ‘nil’ to stop the generating process, or a cons
  852. (A . B), where A will be prepended to the result and B is the new
  853. seed.
  854. (-unfold (lambda (x) (unless (= x 0) (cons x (1- x)))) 10)
  855. ⇒ (10 9 8 7 6 5 4 3 2 1)
  856. (--unfold (when it (cons it (cdr it))) '(1 2 3 4))
  857. ⇒ ((1 2 3 4) (2 3 4) (3 4) (4))
  858. (--unfold (when it (cons it (butlast it))) '(1 2 3 4))
  859. ⇒ ((1 2 3 4) (1 2 3) (1 2) (1))
  860. 
  861. File: dash.info, Node: Predicates, Next: Partitioning, Prev: Unfolding, Up: Functions
  862. 2.6 Predicates
  863. ==============
  864. Reductions of one or more lists to a boolean value.
  865. -- Function: -any? (pred list)
  866. Return t if (PRED x) is non-nil for any x in LIST, else nil.
  867. Alias: ‘-any-p’, ‘-some?’, ‘-some-p’
  868. (-any? 'even? '(1 2 3))
  869. ⇒ t
  870. (-any? 'even? '(1 3 5))
  871. ⇒ nil
  872. (-any? 'null '(1 3 5))
  873. ⇒ nil
  874. -- Function: -all? (pred list)
  875. Return t if (PRED x) is non-nil for all x in LIST, else nil.
  876. Alias: ‘-all-p’, ‘-every?’, ‘-every-p’
  877. (-all? 'even? '(1 2 3))
  878. ⇒ nil
  879. (-all? 'even? '(2 4 6))
  880. ⇒ t
  881. (--all? (= 0 (% it 2)) '(2 4 6))
  882. ⇒ t
  883. -- Function: -none? (pred list)
  884. Return t if (PRED x) is nil for all x in LIST, else nil.
  885. Alias: ‘-none-p’
  886. (-none? 'even? '(1 2 3))
  887. ⇒ nil
  888. (-none? 'even? '(1 3 5))
  889. ⇒ t
  890. (--none? (= 0 (% it 2)) '(1 2 3))
  891. ⇒ nil
  892. -- Function: -only-some? (pred list)
  893. Return ‘t‘ if at least one item of LIST matches PRED and at least
  894. one item of LIST does not match PRED. Return ‘nil‘ both if all
  895. items match the predicate or if none of the items match the
  896. predicate.
  897. Alias: ‘-only-some-p’
  898. (-only-some? 'even? '(1 2 3))
  899. ⇒ t
  900. (-only-some? 'even? '(1 3 5))
  901. ⇒ nil
  902. (-only-some? 'even? '(2 4 6))
  903. ⇒ nil
  904. -- Function: -contains? (list element)
  905. Return non-nil if LIST contains ELEMENT.
  906. The test for equality is done with ‘equal’, or with ‘-compare-fn’
  907. if that’s non-nil.
  908. Alias: ‘-contains-p’
  909. (-contains? '(1 2 3) 1)
  910. ⇒ t
  911. (-contains? '(1 2 3) 2)
  912. ⇒ t
  913. (-contains? '(1 2 3) 4)
  914. ⇒ nil
  915. -- Function: -same-items? (list list2)
  916. Return true if LIST and LIST2 has the same items.
  917. The order of the elements in the lists does not matter.
  918. Alias: ‘-same-items-p’
  919. (-same-items? '(1 2 3) '(1 2 3))
  920. ⇒ t
  921. (-same-items? '(1 2 3) '(3 2 1))
  922. ⇒ t
  923. (-same-items? '(1 2 3) '(1 2 3 4))
  924. ⇒ nil
  925. -- Function: -is-prefix? (prefix list)
  926. Return non-nil if PREFIX is a prefix of LIST.
  927. Alias: ‘-is-prefix-p’.
  928. (-is-prefix? '(1 2 3) '(1 2 3 4 5))
  929. ⇒ t
  930. (-is-prefix? '(1 2 3 4 5) '(1 2 3))
  931. ⇒ nil
  932. (-is-prefix? '(1 3) '(1 2 3 4 5))
  933. ⇒ nil
  934. -- Function: -is-suffix? (suffix list)
  935. Return non-nil if SUFFIX is a suffix of LIST.
  936. Alias: ‘-is-suffix-p’.
  937. (-is-suffix? '(3 4 5) '(1 2 3 4 5))
  938. ⇒ t
  939. (-is-suffix? '(1 2 3 4 5) '(3 4 5))
  940. ⇒ nil
  941. (-is-suffix? '(3 5) '(1 2 3 4 5))
  942. ⇒ nil
  943. -- Function: -is-infix? (infix list)
  944. Return non-nil if INFIX is infix of LIST.
  945. This operation runs in O(n^2) time
  946. Alias: ‘-is-infix-p’
  947. (-is-infix? '(1 2 3) '(1 2 3 4 5))
  948. ⇒ t
  949. (-is-infix? '(2 3 4) '(1 2 3 4 5))
  950. ⇒ t
  951. (-is-infix? '(3 4 5) '(1 2 3 4 5))
  952. ⇒ t
  953. -- Function: -cons-pair? (obj)
  954. Return non-nil if OBJ is a true cons pair. That is, a cons (A .
  955. B) where B is not a list.
  956. Alias: ‘-cons-pair-p’.
  957. (-cons-pair? '(1 . 2))
  958. ⇒ t
  959. (-cons-pair? '(1 2))
  960. ⇒ nil
  961. (-cons-pair? '(1))
  962. ⇒ nil
  963. 
  964. File: dash.info, Node: Partitioning, Next: Indexing, Prev: Predicates, Up: Functions
  965. 2.7 Partitioning
  966. ================
  967. Functions partitioning the input list into a list of lists.
  968. -- Function: -split-at (n list)
  969. Split LIST into two sublists after the Nth element. The result is
  970. a list of two elements (TAKE DROP) where TAKE is a new list of the
  971. first N elements of LIST, and DROP is the remaining elements of
  972. LIST (not a copy). TAKE and DROP are like the results of ‘-take’
  973. (*note -take::) and ‘-drop’ (*note -drop::), respectively, but the
  974. split is done in a single list traversal.
  975. (-split-at 3 '(1 2 3 4 5))
  976. ⇒ ((1 2 3) (4 5))
  977. (-split-at 17 '(1 2 3 4 5))
  978. ⇒ ((1 2 3 4 5) nil)
  979. (-split-at 0 '(1 2 3 4 5))
  980. ⇒ (nil (1 2 3 4 5))
  981. -- Function: -split-with (pred list)
  982. Return a list of ((-take-while PRED LIST) (-drop-while PRED LIST)),
  983. in no more than one pass through the list.
  984. (-split-with 'even? '(1 2 3 4))
  985. ⇒ (nil (1 2 3 4))
  986. (-split-with 'even? '(2 4 5 6))
  987. ⇒ ((2 4) (5 6))
  988. (--split-with (< it 4) '(1 2 3 4 3 2 1))
  989. ⇒ ((1 2 3) (4 3 2 1))
  990. -- Macro: -split-on (item list)
  991. Split the LIST each time ITEM is found.
  992. Unlike ‘-partition-by’ (*note -partition-by::), the ITEM is
  993. discarded from the results. Empty lists are also removed from the
  994. result.
  995. Comparison is done by ‘equal’.
  996. See also ‘-split-when’ (*note -split-when::)
  997. (-split-on '| '(Nil | Leaf a | Node [Tree a]))
  998. ⇒ ((Nil) (Leaf a) (Node [Tree a]))
  999. (-split-on ':endgroup '("a" "b" :endgroup "c" :endgroup "d" "e"))
  1000. ⇒ (("a" "b") ("c") ("d" "e"))
  1001. (-split-on ':endgroup '("a" "b" :endgroup :endgroup "d" "e"))
  1002. ⇒ (("a" "b") ("d" "e"))
  1003. -- Function: -split-when (fn list)
  1004. Split the LIST on each element where FN returns non-nil.
  1005. Unlike ‘-partition-by’ (*note -partition-by::), the "matched"
  1006. element is discarded from the results. Empty lists are also
  1007. removed from the result.
  1008. This function can be thought of as a generalization of
  1009. ‘split-string’.
  1010. (-split-when 'even? '(1 2 3 4 5 6))
  1011. ⇒ ((1) (3) (5))
  1012. (-split-when 'even? '(1 2 3 4 6 8 9))
  1013. ⇒ ((1) (3) (9))
  1014. (--split-when (memq it '(&optional &rest)) '(a b &optional c d &rest args))
  1015. ⇒ ((a b) (c d) (args))
  1016. -- Function: -separate (pred list)
  1017. Return a list of ((-filter PRED LIST) (-remove PRED LIST)), in one
  1018. pass through the list.
  1019. (-separate (lambda (num) (= 0 (% num 2))) '(1 2 3 4 5 6 7))
  1020. ⇒ ((2 4 6) (1 3 5 7))
  1021. (--separate (< it 5) '(3 7 5 9 3 2 1 4 6))
  1022. ⇒ ((3 3 2 1 4) (7 5 9 6))
  1023. (-separate 'cdr '((1 2) (1) (1 2 3) (4)))
  1024. ⇒ (((1 2) (1 2 3)) ((1) (4)))
  1025. -- Function: -partition (n list)
  1026. Return a new list with the items in LIST grouped into N-sized
  1027. sublists. If there are not enough items to make the last group
  1028. N-sized, those items are discarded.
  1029. (-partition 2 '(1 2 3 4 5 6))
  1030. ⇒ ((1 2) (3 4) (5 6))
  1031. (-partition 2 '(1 2 3 4 5 6 7))
  1032. ⇒ ((1 2) (3 4) (5 6))
  1033. (-partition 3 '(1 2 3 4 5 6 7))
  1034. ⇒ ((1 2 3) (4 5 6))
  1035. -- Function: -partition-all (n list)
  1036. Return a new list with the items in LIST grouped into N-sized
  1037. sublists. The last group may contain less than N items.
  1038. (-partition-all 2 '(1 2 3 4 5 6))
  1039. ⇒ ((1 2) (3 4) (5 6))
  1040. (-partition-all 2 '(1 2 3 4 5 6 7))
  1041. ⇒ ((1 2) (3 4) (5 6) (7))
  1042. (-partition-all 3 '(1 2 3 4 5 6 7))
  1043. ⇒ ((1 2 3) (4 5 6) (7))
  1044. -- Function: -partition-in-steps (n step list)
  1045. Return a new list with the items in LIST grouped into N-sized
  1046. sublists at offsets STEP apart. If there are not enough items to
  1047. make the last group N-sized, those items are discarded.
  1048. (-partition-in-steps 2 1 '(1 2 3 4))
  1049. ⇒ ((1 2) (2 3) (3 4))
  1050. (-partition-in-steps 3 2 '(1 2 3 4))
  1051. ⇒ ((1 2 3))
  1052. (-partition-in-steps 3 2 '(1 2 3 4 5))
  1053. ⇒ ((1 2 3) (3 4 5))
  1054. -- Function: -partition-all-in-steps (n step list)
  1055. Return a new list with the items in LIST grouped into N-sized
  1056. sublists at offsets STEP apart. The last groups may contain less
  1057. than N items.
  1058. (-partition-all-in-steps 2 1 '(1 2 3 4))
  1059. ⇒ ((1 2) (2 3) (3 4) (4))
  1060. (-partition-all-in-steps 3 2 '(1 2 3 4))
  1061. ⇒ ((1 2 3) (3 4))
  1062. (-partition-all-in-steps 3 2 '(1 2 3 4 5))
  1063. ⇒ ((1 2 3) (3 4 5) (5))
  1064. -- Function: -partition-by (fn list)
  1065. Apply FN to each item in LIST, splitting it each time FN returns a
  1066. new value.
  1067. (-partition-by 'even? ())
  1068. ⇒ ()
  1069. (-partition-by 'even? '(1 1 2 2 2 3 4 6 8))
  1070. ⇒ ((1 1) (2 2 2) (3) (4 6 8))
  1071. (--partition-by (< it 3) '(1 2 3 4 3 2 1))
  1072. ⇒ ((1 2) (3 4 3) (2 1))
  1073. -- Function: -partition-by-header (fn list)
  1074. Apply FN to the first item in LIST. That is the header value.
  1075. Apply FN to each item in LIST, splitting it each time FN returns
  1076. the header value, but only after seeing at least one other value
  1077. (the body).
  1078. (--partition-by-header (= it 1) '(1 2 3 1 2 1 2 3 4))
  1079. ⇒ ((1 2 3) (1 2) (1 2 3 4))
  1080. (--partition-by-header (> it 0) '(1 2 0 1 0 1 2 3 0))
  1081. ⇒ ((1 2 0) (1 0) (1 2 3 0))
  1082. (-partition-by-header 'even? '(2 1 1 1 4 1 3 5 6 6 1))
  1083. ⇒ ((2 1 1 1) (4 1 3 5) (6 6 1))
  1084. -- Function: -partition-after-pred (pred list)
  1085. Partition directly after each time PRED is true on an element of
  1086. LIST.
  1087. (-partition-after-pred #'booleanp ())
  1088. ⇒ ()
  1089. (-partition-after-pred #'booleanp '(t t))
  1090. ⇒ ((t) (t))
  1091. (-partition-after-pred #'booleanp '(0 0 t t 0 t))
  1092. ⇒ ((0 0 t) (t) (0 t))
  1093. -- Function: -partition-before-pred (pred list)
  1094. Partition directly before each time PRED is true on an element of
  1095. LIST.
  1096. (-partition-before-pred #'booleanp ())
  1097. ⇒ ()
  1098. (-partition-before-pred #'booleanp '(0 t))
  1099. ⇒ ((0) (t))
  1100. (-partition-before-pred #'booleanp '(0 0 t 0 t t))
  1101. ⇒ ((0 0) (t 0) (t) (t))
  1102. -- Function: -partition-before-item (item list)
  1103. Partition directly before each time ITEM appears in LIST.
  1104. (-partition-before-item 3 ())
  1105. ⇒ ()
  1106. (-partition-before-item 3 '(1))
  1107. ⇒ ((1))
  1108. (-partition-before-item 3 '(3))
  1109. ⇒ ((3))
  1110. -- Function: -partition-after-item (item list)
  1111. Partition directly after each time ITEM appears in LIST.
  1112. (-partition-after-item 3 ())
  1113. ⇒ ()
  1114. (-partition-after-item 3 '(1))
  1115. ⇒ ((1))
  1116. (-partition-after-item 3 '(3))
  1117. ⇒ ((3))
  1118. -- Function: -group-by (fn list)
  1119. Separate LIST into an alist whose keys are FN applied to the
  1120. elements of LIST. Keys are compared by ‘equal’.
  1121. (-group-by 'even? ())
  1122. ⇒ ()
  1123. (-group-by 'even? '(1 1 2 2 2 3 4 6 8))
  1124. ⇒ ((nil 1 1 3) (t 2 2 2 4 6 8))
  1125. (--group-by (car (split-string it "/")) '("a/b" "c/d" "a/e"))
  1126. ⇒ (("a" "a/b" "a/e") ("c" "c/d"))
  1127. 
  1128. File: dash.info, Node: Indexing, Next: Set operations, Prev: Partitioning, Up: Functions
  1129. 2.8 Indexing
  1130. ============
  1131. Functions retrieving or sorting based on list indices and related
  1132. predicates.
  1133. -- Function: -elem-index (elem list)
  1134. Return the index of the first element in the given LIST which is
  1135. equal to the query element ELEM, or nil if there is no such
  1136. element.
  1137. (-elem-index 2 '(6 7 8 2 3 4))
  1138. ⇒ 3
  1139. (-elem-index "bar" '("foo" "bar" "baz"))
  1140. ⇒ 1
  1141. (-elem-index '(1 2) '((3) (5 6) (1 2) nil))
  1142. ⇒ 2
  1143. -- Function: -elem-indices (elem list)
  1144. Return the indices of all elements in LIST equal to the query
  1145. element ELEM, in ascending order.
  1146. (-elem-indices 2 '(6 7 8 2 3 4 2 1))
  1147. ⇒ (3 6)
  1148. (-elem-indices "bar" '("foo" "bar" "baz"))
  1149. ⇒ (1)
  1150. (-elem-indices '(1 2) '((3) (1 2) (5 6) (1 2) nil))
  1151. ⇒ (1 3)
  1152. -- Function: -find-index (pred list)
  1153. Take a predicate PRED and a LIST and return the index of the first
  1154. element in the list satisfying the predicate, or nil if there is no
  1155. such element.
  1156. See also ‘-first’ (*note -first::).
  1157. (-find-index 'even? '(2 4 1 6 3 3 5 8))
  1158. ⇒ 0
  1159. (--find-index (< 5 it) '(2 4 1 6 3 3 5 8))
  1160. ⇒ 3
  1161. (-find-index (-partial 'string-lessp "baz") '("bar" "foo" "baz"))
  1162. ⇒ 1
  1163. -- Function: -find-last-index (pred list)
  1164. Take a predicate PRED and a LIST and return the index of the last
  1165. element in the list satisfying the predicate, or nil if there is no
  1166. such element.
  1167. See also ‘-last’ (*note -last::).
  1168. (-find-last-index 'even? '(2 4 1 6 3 3 5 8))
  1169. ⇒ 7
  1170. (--find-last-index (< 5 it) '(2 7 1 6 3 8 5 2))
  1171. ⇒ 5
  1172. (-find-last-index (-partial 'string-lessp "baz") '("q" "foo" "baz"))
  1173. ⇒ 1
  1174. -- Function: -find-indices (pred list)
  1175. Return the indices of all elements in LIST satisfying the predicate
  1176. PRED, in ascending order.
  1177. (-find-indices 'even? '(2 4 1 6 3 3 5 8))
  1178. ⇒ (0 1 3 7)
  1179. (--find-indices (< 5 it) '(2 4 1 6 3 3 5 8))
  1180. ⇒ (3 7)
  1181. (-find-indices (-partial 'string-lessp "baz") '("bar" "foo" "baz"))
  1182. ⇒ (1)
  1183. -- Function: -grade-up (comparator list)
  1184. Grade elements of LIST using COMPARATOR relation. This yields a
  1185. permutation vector such that applying this permutation to LIST
  1186. sorts it in ascending order.
  1187. (-grade-up #'< '(3 1 4 2 1 3 3))
  1188. ⇒ (1 4 3 0 5 6 2)
  1189. (let ((l '(3 1 4 2 1 3 3))) (-select-by-indices (-grade-up #'< l) l))
  1190. ⇒ (1 1 2 3 3 3 4)
  1191. -- Function: -grade-down (comparator list)
  1192. Grade elements of LIST using COMPARATOR relation. This yields a
  1193. permutation vector such that applying this permutation to LIST
  1194. sorts it in descending order.
  1195. (-grade-down #'< '(3 1 4 2 1 3 3))
  1196. ⇒ (2 0 5 6 3 1 4)
  1197. (let ((l '(3 1 4 2 1 3 3))) (-select-by-indices (-grade-down #'< l) l))
  1198. ⇒ (4 3 3 3 2 1 1)
  1199. 
  1200. File: dash.info, Node: Set operations, Next: Other list operations, Prev: Indexing, Up: Functions
  1201. 2.9 Set operations
  1202. ==================
  1203. Operations pretending lists are sets.
  1204. -- Function: -union (list list2)
  1205. Return a new list containing the elements of LIST and elements of
  1206. LIST2 that are not in LIST. The test for equality is done with
  1207. ‘equal’, or with ‘-compare-fn’ if that’s non-nil.
  1208. (-union '(1 2 3) '(3 4 5))
  1209. ⇒ (1 2 3 4 5)
  1210. (-union '(1 2 3 4) ())
  1211. ⇒ (1 2 3 4)
  1212. (-union '(1 1 2 2) '(3 2 1))
  1213. ⇒ (1 1 2 2 3)
  1214. -- Function: -difference (list list2)
  1215. Return a new list with only the members of LIST that are not in
  1216. LIST2. The test for equality is done with ‘equal’, or with
  1217. ‘-compare-fn’ if that’s non-nil.
  1218. (-difference () ())
  1219. ⇒ ()
  1220. (-difference '(1 2 3) '(4 5 6))
  1221. ⇒ (1 2 3)
  1222. (-difference '(1 2 3 4) '(3 4 5 6))
  1223. ⇒ (1 2)
  1224. -- Function: -intersection (list list2)
  1225. Return a new list containing only the elements that are members of
  1226. both LIST and LIST2. The test for equality is done with ‘equal’,
  1227. or with ‘-compare-fn’ if that’s non-nil.
  1228. (-intersection () ())
  1229. ⇒ ()
  1230. (-intersection '(1 2 3) '(4 5 6))
  1231. ⇒ ()
  1232. (-intersection '(1 2 3 4) '(3 4 5 6))
  1233. ⇒ (3 4)
  1234. -- Function: -powerset (list)
  1235. Return the power set of LIST.
  1236. (-powerset ())
  1237. ⇒ (nil)
  1238. (-powerset '(x y z))
  1239. ⇒ ((x y z) (x y) (x z) (x) (y z) (y) (z) nil)
  1240. -- Function: -permutations (list)
  1241. Return the permutations of LIST.
  1242. (-permutations ())
  1243. ⇒ (nil)
  1244. (-permutations '(1 2))
  1245. ⇒ ((1 2) (2 1))
  1246. (-permutations '(a b c))
  1247. ⇒ ((a b c) (a c b) (b a c) (b c a) (c a b) (c b a))
  1248. -- Function: -distinct (list)
  1249. Return a new list with all duplicates removed. The test for
  1250. equality is done with ‘equal’, or with ‘-compare-fn’ if that’s
  1251. non-nil.
  1252. Alias: ‘-uniq’
  1253. (-distinct ())
  1254. ⇒ ()
  1255. (-distinct '(1 2 2 4))
  1256. ⇒ (1 2 4)
  1257. (-distinct '(t t t))
  1258. ⇒ (t)
  1259. 
  1260. File: dash.info, Node: Other list operations, Next: Tree operations, Prev: Set operations, Up: Functions
  1261. 2.10 Other list operations
  1262. ==========================
  1263. Other list functions not fit to be classified elsewhere.
  1264. -- Function: -rotate (n list)
  1265. Rotate LIST N places to the right. With N negative, rotate to the
  1266. left. The time complexity is O(n).
  1267. (-rotate 3 '(1 2 3 4 5 6 7))
  1268. ⇒ (5 6 7 1 2 3 4)
  1269. (-rotate -3 '(1 2 3 4 5 6 7))
  1270. ⇒ (4 5 6 7 1 2 3)
  1271. (-rotate 16 '(1 2 3 4 5 6 7))
  1272. ⇒ (6 7 1 2 3 4 5)
  1273. -- Function: -repeat (n x)
  1274. Return a new list of length N with each element being X. Return
  1275. nil if N is less than 1.
  1276. (-repeat 3 :a)
  1277. ⇒ (:a :a :a)
  1278. (-repeat 1 :a)
  1279. ⇒ (:a)
  1280. (-repeat 0 :a)
  1281. ⇒ nil
  1282. -- Function: -cons* (&rest args)
  1283. Make a new list from the elements of ARGS. The last 2 elements of
  1284. ARGS are used as the final cons of the result, so if the final
  1285. element of ARGS is not a list, the result is a dotted list. With
  1286. no ARGS, return nil.
  1287. (-cons* 1 2)
  1288. ⇒ (1 . 2)
  1289. (-cons* 1 2 3)
  1290. ⇒ (1 2 . 3)
  1291. (-cons* 1)
  1292. ⇒ 1
  1293. -- Function: -snoc (list elem &rest elements)
  1294. Append ELEM to the end of the list.
  1295. This is like ‘cons’, but operates on the end of list.
  1296. If ELEMENTS is non nil, append these to the list as well.
  1297. (-snoc '(1 2 3) 4)
  1298. ⇒ (1 2 3 4)
  1299. (-snoc '(1 2 3) 4 5 6)
  1300. ⇒ (1 2 3 4 5 6)
  1301. (-snoc '(1 2 3) '(4 5 6))
  1302. ⇒ (1 2 3 (4 5 6))
  1303. -- Function: -interpose (sep list)
  1304. Return a new list of all elements in LIST separated by SEP.
  1305. (-interpose "-" ())
  1306. ⇒ ()
  1307. (-interpose "-" '("a"))
  1308. ⇒ ("a")
  1309. (-interpose "-" '("a" "b" "c"))
  1310. ⇒ ("a" "-" "b" "-" "c")
  1311. -- Function: -interleave (&rest lists)
  1312. Return a new list of the first item in each list, then the second
  1313. etc.
  1314. (-interleave '(1 2) '("a" "b"))
  1315. ⇒ (1 "a" 2 "b")
  1316. (-interleave '(1 2) '("a" "b") '("A" "B"))
  1317. ⇒ (1 "a" "A" 2 "b" "B")
  1318. (-interleave '(1 2 3) '("a" "b"))
  1319. ⇒ (1 "a" 2 "b")
  1320. -- Function: -iota (count &optional start step)
  1321. Return a list containing COUNT numbers. Starts from START and adds
  1322. STEP each time. The default START is zero, the default STEP is 1.
  1323. This function takes its name from the corresponding primitive in
  1324. the APL language.
  1325. (-iota 6)
  1326. ⇒ (0 1 2 3 4 5)
  1327. (-iota 4 2.5 -2)
  1328. ⇒ (2.5 0.5 -1.5 -3.5)
  1329. (-iota -1)
  1330. error→ Wrong type argument: natnump, -1
  1331. -- Function: -zip-with (fn list1 list2)
  1332. Zip the two lists LIST1 and LIST2 using a function FN. This
  1333. function is applied pairwise taking as first argument element of
  1334. LIST1 and as second argument element of LIST2 at corresponding
  1335. position.
  1336. The anaphoric form ‘--zip-with’ binds the elements from LIST1 as
  1337. symbol ‘it’, and the elements from LIST2 as symbol ‘other’.
  1338. (-zip-with '+ '(1 2 3) '(4 5 6))
  1339. ⇒ (5 7 9)
  1340. (-zip-with 'cons '(1 2 3) '(4 5 6))
  1341. ⇒ ((1 . 4) (2 . 5) (3 . 6))
  1342. (--zip-with (concat it " and " other) '("Batman" "Jekyll") '("Robin" "Hyde"))
  1343. ⇒ ("Batman and Robin" "Jekyll and Hyde")
  1344. -- Function: -zip (&rest lists)
  1345. Zip LISTS together. Group the head of each list, followed by the
  1346. second elements of each list, and so on. The lengths of the
  1347. returned groupings are equal to the length of the shortest input
  1348. list.
  1349. If two lists are provided as arguments, return the groupings as a
  1350. list of cons cells. Otherwise, return the groupings as a list of
  1351. lists.
  1352. Use ‘-zip-lists’ (*note -zip-lists::) if you need the return value
  1353. to always be a list of lists.
  1354. Alias: ‘-zip-pair’
  1355. See also: ‘-zip-lists’ (*note -zip-lists::)
  1356. (-zip '(1 2 3) '(4 5 6))
  1357. ⇒ ((1 . 4) (2 . 5) (3 . 6))
  1358. (-zip '(1 2 3) '(4 5 6 7))
  1359. ⇒ ((1 . 4) (2 . 5) (3 . 6))
  1360. (-zip '(1 2) '(3 4 5) '(6))
  1361. ⇒ ((1 3 6))
  1362. -- Function: -zip-lists (&rest lists)
  1363. Zip LISTS together. Group the head of each list, followed by the
  1364. second elements of each list, and so on. The lengths of the
  1365. returned groupings are equal to the length of the shortest input
  1366. list.
  1367. The return value is always list of lists, which is a difference
  1368. from ‘-zip-pair’ which returns a cons-cell in case two input lists
  1369. are provided.
  1370. See also: ‘-zip’ (*note -zip::)
  1371. (-zip-lists '(1 2 3) '(4 5 6))
  1372. ⇒ ((1 4) (2 5) (3 6))
  1373. (-zip-lists '(1 2 3) '(4 5 6 7))
  1374. ⇒ ((1 4) (2 5) (3 6))
  1375. (-zip-lists '(1 2) '(3 4 5) '(6))
  1376. ⇒ ((1 3 6))
  1377. -- Function: -zip-fill (fill-value &rest lists)
  1378. Zip LISTS, with FILL-VALUE padded onto the shorter lists. The
  1379. lengths of the returned groupings are equal to the length of the
  1380. longest input list.
  1381. (-zip-fill 0 '(1 2 3 4 5) '(6 7 8 9))
  1382. ⇒ ((1 . 6) (2 . 7) (3 . 8) (4 . 9) (5 . 0))
  1383. -- Function: -unzip (lists)
  1384. Unzip LISTS.
  1385. This works just like ‘-zip’ (*note -zip::) but takes a list of
  1386. lists instead of a variable number of arguments, such that
  1387. (-unzip (-zip L1 L2 L3 ...))
  1388. is identity (given that the lists are the same length).
  1389. Note in particular that calling this on a list of two lists will
  1390. return a list of cons-cells such that the above identity works.
  1391. See also: ‘-zip’ (*note -zip::)
  1392. (-unzip (-zip '(1 2 3) '(a b c) '("e" "f" "g")))
  1393. ⇒ ((1 2 3) (a b c) ("e" "f" "g"))
  1394. (-unzip '((1 2) (3 4) (5 6) (7 8) (9 10)))
  1395. ⇒ ((1 3 5 7 9) (2 4 6 8 10))
  1396. (-unzip '((1 2) (3 4)))
  1397. ⇒ ((1 . 3) (2 . 4))
  1398. -- Function: -cycle (list)
  1399. Return an infinite circular copy of LIST. The returned list cycles
  1400. through the elements of LIST and repeats from the beginning.
  1401. (-take 5 (-cycle '(1 2 3)))
  1402. ⇒ (1 2 3 1 2)
  1403. (-take 7 (-cycle '(1 "and" 3)))
  1404. ⇒ (1 "and" 3 1 "and" 3 1)
  1405. (-zip (-cycle '(1 2 3)) '(1 2))
  1406. ⇒ ((1 . 1) (2 . 2))
  1407. -- Function: -pad (fill-value &rest lists)
  1408. Appends FILL-VALUE to the end of each list in LISTS such that they
  1409. will all have the same length.
  1410. (-pad 0 ())
  1411. ⇒ (nil)
  1412. (-pad 0 '(1))
  1413. ⇒ ((1))
  1414. (-pad 0 '(1 2 3) '(4 5))
  1415. ⇒ ((1 2 3) (4 5 0))
  1416. -- Function: -table (fn &rest lists)
  1417. Compute outer product of LISTS using function FN.
  1418. The function FN should have the same arity as the number of
  1419. supplied lists.
  1420. The outer product is computed by applying fn to all possible
  1421. combinations created by taking one element from each list in order.
  1422. The dimension of the result is (length lists).
  1423. See also: ‘-table-flat’ (*note -table-flat::)
  1424. (-table '* '(1 2 3) '(1 2 3))
  1425. ⇒ ((1 2 3) (2 4 6) (3 6 9))
  1426. (-table (lambda (a b) (-sum (-zip-with '* a b))) '((1 2) (3 4)) '((1 3) (2 4)))
  1427. ⇒ ((7 15) (10 22))
  1428. (apply '-table 'list (-repeat 3 '(1 2)))
  1429. ⇒ ((((1 1 1) (2 1 1)) ((1 2 1) (2 2 1))) (((1 1 2) (2 1 2)) ((1 2 2) (2 2 2))))
  1430. -- Function: -table-flat (fn &rest lists)
  1431. Compute flat outer product of LISTS using function FN.
  1432. The function FN should have the same arity as the number of
  1433. supplied lists.
  1434. The outer product is computed by applying fn to all possible
  1435. combinations created by taking one element from each list in order.
  1436. The results are flattened, ignoring the tensor structure of the
  1437. result. This is equivalent to calling:
  1438. (-flatten-n (1- (length lists)) (apply ’-table fn lists))
  1439. but the implementation here is much more efficient.
  1440. See also: ‘-flatten-n’ (*note -flatten-n::), ‘-table’ (*note
  1441. -table::)
  1442. (-table-flat 'list '(1 2 3) '(a b c))
  1443. ⇒ ((1 a) (2 a) (3 a) (1 b) (2 b) (3 b) (1 c) (2 c) (3 c))
  1444. (-table-flat '* '(1 2 3) '(1 2 3))
  1445. ⇒ (1 2 3 2 4 6 3 6 9)
  1446. (apply '-table-flat 'list (-repeat 3 '(1 2)))
  1447. ⇒ ((1 1 1) (2 1 1) (1 2 1) (2 2 1) (1 1 2) (2 1 2) (1 2 2) (2 2 2))
  1448. -- Function: -first (pred list)
  1449. Return the first item in LIST for which PRED returns non-nil.
  1450. Return nil if no such element is found. To get the first item in
  1451. the list no questions asked, use ‘car’.
  1452. Alias: ‘-find’.
  1453. This function’s anaphoric counterpart is ‘--first’.
  1454. (-first #'natnump '(-1 0 1))
  1455. ⇒ 0
  1456. (-first #'null '(1 2 3))
  1457. ⇒ nil
  1458. (--first (> it 2) '(1 2 3))
  1459. ⇒ 3
  1460. -- Function: -some (pred list)
  1461. Return (PRED x) for the first LIST item where (PRED x) is non-nil,
  1462. else nil.
  1463. Alias: ‘-any’.
  1464. This function’s anaphoric counterpart is ‘--some’.
  1465. (-some (lambda (s) (string-match-p "x" s)) '("foo" "axe" "xor"))
  1466. ⇒ 1
  1467. (-some (lambda (s) (string-match-p "x" s)) '("foo" "bar" "baz"))
  1468. ⇒ nil
  1469. (--some (member 'foo it) '((foo bar) (baz)))
  1470. ⇒ (foo bar)
  1471. -- Function: -last (pred list)
  1472. Return the last x in LIST where (PRED x) is non-nil, else nil.
  1473. (-last 'even? '(1 2 3 4 5 6 3 3 3))
  1474. ⇒ 6
  1475. (-last 'even? '(1 3 7 5 9))
  1476. ⇒ nil
  1477. (--last (> (length it) 3) '("a" "looong" "word" "and" "short" "one"))
  1478. ⇒ "short"
  1479. -- Function: -first-item (list)
  1480. Return the first item of LIST, or nil on an empty list.
  1481. See also: ‘-second-item’ (*note -second-item::), ‘-last-item’
  1482. (*note -last-item::).
  1483. (-first-item '(1 2 3))
  1484. ⇒ 1
  1485. (-first-item nil)
  1486. ⇒ nil
  1487. (let ((list (list 1 2 3))) (setf (-first-item list) 5) list)
  1488. ⇒ (5 2 3)
  1489. -- Function: -second-item (list)
  1490. Return the second item of LIST, or nil if LIST is too short.
  1491. See also: ‘-third-item’ (*note -third-item::).
  1492. (-second-item '(1 2 3))
  1493. ⇒ 2
  1494. (-second-item nil)
  1495. ⇒ nil
  1496. -- Function: -third-item (list)
  1497. Return the third item of LIST, or nil if LIST is too short.
  1498. See also: ‘-fourth-item’ (*note -fourth-item::).
  1499. (-third-item '(1 2 3))
  1500. ⇒ 3
  1501. (-third-item nil)
  1502. ⇒ nil
  1503. -- Function: -fourth-item (list)
  1504. Return the fourth item of LIST, or nil if LIST is too short.
  1505. See also: ‘-fifth-item’ (*note -fifth-item::).
  1506. (-fourth-item '(1 2 3 4))
  1507. ⇒ 4
  1508. (-fourth-item nil)
  1509. ⇒ nil
  1510. -- Function: -fifth-item (list)
  1511. Return the fifth item of LIST, or nil if LIST is too short.
  1512. See also: ‘-last-item’ (*note -last-item::).
  1513. (-fifth-item '(1 2 3 4 5))
  1514. ⇒ 5
  1515. (-fifth-item nil)
  1516. ⇒ nil
  1517. -- Function: -last-item (list)
  1518. Return the last item of LIST, or nil on an empty list.
  1519. (-last-item '(1 2 3))
  1520. ⇒ 3
  1521. (-last-item nil)
  1522. ⇒ nil
  1523. (let ((list (list 1 2 3))) (setf (-last-item list) 5) list)
  1524. ⇒ (1 2 5)
  1525. -- Function: -butlast (list)
  1526. Return a list of all items in list except for the last.
  1527. (-butlast '(1 2 3))
  1528. ⇒ (1 2)
  1529. (-butlast '(1 2))
  1530. ⇒ (1)
  1531. (-butlast '(1))
  1532. ⇒ nil
  1533. -- Function: -sort (comparator list)
  1534. Sort LIST, stably, comparing elements using COMPARATOR. Return the
  1535. sorted list. LIST is NOT modified by side effects. COMPARATOR is
  1536. called with two elements of LIST, and should return non-nil if the
  1537. first element should sort before the second.
  1538. (-sort '< '(3 1 2))
  1539. ⇒ (1 2 3)
  1540. (-sort '> '(3 1 2))
  1541. ⇒ (3 2 1)
  1542. (--sort (< it other) '(3 1 2))
  1543. ⇒ (1 2 3)
  1544. -- Function: -list (arg)
  1545. Ensure ARG is a list. If ARG is already a list, return it as is
  1546. (not a copy). Otherwise, return a new list with ARG as its only
  1547. element.
  1548. Another supported calling convention is (-list &rest ARGS). In
  1549. this case, if ARG is not a list, a new list with all of ARGS as
  1550. elements is returned. This use is supported for backward
  1551. compatibility and is otherwise deprecated.
  1552. (-list 1)
  1553. ⇒ (1)
  1554. (-list ())
  1555. ⇒ ()
  1556. (-list '(1 2 3))
  1557. ⇒ (1 2 3)
  1558. -- Function: -fix (fn list)
  1559. Compute the (least) fixpoint of FN with initial input LIST.
  1560. FN is called at least once, results are compared with ‘equal’.
  1561. (-fix (lambda (l) (-non-nil (--mapcat (-split-at (/ (length it) 2) it) l))) '((1 2 3)))
  1562. ⇒ ((1) (2) (3))
  1563. (let ((l '((starwars scifi) (jedi starwars warrior)))) (--fix (-uniq (--mapcat (cons it (cdr (assq it l))) it)) '(jedi book)))
  1564. ⇒ (jedi starwars warrior scifi book)
  1565. 
  1566. File: dash.info, Node: Tree operations, Next: Threading macros, Prev: Other list operations, Up: Functions
  1567. 2.11 Tree operations
  1568. ====================
  1569. Functions pretending lists are trees.
  1570. -- Function: -tree-seq (branch children tree)
  1571. Return a sequence of the nodes in TREE, in depth-first search
  1572. order.
  1573. BRANCH is a predicate of one argument that returns non-nil if the
  1574. passed argument is a branch, that is, a node that can have
  1575. children.
  1576. CHILDREN is a function of one argument that returns the children of
  1577. the passed branch node.
  1578. Non-branch nodes are simply copied.
  1579. (-tree-seq 'listp 'identity '(1 (2 3) 4 (5 (6 7))))
  1580. ⇒ ((1 (2 3) 4 (5 (6 7))) 1 (2 3) 2 3 4 (5 (6 7)) 5 (6 7) 6 7)
  1581. (-tree-seq 'listp 'reverse '(1 (2 3) 4 (5 (6 7))))
  1582. ⇒ ((1 (2 3) 4 (5 (6 7))) (5 (6 7)) (6 7) 7 6 5 4 (2 3) 3 2 1)
  1583. (--tree-seq (vectorp it) (append it nil) [1 [2 3] 4 [5 [6 7]]])
  1584. ⇒ ([1 [2 3] 4 [5 [6 7]]] 1 [2 3] 2 3 4 [5 [6 7]] 5 [6 7] 6 7)
  1585. -- Function: -tree-map (fn tree)
  1586. Apply FN to each element of TREE while preserving the tree
  1587. structure.
  1588. (-tree-map '1+ '(1 (2 3) (4 (5 6) 7)))
  1589. ⇒ (2 (3 4) (5 (6 7) 8))
  1590. (-tree-map '(lambda (x) (cons x (expt 2 x))) '(1 (2 3) 4))
  1591. ⇒ ((1 . 2) ((2 . 4) (3 . 8)) (4 . 16))
  1592. (--tree-map (length it) '("<body>" ("<p>" "text" "</p>") "</body>"))
  1593. ⇒ (6 (3 4 4) 7)
  1594. -- Function: -tree-map-nodes (pred fun tree)
  1595. Call FUN on each node of TREE that satisfies PRED.
  1596. If PRED returns nil, continue descending down this node. If PRED
  1597. returns non-nil, apply FUN to this node and do not descend further.
  1598. (-tree-map-nodes 'vectorp (lambda (x) (-sum (append x nil))) '(1 [2 3] 4 (5 [6 7] 8)))
  1599. ⇒ (1 5 4 (5 13 8))
  1600. (-tree-map-nodes 'keywordp (lambda (x) (symbol-name x)) '(1 :foo 4 ((5 6 :bar) :baz 8)))
  1601. ⇒ (1 ":foo" 4 ((5 6 ":bar") ":baz" 8))
  1602. (--tree-map-nodes (eq (car-safe it) 'add-mode) (-concat it (list :mode 'emacs-lisp-mode)) '(with-mode emacs-lisp-mode (foo bar) (add-mode a b) (baz (add-mode c d))))
  1603. ⇒ (with-mode emacs-lisp-mode (foo bar) (add-mode a b :mode emacs-lisp-mode) (baz (add-mode c d :mode emacs-lisp-mode)))
  1604. -- Function: -tree-reduce (fn tree)
  1605. Use FN to reduce elements of list TREE. If elements of TREE are
  1606. lists themselves, apply the reduction recursively.
  1607. FN is first applied to first element of the list and second
  1608. element, then on this result and third element from the list etc.
  1609. See ‘-reduce-r’ (*note -reduce-r::) for how exactly are lists of
  1610. zero or one element handled.
  1611. (-tree-reduce '+ '(1 (2 3) (4 5)))
  1612. ⇒ 15
  1613. (-tree-reduce 'concat '("strings" (" on" " various") ((" levels"))))
  1614. ⇒ "strings on various levels"
  1615. (--tree-reduce (cond ((stringp it) (concat it " " acc)) (t (let ((sn (symbol-name it))) (concat "<" sn ">" acc "</" sn ">")))) '(body (p "some words") (div "more" (b "bold") "words")))
  1616. ⇒ "<body><p>some words</p> <div>more <b>bold</b> words</div></body>"
  1617. -- Function: -tree-reduce-from (fn init-value tree)
  1618. Use FN to reduce elements of list TREE. If elements of TREE are
  1619. lists themselves, apply the reduction recursively.
  1620. FN is first applied to INIT-VALUE and first element of the list,
  1621. then on this result and second element from the list etc.
  1622. The initial value is ignored on cons pairs as they always contain
  1623. two elements.
  1624. (-tree-reduce-from '+ 1 '(1 (1 1) ((1))))
  1625. ⇒ 8
  1626. (--tree-reduce-from (-concat acc (list it)) nil '(1 (2 3 (4 5)) (6 7)))
  1627. ⇒ ((7 6) ((5 4) 3 2) 1)
  1628. -- Function: -tree-mapreduce (fn folder tree)
  1629. Apply FN to each element of TREE, and make a list of the results.
  1630. If elements of TREE are lists themselves, apply FN recursively to
  1631. elements of these nested lists.
  1632. Then reduce the resulting lists using FOLDER and initial value
  1633. INIT-VALUE. See ‘-reduce-r-from’ (*note -reduce-r-from::).
  1634. This is the same as calling ‘-tree-reduce’ (*note -tree-reduce::)
  1635. after ‘-tree-map’ (*note -tree-map::) but is twice as fast as it
  1636. only traverse the structure once.
  1637. (-tree-mapreduce 'list 'append '(1 (2 (3 4) (5 6)) (7 (8 9))))
  1638. ⇒ (1 2 3 4 5 6 7 8 9)
  1639. (--tree-mapreduce 1 (+ it acc) '(1 (2 (4 9) (2 1)) (7 (4 3))))
  1640. ⇒ 9
  1641. (--tree-mapreduce 0 (max acc (1+ it)) '(1 (2 (4 9) (2 1)) (7 (4 3))))
  1642. ⇒ 3
  1643. -- Function: -tree-mapreduce-from (fn folder init-value tree)
  1644. Apply FN to each element of TREE, and make a list of the results.
  1645. If elements of TREE are lists themselves, apply FN recursively to
  1646. elements of these nested lists.
  1647. Then reduce the resulting lists using FOLDER and initial value
  1648. INIT-VALUE. See ‘-reduce-r-from’ (*note -reduce-r-from::).
  1649. This is the same as calling ‘-tree-reduce-from’ (*note
  1650. -tree-reduce-from::) after ‘-tree-map’ (*note -tree-map::) but is
  1651. twice as fast as it only traverse the structure once.
  1652. (-tree-mapreduce-from 'identity '* 1 '(1 (2 (3 4) (5 6)) (7 (8 9))))
  1653. ⇒ 362880
  1654. (--tree-mapreduce-from (+ it it) (cons it acc) nil '(1 (2 (4 9) (2 1)) (7 (4 3))))
  1655. ⇒ (2 (4 (8 18) (4 2)) (14 (8 6)))
  1656. (concat "{" (--tree-mapreduce-from (cond ((-cons-pair? it) (concat (symbol-name (car it)) " -> " (symbol-name (cdr it)))) (t (concat (symbol-name it) " : {"))) (concat it (unless (or (equal acc "}") (equal (substring it (1- (length it))) "{")) ", ") acc) "}" '((elisp-mode (foo (bar . booze)) (baz . qux)) (c-mode (foo . bla) (bum . bam)))))
  1657. ⇒ "{elisp-mode : {foo : {bar -> booze}, baz -> qux}, c-mode : {foo -> bla, bum -> bam}}"
  1658. -- Function: -clone (list)
  1659. Create a deep copy of LIST. The new list has the same elements and
  1660. structure but all cons are replaced with new ones. This is useful
  1661. when you need to clone a structure such as plist or alist.
  1662. (let* ((a '(1 2 3)) (b (-clone a))) (nreverse a) b)
  1663. ⇒ (1 2 3)
  1664. 
  1665. File: dash.info, Node: Threading macros, Next: Binding, Prev: Tree operations, Up: Functions
  1666. 2.12 Threading macros
  1667. =====================
  1668. Macros that conditionally combine sequential forms for brevity or
  1669. readability.
  1670. -- Macro: -> (x &optional form &rest more)
  1671. Thread the expr through the forms. Insert X as the second item in
  1672. the first form, making a list of it if it is not a list already.
  1673. If there are more forms, insert the first form as the second item
  1674. in second form, etc.
  1675. (-> '(2 3 5))
  1676. ⇒ (2 3 5)
  1677. (-> '(2 3 5) (append '(8 13)))
  1678. ⇒ (2 3 5 8 13)
  1679. (-> '(2 3 5) (append '(8 13)) (-slice 1 -1))
  1680. ⇒ (3 5 8)
  1681. -- Macro: ->> (x &optional form &rest more)
  1682. Thread the expr through the forms. Insert X as the last item in
  1683. the first form, making a list of it if it is not a list already.
  1684. If there are more forms, insert the first form as the last item in
  1685. second form, etc.
  1686. (->> '(1 2 3) (-map 'square))
  1687. ⇒ (1 4 9)
  1688. (->> '(1 2 3) (-map 'square) (-remove 'even?))
  1689. ⇒ (1 9)
  1690. (->> '(1 2 3) (-map 'square) (-reduce '+))
  1691. ⇒ 14
  1692. -- Macro: --> (x &rest forms)
  1693. Starting with the value of X, thread each expression through FORMS.
  1694. Insert X at the position signified by the symbol ‘it’ in the first
  1695. form. If there are more forms, insert the first form at the
  1696. position signified by ‘it’ in in second form, etc.
  1697. (--> "def" (concat "abc" it "ghi"))
  1698. ⇒ "abcdefghi"
  1699. (--> "def" (concat "abc" it "ghi") (upcase it))
  1700. ⇒ "ABCDEFGHI"
  1701. (--> "def" (concat "abc" it "ghi") upcase)
  1702. ⇒ "ABCDEFGHI"
  1703. -- Macro: -as-> (value variable &rest forms)
  1704. Starting with VALUE, thread VARIABLE through FORMS.
  1705. In the first form, bind VARIABLE to VALUE. In the second form,
  1706. bind VARIABLE to the result of the first form, and so forth.
  1707. (-as-> 3 my-var (1+ my-var) (list my-var) (mapcar (lambda (ele) (* 2 ele)) my-var))
  1708. ⇒ (8)
  1709. (-as-> 3 my-var 1+)
  1710. ⇒ 4
  1711. (-as-> 3 my-var)
  1712. ⇒ 3
  1713. -- Macro: -some-> (x &optional form &rest more)
  1714. When expr is non-nil, thread it through the first form (via ‘->’
  1715. (*note ->::)), and when that result is non-nil, through the next
  1716. form, etc.
  1717. (-some-> '(2 3 5))
  1718. ⇒ (2 3 5)
  1719. (-some-> 5 square)
  1720. ⇒ 25
  1721. (-some-> 5 even? square)
  1722. ⇒ nil
  1723. -- Macro: -some->> (x &optional form &rest more)
  1724. When expr is non-nil, thread it through the first form (via ‘->>’
  1725. (*note ->>::)), and when that result is non-nil, through the next
  1726. form, etc.
  1727. (-some->> '(1 2 3) (-map 'square))
  1728. ⇒ (1 4 9)
  1729. (-some->> '(1 3 5) (-last 'even?) (+ 100))
  1730. ⇒ nil
  1731. (-some->> '(2 4 6) (-last 'even?) (+ 100))
  1732. ⇒ 106
  1733. -- Macro: -some--> (expr &rest forms)
  1734. Thread EXPR through FORMS via ‘-->’ (*note -->::), while the result
  1735. is non-nil. When EXPR evaluates to non-nil, thread the result
  1736. through the first of FORMS, and when that result is non-nil, thread
  1737. it through the next form, etc.
  1738. (-some--> "def" (concat "abc" it "ghi"))
  1739. ⇒ "abcdefghi"
  1740. (-some--> nil (concat "abc" it "ghi"))
  1741. ⇒ nil
  1742. (-some--> '(0 1) (-remove #'natnump it) (append it it) (-map #'1+ it))
  1743. ⇒ ()
  1744. -- Macro: -doto (init &rest forms)
  1745. Evaluate INIT and pass it as argument to FORMS with ‘->’ (*note
  1746. ->::). The RESULT of evaluating INIT is threaded through each of
  1747. FORMS individually using ‘->’ (*note ->::), which see. The return
  1748. value is RESULT, which FORMS may have modified by side effect.
  1749. (-doto (list 1 2 3) pop pop)
  1750. ⇒ (3)
  1751. (-doto (cons 1 2) (setcar 3) (setcdr 4))
  1752. ⇒ (3 . 4)
  1753. (gethash 'k (--doto (make-hash-table) (puthash 'k 'v it)))
  1754. ⇒ v
  1755. 
  1756. File: dash.info, Node: Binding, Next: Side effects, Prev: Threading macros, Up: Functions
  1757. 2.13 Binding
  1758. ============
  1759. Macros that combine ‘let’ and ‘let*’ with destructuring and flow
  1760. control.
  1761. -- Macro: -when-let ((var val) &rest body)
  1762. If VAL evaluates to non-nil, bind it to VAR and execute body.
  1763. Note: binding is done according to ‘-let’ (*note -let::).
  1764. (-when-let (match-index (string-match "d" "abcd")) (+ match-index 2))
  1765. ⇒ 5
  1766. (-when-let ((&plist :foo foo) (list :foo "foo")) foo)
  1767. ⇒ "foo"
  1768. (-when-let ((&plist :foo foo) (list :bar "bar")) foo)
  1769. ⇒ nil
  1770. -- Macro: -when-let* (vars-vals &rest body)
  1771. If all VALS evaluate to true, bind them to their corresponding VARS
  1772. and execute body. VARS-VALS should be a list of (VAR VAL) pairs.
  1773. Note: binding is done according to ‘-let*’ (*note -let*::). VALS
  1774. are evaluated sequentially, and evaluation stops after the first
  1775. nil VAL is encountered.
  1776. (-when-let* ((x 5) (y 3) (z (+ y 4))) (+ x y z))
  1777. ⇒ 15
  1778. (-when-let* ((x 5) (y nil) (z 7)) (+ x y z))
  1779. ⇒ nil
  1780. -- Macro: -if-let ((var val) then &rest else)
  1781. If VAL evaluates to non-nil, bind it to VAR and do THEN, otherwise
  1782. do ELSE.
  1783. Note: binding is done according to ‘-let’ (*note -let::).
  1784. (-if-let (match-index (string-match "d" "abc")) (+ match-index 3) 7)
  1785. ⇒ 7
  1786. (--if-let (even? 4) it nil)
  1787. ⇒ t
  1788. -- Macro: -if-let* (vars-vals then &rest else)
  1789. If all VALS evaluate to true, bind them to their corresponding VARS
  1790. and do THEN, otherwise do ELSE. VARS-VALS should be a list of (VAR
  1791. VAL) pairs.
  1792. Note: binding is done according to ‘-let*’ (*note -let*::). VALS
  1793. are evaluated sequentially, and evaluation stops after the first
  1794. nil VAL is encountered.
  1795. (-if-let* ((x 5) (y 3) (z 7)) (+ x y z) "foo")
  1796. ⇒ 15
  1797. (-if-let* ((x 5) (y nil) (z 7)) (+ x y z) "foo")
  1798. ⇒ "foo"
  1799. (-if-let* (((_ _ x) '(nil nil 7))) x)
  1800. ⇒ 7
  1801. -- Macro: -let (varlist &rest body)
  1802. Bind variables according to VARLIST then eval BODY.
  1803. VARLIST is a list of lists of the form (PATTERN SOURCE). Each
  1804. PATTERN is matched against the SOURCE "structurally". SOURCE is
  1805. only evaluated once for each PATTERN. Each PATTERN is matched
  1806. recursively, and can therefore contain sub-patterns which are
  1807. matched against corresponding sub-expressions of SOURCE.
  1808. All the SOURCEs are evalled before any symbols are bound (i.e. "in
  1809. parallel").
  1810. If VARLIST only contains one (PATTERN SOURCE) element, you can
  1811. optionally specify it using a vector and discarding the outer-most
  1812. parens. Thus
  1813. (-let ((PATTERN SOURCE)) ...)
  1814. becomes
  1815. (-let [PATTERN SOURCE] ...).
  1816. ‘-let’ (*note -let::) uses a convention of not binding places
  1817. (symbols) starting with _ whenever it’s possible. You can use this
  1818. to skip over entries you don’t care about. However, this is not
  1819. *always* possible (as a result of implementation) and these symbols
  1820. might get bound to undefined values.
  1821. Following is the overview of supported patterns. Remember that
  1822. patterns can be matched recursively, so every a, b, aK in the
  1823. following can be a matching construct and not necessarily a
  1824. symbol/variable.
  1825. Symbol:
  1826. a - bind the SOURCE to A. This is just like regular ‘let’.
  1827. Conses and lists:
  1828. (a) - bind ‘car’ of cons/list to A
  1829. (a . b) - bind car of cons to A and ‘cdr’ to B
  1830. (a b) - bind car of list to A and ‘cadr’ to B
  1831. (a1 a2 a3 ...) - bind 0th car of list to A1, 1st to A2, 2nd to
  1832. A3...
  1833. (a1 a2 a3 ... aN . rest) - as above, but bind the Nth cdr to REST.
  1834. Vectors:
  1835. [a] - bind 0th element of a non-list sequence to A (works with
  1836. vectors, strings, bit arrays...)
  1837. [a1 a2 a3 ...] - bind 0th element of non-list sequence to A0, 1st
  1838. to A1, 2nd to A2, ... If the PATTERN is shorter than SOURCE, the
  1839. values at places not in PATTERN are ignored. If the PATTERN is
  1840. longer than SOURCE, an ‘error’ is thrown.
  1841. [a1 a2 a3 ... &rest rest] - as above, but bind the rest of the
  1842. sequence to REST. This is conceptually the same as improper list
  1843. matching (a1 a2 ... aN . rest)
  1844. Key/value stores:
  1845. (&plist key0 a0 ... keyN aN) - bind value mapped by keyK in the
  1846. SOURCE plist to aK. If the value is not found, aK is nil. Uses
  1847. ‘plist-get’ to fetch values.
  1848. (&alist key0 a0 ... keyN aN) - bind value mapped by keyK in the
  1849. SOURCE alist to aK. If the value is not found, aK is nil. Uses
  1850. ‘assoc’ to fetch values.
  1851. (&hash key0 a0 ... keyN aN) - bind value mapped by keyK in the
  1852. SOURCE hash table to aK. If the value is not found, aK is nil.
  1853. Uses ‘gethash’ to fetch values.
  1854. Further, special keyword &keys supports "inline" matching of
  1855. plist-like key-value pairs, similarly to &keys keyword of
  1856. ‘cl-defun’.
  1857. (a1 a2 ... aN &keys key1 b1 ... keyN bK)
  1858. This binds N values from the list to a1 ... aN, then interprets the
  1859. cdr as a plist (see key/value matching above).
  1860. A shorthand notation for kv-destructuring exists which allows the
  1861. patterns be optionally left out and derived from the key name in
  1862. the following fashion:
  1863. - a key :foo is converted into ‘foo’ pattern, - a key ’bar is
  1864. converted into ‘bar’ pattern, - a key "baz" is converted into ‘baz’
  1865. pattern.
  1866. That is, the entire value under the key is bound to the derived
  1867. variable without any further destructuring.
  1868. This is possible only when the form following the key is not a
  1869. valid pattern (i.e. not a symbol, a cons cell or a vector).
  1870. Otherwise the matching proceeds as usual and in case of an invalid
  1871. spec fails with an error.
  1872. Thus the patterns are normalized as follows:
  1873. ;; derive all the missing patterns (&plist :foo ’bar "baz") =>
  1874. (&plist :foo foo ’bar bar "baz" baz)
  1875. ;; we can specify some but not others (&plist :foo ’bar
  1876. explicit-bar) => (&plist :foo foo ’bar explicit-bar)
  1877. ;; nothing happens, we store :foo in x (&plist :foo x) => (&plist
  1878. :foo x)
  1879. ;; nothing happens, we match recursively (&plist :foo (a b c)) =>
  1880. (&plist :foo (a b c))
  1881. You can name the source using the syntax SYMBOL &as PATTERN. This
  1882. syntax works with lists (proper or improper), vectors and all types
  1883. of maps.
  1884. (list &as a b c) (list 1 2 3)
  1885. binds A to 1, B to 2, C to 3 and LIST to (1 2 3).
  1886. Similarly:
  1887. (bounds &as beg . end) (cons 1 2)
  1888. binds BEG to 1, END to 2 and BOUNDS to (1 . 2).
  1889. (items &as first . rest) (list 1 2 3)
  1890. binds FIRST to 1, REST to (2 3) and ITEMS to (1 2 3)
  1891. [vect &as _ b c] [1 2 3]
  1892. binds B to 2, C to 3 and VECT to [1 2 3] (_ avoids binding as
  1893. usual).
  1894. (plist &as &plist :b b) (list :a 1 :b 2 :c 3)
  1895. binds B to 2 and PLIST to (:a 1 :b 2 :c 3). Same for &alist and
  1896. &hash.
  1897. This is especially useful when we want to capture the result of a
  1898. computation and destructure at the same time. Consider the form
  1899. (function-returning-complex-structure) returning a list of two
  1900. vectors with two items each. We want to capture this entire result
  1901. and pass it to another computation, but at the same time we want to
  1902. get the second item from each vector. We can achieve it with
  1903. pattern
  1904. (result &as [_ a] [_ b]) (function-returning-complex-structure)
  1905. Note: Clojure programmers may know this feature as the ":as
  1906. binding". The difference is that we put the &as at the front
  1907. because we need to support improper list binding.
  1908. (-let (([a (b c) d] [1 (2 3) 4])) (list a b c d))
  1909. ⇒ (1 2 3 4)
  1910. (-let [(a b c . d) (list 1 2 3 4 5 6)] (list a b c d))
  1911. ⇒ (1 2 3 (4 5 6))
  1912. (-let [(&plist :foo foo :bar bar) (list :baz 3 :foo 1 :qux 4 :bar 2)] (list foo bar))
  1913. ⇒ (1 2)
  1914. -- Macro: -let* (varlist &rest body)
  1915. Bind variables according to VARLIST then eval BODY.
  1916. VARLIST is a list of lists of the form (PATTERN SOURCE). Each
  1917. PATTERN is matched against the SOURCE structurally. SOURCE is only
  1918. evaluated once for each PATTERN.
  1919. Each SOURCE can refer to the symbols already bound by this VARLIST.
  1920. This is useful if you want to destructure SOURCE recursively but
  1921. also want to name the intermediate structures.
  1922. See ‘-let’ (*note -let::) for the list of all possible patterns.
  1923. (-let* (((a . b) (cons 1 2)) ((c . d) (cons 3 4))) (list a b c d))
  1924. ⇒ (1 2 3 4)
  1925. (-let* (((a . b) (cons 1 (cons 2 3))) ((c . d) b)) (list a b c d))
  1926. ⇒ (1 (2 . 3) 2 3)
  1927. (-let* (((&alist "foo" foo "bar" bar) (list (cons "foo" 1) (cons "bar" (list 'a 'b 'c)))) ((a b c) bar)) (list foo a b c bar))
  1928. ⇒ (1 a b c (a b c))
  1929. -- Macro: -lambda (match-form &rest body)
  1930. Return a lambda which destructures its input as MATCH-FORM and
  1931. executes BODY.
  1932. Note that you have to enclose the MATCH-FORM in a pair of parens,
  1933. such that:
  1934. (-lambda (x) body) (-lambda (x y ...) body)
  1935. has the usual semantics of ‘lambda’. Furthermore, these get
  1936. translated into normal ‘lambda’, so there is no performance
  1937. penalty.
  1938. See ‘-let’ (*note -let::) for a description of the destructuring
  1939. mechanism.
  1940. (-map (-lambda ((x y)) (+ x y)) '((1 2) (3 4) (5 6)))
  1941. ⇒ (3 7 11)
  1942. (-map (-lambda ([x y]) (+ x y)) '([1 2] [3 4] [5 6]))
  1943. ⇒ (3 7 11)
  1944. (funcall (-lambda ((_ . a) (_ . b)) (-concat a b)) '(1 2 3) '(4 5 6))
  1945. ⇒ (2 3 5 6)
  1946. -- Macro: -setq ([match-form val] ...)
  1947. Bind each MATCH-FORM to the value of its VAL.
  1948. MATCH-FORM destructuring is done according to the rules of ‘-let’
  1949. (*note -let::).
  1950. This macro allows you to bind multiple variables by destructuring
  1951. the value, so for example:
  1952. (-setq (a b) x (&plist :c c) plist)
  1953. expands roughly speaking to the following code
  1954. (setq a (car x) b (cadr x) c (plist-get plist :c))
  1955. Care is taken to only evaluate each VAL once so that in case of
  1956. multiple assignments it does not cause unexpected side effects.
  1957. (let (a) (-setq a 1) a)
  1958. ⇒ 1
  1959. (let (a b) (-setq (a b) (list 1 2)) (list a b))
  1960. ⇒ (1 2)
  1961. (let (c) (-setq (&plist :c c) (list :c "c")) c)
  1962. ⇒ "c"
  1963. 
  1964. File: dash.info, Node: Side effects, Next: Destructive operations, Prev: Binding, Up: Functions
  1965. 2.14 Side effects
  1966. =================
  1967. Functions iterating over lists for side effect only.
  1968. -- Function: -each (list fn)
  1969. Call FN on each element of LIST. Return nil; this function is
  1970. intended for side effects.
  1971. Its anaphoric counterpart is ‘--each’.
  1972. For access to the current element’s index in LIST, see
  1973. ‘-each-indexed’ (*note -each-indexed::).
  1974. (let (l) (-each '(1 2 3) (lambda (x) (push x l))) l)
  1975. ⇒ (3 2 1)
  1976. (let (l) (--each '(1 2 3) (push it l)) l)
  1977. ⇒ (3 2 1)
  1978. (-each '(1 2 3) #'identity)
  1979. ⇒ nil
  1980. -- Function: -each-while (list pred fn)
  1981. Call FN on each ITEM in LIST, while (PRED ITEM) is non-nil. Once
  1982. an ITEM is reached for which PRED returns nil, FN is no longer
  1983. called. Return nil; this function is intended for side effects.
  1984. Its anaphoric counterpart is ‘--each-while’.
  1985. (let (l) (-each-while '(2 4 5 6) #'even? (lambda (x) (push x l))) l)
  1986. ⇒ (4 2)
  1987. (let (l) (--each-while '(1 2 3 4) (< it 3) (push it l)) l)
  1988. ⇒ (2 1)
  1989. (let ((s 0)) (--each-while '(1 3 4 5) (< it 5) (setq s (+ s it))) s)
  1990. ⇒ 8
  1991. -- Function: -each-indexed (list fn)
  1992. Call FN on each index and element of LIST. For each ITEM at INDEX
  1993. in LIST, call (funcall FN INDEX ITEM). Return nil; this function
  1994. is intended for side effects.
  1995. See also: ‘-map-indexed’ (*note -map-indexed::).
  1996. (let (l) (-each-indexed '(a b c) (lambda (i x) (push (list x i) l))) l)
  1997. ⇒ ((c 2) (b 1) (a 0))
  1998. (let (l) (--each-indexed '(a b c) (push (list it it-index) l)) l)
  1999. ⇒ ((c 2) (b 1) (a 0))
  2000. (let (l) (--each-indexed () (push it l)) l)
  2001. ⇒ ()
  2002. -- Function: -each-r (list fn)
  2003. Call FN on each element of LIST in reversed order. Return nil;
  2004. this function is intended for side effects.
  2005. Its anaphoric counterpart is ‘--each-r’.
  2006. (let (l) (-each-r '(1 2 3) (lambda (x) (push x l))) l)
  2007. ⇒ (1 2 3)
  2008. (let (l) (--each-r '(1 2 3) (push it l)) l)
  2009. ⇒ (1 2 3)
  2010. (-each-r '(1 2 3) #'identity)
  2011. ⇒ nil
  2012. -- Function: -each-r-while (list pred fn)
  2013. Call FN on each ITEM in reversed LIST, while (PRED ITEM) is
  2014. non-nil. Once an ITEM is reached for which PRED returns nil, FN is
  2015. no longer called. Return nil; this function is intended for side
  2016. effects.
  2017. Its anaphoric counterpart is ‘--each-r-while’.
  2018. (let (l) (-each-r-while '(2 4 5 6) #'even? (lambda (x) (push x l))) l)
  2019. ⇒ (6)
  2020. (let (l) (--each-r-while '(1 2 3 4) (>= it 3) (push it l)) l)
  2021. ⇒ (3 4)
  2022. (let ((s 0)) (--each-r-while '(1 2 3 5) (> it 1) (setq s (+ s it))) s)
  2023. ⇒ 10
  2024. -- Function: -dotimes (num fn)
  2025. Call FN NUM times, presumably for side effects. FN is called with
  2026. a single argument on successive integers running from 0, inclusive,
  2027. to NUM, exclusive. FN is not called if NUM is less than 1.
  2028. This function’s anaphoric counterpart is ‘--dotimes’.
  2029. (let (s) (-dotimes 3 (lambda (n) (push n s))) s)
  2030. ⇒ (2 1 0)
  2031. (let (s) (-dotimes 0 (lambda (n) (push n s))) s)
  2032. ⇒ ()
  2033. (let (s) (--dotimes 5 (push it s)) s)
  2034. ⇒ (4 3 2 1 0)
  2035. 
  2036. File: dash.info, Node: Destructive operations, Next: Function combinators, Prev: Side effects, Up: Functions
  2037. 2.15 Destructive operations
  2038. ===========================
  2039. Macros that modify variables holding lists.
  2040. -- Macro: !cons (car cdr)
  2041. Destructive: Set CDR to the cons of CAR and CDR.
  2042. (let (l) (!cons 5 l) l)
  2043. ⇒ (5)
  2044. (let ((l '(3))) (!cons 5 l) l)
  2045. ⇒ (5 3)
  2046. -- Macro: !cdr (list)
  2047. Destructive: Set LIST to the cdr of LIST.
  2048. (let ((l '(3))) (!cdr l) l)
  2049. ⇒ ()
  2050. (let ((l '(3 5))) (!cdr l) l)
  2051. ⇒ (5)
  2052. 
  2053. File: dash.info, Node: Function combinators, Prev: Destructive operations, Up: Functions
  2054. 2.16 Function combinators
  2055. =========================
  2056. Functions that manipulate and compose other functions.
  2057. -- Function: -partial (fn &rest args)
  2058. Take a function FN and fewer than the normal arguments to FN, and
  2059. return a fn that takes a variable number of additional ARGS. When
  2060. called, the returned function calls FN with ARGS first and then
  2061. additional args.
  2062. (funcall (-partial '- 5) 3)
  2063. ⇒ 2
  2064. (funcall (-partial '+ 5 2) 3)
  2065. ⇒ 10
  2066. -- Function: -rpartial (fn &rest args)
  2067. Takes a function FN and fewer than the normal arguments to FN, and
  2068. returns a fn that takes a variable number of additional ARGS. When
  2069. called, the returned function calls FN with the additional args
  2070. first and then ARGS.
  2071. (funcall (-rpartial '- 5) 8)
  2072. ⇒ 3
  2073. (funcall (-rpartial '- 5 2) 10)
  2074. ⇒ 3
  2075. -- Function: -juxt (&rest fns)
  2076. Takes a list of functions and returns a fn that is the
  2077. juxtaposition of those fns. The returned fn takes a variable
  2078. number of args, and returns a list containing the result of
  2079. applying each fn to the args (left-to-right).
  2080. (funcall (-juxt '+ '-) 3 5)
  2081. ⇒ (8 -2)
  2082. (-map (-juxt 'identity 'square) '(1 2 3))
  2083. ⇒ ((1 1) (2 4) (3 9))
  2084. -- Function: -compose (&rest fns)
  2085. Takes a list of functions and returns a fn that is the composition
  2086. of those fns. The returned fn takes a variable number of
  2087. arguments, and returns the result of applying each fn to the result
  2088. of applying the previous fn to the arguments (right-to-left).
  2089. (funcall (-compose 'square '+) 2 3)
  2090. ⇒ (square (+ 2 3))
  2091. (funcall (-compose 'identity 'square) 3)
  2092. ⇒ (square 3)
  2093. (funcall (-compose 'square 'identity) 3)
  2094. ⇒ (square 3)
  2095. -- Function: -applify (fn)
  2096. Changes an n-arity function FN to a 1-arity function that expects a
  2097. list with n items as arguments
  2098. (-map (-applify '+) '((1 1 1) (1 2 3) (5 5 5)))
  2099. ⇒ (3 6 15)
  2100. (-map (-applify (lambda (a b c) `(,a (,b (,c))))) '((1 1 1) (1 2 3) (5 5 5)))
  2101. ⇒ ((1 (1 (1))) (1 (2 (3))) (5 (5 (5))))
  2102. (funcall (-applify '<) '(3 6))
  2103. ⇒ t
  2104. -- Function: -on (operator transformer)
  2105. Return a function of two arguments that first applies TRANSFORMER
  2106. to each of them and then applies OPERATOR on the results (in the
  2107. same order).
  2108. In types: (b -> b -> c) -> (a -> b) -> a -> a -> c
  2109. (-sort (-on '< 'length) '((1 2 3) (1) (1 2)))
  2110. ⇒ ((1) (1 2) (1 2 3))
  2111. (-min-by (-on '> 'length) '((1 2 3) (4) (1 2)))
  2112. ⇒ (4)
  2113. (-min-by (-on 'string-lessp 'number-to-string) '(2 100 22))
  2114. ⇒ 22
  2115. -- Function: -flip (func)
  2116. Swap the order of arguments for binary function FUNC.
  2117. In types: (a -> b -> c) -> b -> a -> c
  2118. (funcall (-flip '<) 2 1)
  2119. ⇒ t
  2120. (funcall (-flip '-) 3 8)
  2121. ⇒ 5
  2122. (-sort (-flip '<) '(4 3 6 1))
  2123. ⇒ (6 4 3 1)
  2124. -- Function: -const (c)
  2125. Return a function that returns C ignoring any additional arguments.
  2126. In types: a -> b -> a
  2127. (funcall (-const 2) 1 3 "foo")
  2128. ⇒ 2
  2129. (-map (-const 1) '("a" "b" "c" "d"))
  2130. ⇒ (1 1 1 1)
  2131. (-sum (-map (-const 1) '("a" "b" "c" "d")))
  2132. ⇒ 4
  2133. -- Macro: -cut (&rest params)
  2134. Take n-ary function and n arguments and specialize some of them.
  2135. Arguments denoted by <> will be left unspecialized.
  2136. See SRFI-26 for detailed description.
  2137. (funcall (-cut list 1 <> 3 <> 5) 2 4)
  2138. ⇒ (1 2 3 4 5)
  2139. (-map (-cut funcall <> 5) `(1+ 1- ,(lambda (x) (/ 1.0 x))))
  2140. ⇒ (6 4 0.2)
  2141. (-map (-cut <> 1 2 3) '(list vector string))
  2142. ⇒ ((1 2 3) [1 2 3] "\1\2\3")
  2143. -- Function: -not (pred)
  2144. Take a unary predicate PRED and return a unary predicate that
  2145. returns t if PRED returns nil and nil if PRED returns non-nil.
  2146. (funcall (-not 'even?) 5)
  2147. ⇒ t
  2148. (-filter (-not (-partial '< 4)) '(1 2 3 4 5 6 7 8))
  2149. ⇒ (1 2 3 4)
  2150. -- Function: -orfn (&rest preds)
  2151. Take list of unary predicates PREDS and return a unary predicate
  2152. with argument x that returns non-nil if at least one of the PREDS
  2153. returns non-nil on x.
  2154. In types: [a -> Bool] -> a -> Bool
  2155. (-filter (-orfn 'even? (-partial (-flip '<) 5)) '(1 2 3 4 5 6 7 8 9 10))
  2156. ⇒ (1 2 3 4 6 8 10)
  2157. (funcall (-orfn 'stringp 'even?) "foo")
  2158. ⇒ t
  2159. -- Function: -andfn (&rest preds)
  2160. Take list of unary predicates PREDS and return a unary predicate
  2161. with argument x that returns non-nil if all of the PREDS returns
  2162. non-nil on x.
  2163. In types: [a -> Bool] -> a -> Bool
  2164. (funcall (-andfn (-cut < <> 10) 'even?) 6)
  2165. ⇒ t
  2166. (funcall (-andfn (-cut < <> 10) 'even?) 12)
  2167. ⇒ nil
  2168. (-filter (-andfn (-not 'even?) (-cut >= 5 <>)) '(1 2 3 4 5 6 7 8 9 10))
  2169. ⇒ (1 3 5)
  2170. -- Function: -iteratefn (fn n)
  2171. Return a function FN composed N times with itself.
  2172. FN is a unary function. If you need to use a function of higher
  2173. arity, use ‘-applify’ (*note -applify::) first to turn it into a
  2174. unary function.
  2175. With n = 0, this acts as identity function.
  2176. In types: (a -> a) -> Int -> a -> a.
  2177. This function satisfies the following law:
  2178. (funcall (-iteratefn fn n) init) = (-last-item (-iterate fn init
  2179. (1+ n))).
  2180. (funcall (-iteratefn (lambda (x) (* x x)) 3) 2)
  2181. ⇒ 256
  2182. (funcall (-iteratefn '1+ 3) 1)
  2183. ⇒ 4
  2184. (funcall (-iteratefn 'cdr 3) '(1 2 3 4 5))
  2185. ⇒ (4 5)
  2186. -- Function: -fixfn (fn &optional equal-test halt-test)
  2187. Return a function that computes the (least) fixpoint of FN.
  2188. FN must be a unary function. The returned lambda takes a single
  2189. argument, X, the initial value for the fixpoint iteration. The
  2190. iteration halts when either of the following conditions is
  2191. satisfied:
  2192. 1. Iteration converges to the fixpoint, with equality being tested
  2193. using EQUAL-TEST. If EQUAL-TEST is not specified, ‘equal’ is used.
  2194. For functions over the floating point numbers, it may be necessary
  2195. to provide an appropriate approximate comparison test.
  2196. 2. HALT-TEST returns a non-nil value. HALT-TEST defaults to a
  2197. simple counter that returns t after ‘-fixfn-max-iterations’, to
  2198. guard against infinite iteration. Otherwise, HALT-TEST must be a
  2199. function that accepts a single argument, the current value of X,
  2200. and returns non-nil as long as iteration should continue. In this
  2201. way, a more sophisticated convergence test may be supplied by the
  2202. caller.
  2203. The return value of the lambda is either the fixpoint or, if
  2204. iteration halted before converging, a cons with car ‘halted’ and
  2205. cdr the final output from HALT-TEST.
  2206. In types: (a -> a) -> a -> a.
  2207. (funcall (-fixfn #'cos #'approx=) 0.7)
  2208. ⇒ 0.7390851332151607
  2209. (funcall (-fixfn (lambda (x) (expt (+ x 10) 0.25))) 2.0)
  2210. ⇒ 1.8555845286409378
  2211. (funcall (-fixfn #'sin #'approx=) 0.1)
  2212. ⇒ (halted . t)
  2213. -- Function: -prodfn (&rest fns)
  2214. Take a list of n functions and return a function that takes a list
  2215. of length n, applying i-th function to i-th element of the input
  2216. list. Returns a list of length n.
  2217. In types (for n=2): ((a -> b), (c -> d)) -> (a, c) -> (b, d)
  2218. This function satisfies the following laws:
  2219. (-compose (-prodfn f g ...) (-prodfn f’ g’ ...)) = (-prodfn
  2220. (-compose f f’) (-compose g g’) ...) (-prodfn f g ...) = (-juxt
  2221. (-compose f (-partial ’nth 0)) (-compose g (-partial ’nth 1)) ...)
  2222. (-compose (-prodfn f g ...) (-juxt f’ g’ ...)) = (-juxt (-compose f
  2223. f’) (-compose g g’) ...) (-compose (-partial ’nth n) (-prod f1 f2
  2224. ...)) = (-compose fn (-partial ’nth n))
  2225. (funcall (-prodfn '1+ '1- 'number-to-string) '(1 2 3))
  2226. ⇒ (2 1 "3")
  2227. (-map (-prodfn '1+ '1-) '((1 2) (3 4) (5 6) (7 8)))
  2228. ⇒ ((2 1) (4 3) (6 5) (8 7))
  2229. (apply '+ (funcall (-prodfn 'length 'string-to-number) '((1 2 3) "15")))
  2230. ⇒ 18
  2231. 
  2232. File: dash.info, Node: Development, Next: FDL, Prev: Functions, Up: Top
  2233. 3 Development
  2234. *************
  2235. The Dash repository is hosted on GitHub at
  2236. <https://github.com/magnars/dash.el>.
  2237. * Menu:
  2238. * Contribute:: How to contribute.
  2239. * Contributors:: List of contributors.
  2240. 
  2241. File: dash.info, Node: Contribute, Next: Contributors, Up: Development
  2242. 3.1 Contribute
  2243. ==============
  2244. Yes, please do. Pure functions in the list manipulation realm only,
  2245. please. There’s a suite of examples/tests in ‘dev/examples.el’, so
  2246. remember to add tests for your additions, or they may get broken later.
  2247. Run the tests with ‘make check’. Regenerate the docs with ‘make
  2248. docs’. Contributors are encouraged to install these commands as a Git
  2249. pre-commit hook, so that the tests are always running and the docs are
  2250. always in sync:
  2251. $ cp dev/pre-commit.sh .git/hooks/pre-commit
  2252. Oh, and don’t edit ‘README.md’ or ‘dash.texi’ directly, as they are
  2253. auto-generated. Instead, change their respective templates
  2254. ‘readme-template.md’ or ‘dash-template.texi’.
  2255. To ensure that Dash can be distributed with GNU ELPA or Emacs, we
  2256. require that all contributors assign copyright to the Free Software
  2257. Foundation. For more on this, *note (emacs)Copyright Assignment::.
  2258. 
  2259. File: dash.info, Node: Contributors, Prev: Contribute, Up: Development
  2260. 3.2 Contributors
  2261. ================
  2262. • Matus Goljer (https://github.com/Fuco1) contributed lots of
  2263. features and functions.
  2264. • Takafumi Arakaki (https://github.com/tkf) contributed ‘-group-by’.
  2265. • tali713 (https://github.com/tali713) is the author of ‘-applify’.
  2266. • Víctor M. Valenzuela (https://github.com/vemv) contributed
  2267. ‘-repeat’.
  2268. • Nic Ferrier (https://github.com/nicferrier) contributed ‘-cons*’.
  2269. • Wilfred Hughes (https://github.com/Wilfred) contributed ‘-slice’,
  2270. ‘-first-item’, and ‘-last-item’.
  2271. • Emanuel Evans (https://github.com/shosti) contributed ‘-if-let’,
  2272. ‘-when-let’, and ‘-insert-at’.
  2273. • Johan Andersson (https://github.com/rejeep) contributed ‘-sum’,
  2274. ‘-product’, and ‘-same-items?’.
  2275. • Christina Whyte (https://github.com/kurisuwhyte) contributed
  2276. ‘-compose’.
  2277. • Steve Lamb (https://github.com/steventlamb) contributed ‘-cycle’,
  2278. ‘-pad’, ‘-annotate’, ‘-zip-fill’, and a variadic version of ‘-zip’.
  2279. • Fredrik Bergroth (https://github.com/fbergroth) made the ‘-if-let’
  2280. family use ‘-let’ destructuring and improved the script for
  2281. generating documentation.
  2282. • Mark Oteiza (https://github.com/holomorph) contributed ‘-iota’ and
  2283. the script to create an Info manual.
  2284. • Vasilij Schneidermann (https://github.com/wasamasa) contributed
  2285. ‘-some’.
  2286. • William West (https://github.com/occidens) made ‘-fixfn’ more
  2287. robust at handling floats.
  2288. • Cam Saul (https://github.com/camsaul) contributed ‘-some->’,
  2289. ‘-some->>’, and ‘-some-->’.
  2290. • Basil L. Contovounesios (https://github.com/basil-conto)
  2291. contributed ‘-common-prefix’, ‘-common-suffix’, and various other
  2292. improvements.
  2293. • Paul Pogonyshev (https://github.com/doublep) contributed ‘-each-r’
  2294. and ‘-each-r-while’.
  2295. Thanks!
  2296. New contributors are very welcome. *Note Contribute::.
  2297. 
  2298. File: dash.info, Node: FDL, Next: GPL, Prev: Development, Up: Top
  2299. Appendix A GNU Free Documentation License
  2300. *****************************************
  2301. Version 1.3, 3 November 2008
  2302. Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
  2303. <https://fsf.org/>
  2304. Everyone is permitted to copy and distribute verbatim copies
  2305. of this license document, but changing it is not allowed.
  2306. 0. PREAMBLE
  2307. The purpose of this License is to make a manual, textbook, or other
  2308. functional and useful document “free” in the sense of freedom: to
  2309. assure everyone the effective freedom to copy and redistribute it,
  2310. with or without modifying it, either commercially or
  2311. noncommercially. Secondarily, this License preserves for the
  2312. author and publisher a way to get credit for their work, while not
  2313. being considered responsible for modifications made by others.
  2314. This License is a kind of “copyleft”, which means that derivative
  2315. works of the document must themselves be free in the same sense.
  2316. It complements the GNU General Public License, which is a copyleft
  2317. license designed for free software.
  2318. We have designed this License in order to use it for manuals for
  2319. free software, because free software needs free documentation: a
  2320. free program should come with manuals providing the same freedoms
  2321. that the software does. But this License is not limited to
  2322. software manuals; it can be used for any textual work, regardless
  2323. of subject matter or whether it is published as a printed book. We
  2324. recommend this License principally for works whose purpose is
  2325. instruction or reference.
  2326. 1. APPLICABILITY AND DEFINITIONS
  2327. This License applies to any manual or other work, in any medium,
  2328. that contains a notice placed by the copyright holder saying it can
  2329. be distributed under the terms of this License. Such a notice
  2330. grants a world-wide, royalty-free license, unlimited in duration,
  2331. to use that work under the conditions stated herein. The
  2332. “Document”, below, refers to any such manual or work. Any member
  2333. of the public is a licensee, and is addressed as “you”. You accept
  2334. the license if you copy, modify or distribute the work in a way
  2335. requiring permission under copyright law.
  2336. A “Modified Version” of the Document means any work containing the
  2337. Document or a portion of it, either copied verbatim, or with
  2338. modifications and/or translated into another language.
  2339. A “Secondary Section” is a named appendix or a front-matter section
  2340. of the Document that deals exclusively with the relationship of the
  2341. publishers or authors of the Document to the Document’s overall
  2342. subject (or to related matters) and contains nothing that could
  2343. fall directly within that overall subject. (Thus, if the Document
  2344. is in part a textbook of mathematics, a Secondary Section may not
  2345. explain any mathematics.) The relationship could be a matter of
  2346. historical connection with the subject or with related matters, or
  2347. of legal, commercial, philosophical, ethical or political position
  2348. regarding them.
  2349. The “Invariant Sections” are certain Secondary Sections whose
  2350. titles are designated, as being those of Invariant Sections, in the
  2351. notice that says that the Document is released under this License.
  2352. If a section does not fit the above definition of Secondary then it
  2353. is not allowed to be designated as Invariant. The Document may
  2354. contain zero Invariant Sections. If the Document does not identify
  2355. any Invariant Sections then there are none.
  2356. The “Cover Texts” are certain short passages of text that are
  2357. listed, as Front-Cover Texts or Back-Cover Texts, in the notice
  2358. that says that the Document is released under this License. A
  2359. Front-Cover Text may be at most 5 words, and a Back-Cover Text may
  2360. be at most 25 words.
  2361. A “Transparent” copy of the Document means a machine-readable copy,
  2362. represented in a format whose specification is available to the
  2363. general public, that is suitable for revising the document
  2364. straightforwardly with generic text editors or (for images composed
  2365. of pixels) generic paint programs or (for drawings) some widely
  2366. available drawing editor, and that is suitable for input to text
  2367. formatters or for automatic translation to a variety of formats
  2368. suitable for input to text formatters. A copy made in an otherwise
  2369. Transparent file format whose markup, or absence of markup, has
  2370. been arranged to thwart or discourage subsequent modification by
  2371. readers is not Transparent. An image format is not Transparent if
  2372. used for any substantial amount of text. A copy that is not
  2373. “Transparent” is called “Opaque”.
  2374. Examples of suitable formats for Transparent copies include plain
  2375. ASCII without markup, Texinfo input format, LaTeX input format,
  2376. SGML or XML using a publicly available DTD, and standard-conforming
  2377. simple HTML, PostScript or PDF designed for human modification.
  2378. Examples of transparent image formats include PNG, XCF and JPG.
  2379. Opaque formats include proprietary formats that can be read and
  2380. edited only by proprietary word processors, SGML or XML for which
  2381. the DTD and/or processing tools are not generally available, and
  2382. the machine-generated HTML, PostScript or PDF produced by some word
  2383. processors for output purposes only.
  2384. The “Title Page” means, for a printed book, the title page itself,
  2385. plus such following pages as are needed to hold, legibly, the
  2386. material this License requires to appear in the title page. For
  2387. works in formats which do not have any title page as such, “Title
  2388. Page” means the text near the most prominent appearance of the
  2389. work’s title, preceding the beginning of the body of the text.
  2390. The “publisher” means any person or entity that distributes copies
  2391. of the Document to the public.
  2392. A section “Entitled XYZ” means a named subunit of the Document
  2393. whose title either is precisely XYZ or contains XYZ in parentheses
  2394. following text that translates XYZ in another language. (Here XYZ
  2395. stands for a specific section name mentioned below, such as
  2396. “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.)
  2397. To “Preserve the Title” of such a section when you modify the
  2398. Document means that it remains a section “Entitled XYZ” according
  2399. to this definition.
  2400. The Document may include Warranty Disclaimers next to the notice
  2401. which states that this License applies to the Document. These
  2402. Warranty Disclaimers are considered to be included by reference in
  2403. this License, but only as regards disclaiming warranties: any other
  2404. implication that these Warranty Disclaimers may have is void and
  2405. has no effect on the meaning of this License.
  2406. 2. VERBATIM COPYING
  2407. You may copy and distribute the Document in any medium, either
  2408. commercially or noncommercially, provided that this License, the
  2409. copyright notices, and the license notice saying this License
  2410. applies to the Document are reproduced in all copies, and that you
  2411. add no other conditions whatsoever to those of this License. You
  2412. may not use technical measures to obstruct or control the reading
  2413. or further copying of the copies you make or distribute. However,
  2414. you may accept compensation in exchange for copies. If you
  2415. distribute a large enough number of copies you must also follow the
  2416. conditions in section 3.
  2417. You may also lend copies, under the same conditions stated above,
  2418. and you may publicly display copies.
  2419. 3. COPYING IN QUANTITY
  2420. If you publish printed copies (or copies in media that commonly
  2421. have printed covers) of the Document, numbering more than 100, and
  2422. the Document’s license notice requires Cover Texts, you must
  2423. enclose the copies in covers that carry, clearly and legibly, all
  2424. these Cover Texts: Front-Cover Texts on the front cover, and
  2425. Back-Cover Texts on the back cover. Both covers must also clearly
  2426. and legibly identify you as the publisher of these copies. The
  2427. front cover must present the full title with all words of the title
  2428. equally prominent and visible. You may add other material on the
  2429. covers in addition. Copying with changes limited to the covers, as
  2430. long as they preserve the title of the Document and satisfy these
  2431. conditions, can be treated as verbatim copying in other respects.
  2432. If the required texts for either cover are too voluminous to fit
  2433. legibly, you should put the first ones listed (as many as fit
  2434. reasonably) on the actual cover, and continue the rest onto
  2435. adjacent pages.
  2436. If you publish or distribute Opaque copies of the Document
  2437. numbering more than 100, you must either include a machine-readable
  2438. Transparent copy along with each Opaque copy, or state in or with
  2439. each Opaque copy a computer-network location from which the general
  2440. network-using public has access to download using public-standard
  2441. network protocols a complete Transparent copy of the Document, free
  2442. of added material. If you use the latter option, you must take
  2443. reasonably prudent steps, when you begin distribution of Opaque
  2444. copies in quantity, to ensure that this Transparent copy will
  2445. remain thus accessible at the stated location until at least one
  2446. year after the last time you distribute an Opaque copy (directly or
  2447. through your agents or retailers) of that edition to the public.
  2448. It is requested, but not required, that you contact the authors of
  2449. the Document well before redistributing any large number of copies,
  2450. to give them a chance to provide you with an updated version of the
  2451. Document.
  2452. 4. MODIFICATIONS
  2453. You may copy and distribute a Modified Version of the Document
  2454. under the conditions of sections 2 and 3 above, provided that you
  2455. release the Modified Version under precisely this License, with the
  2456. Modified Version filling the role of the Document, thus licensing
  2457. distribution and modification of the Modified Version to whoever
  2458. possesses a copy of it. In addition, you must do these things in
  2459. the Modified Version:
  2460. A. Use in the Title Page (and on the covers, if any) a title
  2461. distinct from that of the Document, and from those of previous
  2462. versions (which should, if there were any, be listed in the
  2463. History section of the Document). You may use the same title
  2464. as a previous version if the original publisher of that
  2465. version gives permission.
  2466. B. List on the Title Page, as authors, one or more persons or
  2467. entities responsible for authorship of the modifications in
  2468. the Modified Version, together with at least five of the
  2469. principal authors of the Document (all of its principal
  2470. authors, if it has fewer than five), unless they release you
  2471. from this requirement.
  2472. C. State on the Title page the name of the publisher of the
  2473. Modified Version, as the publisher.
  2474. D. Preserve all the copyright notices of the Document.
  2475. E. Add an appropriate copyright notice for your modifications
  2476. adjacent to the other copyright notices.
  2477. F. Include, immediately after the copyright notices, a license
  2478. notice giving the public permission to use the Modified
  2479. Version under the terms of this License, in the form shown in
  2480. the Addendum below.
  2481. G. Preserve in that license notice the full lists of Invariant
  2482. Sections and required Cover Texts given in the Document’s
  2483. license notice.
  2484. H. Include an unaltered copy of this License.
  2485. I. Preserve the section Entitled “History”, Preserve its Title,
  2486. and add to it an item stating at least the title, year, new
  2487. authors, and publisher of the Modified Version as given on the
  2488. Title Page. If there is no section Entitled “History” in the
  2489. Document, create one stating the title, year, authors, and
  2490. publisher of the Document as given on its Title Page, then add
  2491. an item describing the Modified Version as stated in the
  2492. previous sentence.
  2493. J. Preserve the network location, if any, given in the Document
  2494. for public access to a Transparent copy of the Document, and
  2495. likewise the network locations given in the Document for
  2496. previous versions it was based on. These may be placed in the
  2497. “History” section. You may omit a network location for a work
  2498. that was published at least four years before the Document
  2499. itself, or if the original publisher of the version it refers
  2500. to gives permission.
  2501. K. For any section Entitled “Acknowledgements” or “Dedications”,
  2502. Preserve the Title of the section, and preserve in the section
  2503. all the substance and tone of each of the contributor
  2504. acknowledgements and/or dedications given therein.
  2505. L. Preserve all the Invariant Sections of the Document, unaltered
  2506. in their text and in their titles. Section numbers or the
  2507. equivalent are not considered part of the section titles.
  2508. M. Delete any section Entitled “Endorsements”. Such a section
  2509. may not be included in the Modified Version.
  2510. N. Do not retitle any existing section to be Entitled
  2511. “Endorsements” or to conflict in title with any Invariant
  2512. Section.
  2513. O. Preserve any Warranty Disclaimers.
  2514. If the Modified Version includes new front-matter sections or
  2515. appendices that qualify as Secondary Sections and contain no
  2516. material copied from the Document, you may at your option designate
  2517. some or all of these sections as invariant. To do this, add their
  2518. titles to the list of Invariant Sections in the Modified Version’s
  2519. license notice. These titles must be distinct from any other
  2520. section titles.
  2521. You may add a section Entitled “Endorsements”, provided it contains
  2522. nothing but endorsements of your Modified Version by various
  2523. parties—for example, statements of peer review or that the text has
  2524. been approved by an organization as the authoritative definition of
  2525. a standard.
  2526. You may add a passage of up to five words as a Front-Cover Text,
  2527. and a passage of up to 25 words as a Back-Cover Text, to the end of
  2528. the list of Cover Texts in the Modified Version. Only one passage
  2529. of Front-Cover Text and one of Back-Cover Text may be added by (or
  2530. through arrangements made by) any one entity. If the Document
  2531. already includes a cover text for the same cover, previously added
  2532. by you or by arrangement made by the same entity you are acting on
  2533. behalf of, you may not add another; but you may replace the old
  2534. one, on explicit permission from the previous publisher that added
  2535. the old one.
  2536. The author(s) and publisher(s) of the Document do not by this
  2537. License give permission to use their names for publicity for or to
  2538. assert or imply endorsement of any Modified Version.
  2539. 5. COMBINING DOCUMENTS
  2540. You may combine the Document with other documents released under
  2541. this License, under the terms defined in section 4 above for
  2542. modified versions, provided that you include in the combination all
  2543. of the Invariant Sections of all of the original documents,
  2544. unmodified, and list them all as Invariant Sections of your
  2545. combined work in its license notice, and that you preserve all
  2546. their Warranty Disclaimers.
  2547. The combined work need only contain one copy of this License, and
  2548. multiple identical Invariant Sections may be replaced with a single
  2549. copy. If there are multiple Invariant Sections with the same name
  2550. but different contents, make the title of each such section unique
  2551. by adding at the end of it, in parentheses, the name of the
  2552. original author or publisher of that section if known, or else a
  2553. unique number. Make the same adjustment to the section titles in
  2554. the list of Invariant Sections in the license notice of the
  2555. combined work.
  2556. In the combination, you must combine any sections Entitled
  2557. “History” in the various original documents, forming one section
  2558. Entitled “History”; likewise combine any sections Entitled
  2559. “Acknowledgements”, and any sections Entitled “Dedications”. You
  2560. must delete all sections Entitled “Endorsements.”
  2561. 6. COLLECTIONS OF DOCUMENTS
  2562. You may make a collection consisting of the Document and other
  2563. documents released under this License, and replace the individual
  2564. copies of this License in the various documents with a single copy
  2565. that is included in the collection, provided that you follow the
  2566. rules of this License for verbatim copying of each of the documents
  2567. in all other respects.
  2568. You may extract a single document from such a collection, and
  2569. distribute it individually under this License, provided you insert
  2570. a copy of this License into the extracted document, and follow this
  2571. License in all other respects regarding verbatim copying of that
  2572. document.
  2573. 7. AGGREGATION WITH INDEPENDENT WORKS
  2574. A compilation of the Document or its derivatives with other
  2575. separate and independent documents or works, in or on a volume of a
  2576. storage or distribution medium, is called an “aggregate” if the
  2577. copyright resulting from the compilation is not used to limit the
  2578. legal rights of the compilation’s users beyond what the individual
  2579. works permit. When the Document is included in an aggregate, this
  2580. License does not apply to the other works in the aggregate which
  2581. are not themselves derivative works of the Document.
  2582. If the Cover Text requirement of section 3 is applicable to these
  2583. copies of the Document, then if the Document is less than one half
  2584. of the entire aggregate, the Document’s Cover Texts may be placed
  2585. on covers that bracket the Document within the aggregate, or the
  2586. electronic equivalent of covers if the Document is in electronic
  2587. form. Otherwise they must appear on printed covers that bracket
  2588. the whole aggregate.
  2589. 8. TRANSLATION
  2590. Translation is considered a kind of modification, so you may
  2591. distribute translations of the Document under the terms of section
  2592. 4. Replacing Invariant Sections with translations requires special
  2593. permission from their copyright holders, but you may include
  2594. translations of some or all Invariant Sections in addition to the
  2595. original versions of these Invariant Sections. You may include a
  2596. translation of this License, and all the license notices in the
  2597. Document, and any Warranty Disclaimers, provided that you also
  2598. include the original English version of this License and the
  2599. original versions of those notices and disclaimers. In case of a
  2600. disagreement between the translation and the original version of
  2601. this License or a notice or disclaimer, the original version will
  2602. prevail.
  2603. If a section in the Document is Entitled “Acknowledgements”,
  2604. “Dedications”, or “History”, the requirement (section 4) to
  2605. Preserve its Title (section 1) will typically require changing the
  2606. actual title.
  2607. 9. TERMINATION
  2608. You may not copy, modify, sublicense, or distribute the Document
  2609. except as expressly provided under this License. Any attempt
  2610. otherwise to copy, modify, sublicense, or distribute it is void,
  2611. and will automatically terminate your rights under this License.
  2612. However, if you cease all violation of this License, then your
  2613. license from a particular copyright holder is reinstated (a)
  2614. provisionally, unless and until the copyright holder explicitly and
  2615. finally terminates your license, and (b) permanently, if the
  2616. copyright holder fails to notify you of the violation by some
  2617. reasonable means prior to 60 days after the cessation.
  2618. Moreover, your license from a particular copyright holder is
  2619. reinstated permanently if the copyright holder notifies you of the
  2620. violation by some reasonable means, this is the first time you have
  2621. received notice of violation of this License (for any work) from
  2622. that copyright holder, and you cure the violation prior to 30 days
  2623. after your receipt of the notice.
  2624. Termination of your rights under this section does not terminate
  2625. the licenses of parties who have received copies or rights from you
  2626. under this License. If your rights have been terminated and not
  2627. permanently reinstated, receipt of a copy of some or all of the
  2628. same material does not give you any rights to use it.
  2629. 10. FUTURE REVISIONS OF THIS LICENSE
  2630. The Free Software Foundation may publish new, revised versions of
  2631. the GNU Free Documentation License from time to time. Such new
  2632. versions will be similar in spirit to the present version, but may
  2633. differ in detail to address new problems or concerns. See
  2634. <https://www.gnu.org/licenses/>.
  2635. Each version of the License is given a distinguishing version
  2636. number. If the Document specifies that a particular numbered
  2637. version of this License “or any later version” applies to it, you
  2638. have the option of following the terms and conditions either of
  2639. that specified version or of any later version that has been
  2640. published (not as a draft) by the Free Software Foundation. If the
  2641. Document does not specify a version number of this License, you may
  2642. choose any version ever published (not as a draft) by the Free
  2643. Software Foundation. If the Document specifies that a proxy can
  2644. decide which future versions of this License can be used, that
  2645. proxy’s public statement of acceptance of a version permanently
  2646. authorizes you to choose that version for the Document.
  2647. 11. RELICENSING
  2648. “Massive Multiauthor Collaboration Site” (or “MMC Site”) means any
  2649. World Wide Web server that publishes copyrightable works and also
  2650. provides prominent facilities for anybody to edit those works. A
  2651. public wiki that anybody can edit is an example of such a server.
  2652. A “Massive Multiauthor Collaboration” (or “MMC”) contained in the
  2653. site means any set of copyrightable works thus published on the MMC
  2654. site.
  2655. “CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0
  2656. license published by Creative Commons Corporation, a not-for-profit
  2657. corporation with a principal place of business in San Francisco,
  2658. California, as well as future copyleft versions of that license
  2659. published by that same organization.
  2660. “Incorporate” means to publish or republish a Document, in whole or
  2661. in part, as part of another Document.
  2662. An MMC is “eligible for relicensing” if it is licensed under this
  2663. License, and if all works that were first published under this
  2664. License somewhere other than this MMC, and subsequently
  2665. incorporated in whole or in part into the MMC, (1) had no cover
  2666. texts or invariant sections, and (2) were thus incorporated prior
  2667. to November 1, 2008.
  2668. The operator of an MMC Site may republish an MMC contained in the
  2669. site under CC-BY-SA on the same site at any time before August 1,
  2670. 2009, provided the MMC is eligible for relicensing.
  2671. ADDENDUM: How to use this License for your documents
  2672. ====================================================
  2673. To use this License in a document you have written, include a copy of
  2674. the License in the document and put the following copyright and license
  2675. notices just after the title page:
  2676. Copyright (C) YEAR YOUR NAME.
  2677. Permission is granted to copy, distribute and/or modify this document
  2678. under the terms of the GNU Free Documentation License, Version 1.3
  2679. or any later version published by the Free Software Foundation;
  2680. with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
  2681. Texts. A copy of the license is included in the section entitled ``GNU
  2682. Free Documentation License''.
  2683. If you have Invariant Sections, Front-Cover Texts and Back-Cover
  2684. Texts, replace the “with...Texts.” line with this:
  2685. with the Invariant Sections being LIST THEIR TITLES, with
  2686. the Front-Cover Texts being LIST, and with the Back-Cover Texts
  2687. being LIST.
  2688. If you have Invariant Sections without Cover Texts, or some other
  2689. combination of the three, merge those two alternatives to suit the
  2690. situation.
  2691. If your document contains nontrivial examples of program code, we
  2692. recommend releasing these examples in parallel under your choice of free
  2693. software license, such as the GNU General Public License, to permit
  2694. their use in free software.
  2695. 
  2696. File: dash.info, Node: GPL, Next: Index, Prev: FDL, Up: Top
  2697. Appendix B GNU General Public License
  2698. *************************************
  2699. Version 3, 29 June 2007
  2700. Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
  2701. Everyone is permitted to copy and distribute verbatim copies of this
  2702. license document, but changing it is not allowed.
  2703. Preamble
  2704. ========
  2705. The GNU General Public License is a free, copyleft license for software
  2706. and other kinds of works.
  2707. The licenses for most software and other practical works are designed
  2708. to take away your freedom to share and change the works. By contrast,
  2709. the GNU General Public License is intended to guarantee your freedom to
  2710. share and change all versions of a program—to make sure it remains free
  2711. software for all its users. We, the Free Software Foundation, use the
  2712. GNU General Public License for most of our software; it applies also to
  2713. any other work released this way by its authors. You can apply it to
  2714. your programs, too.
  2715. When we speak of free software, we are referring to freedom, not
  2716. price. Our General Public Licenses are designed to make sure that you
  2717. have the freedom to distribute copies of free software (and charge for
  2718. them if you wish), that you receive source code or can get it if you
  2719. want it, that you can change the software or use pieces of it in new
  2720. free programs, and that you know you can do these things.
  2721. To protect your rights, we need to prevent others from denying you
  2722. these rights or asking you to surrender the rights. Therefore, you have
  2723. certain responsibilities if you distribute copies of the software, or if
  2724. you modify it: responsibilities to respect the freedom of others.
  2725. For example, if you distribute copies of such a program, whether
  2726. gratis or for a fee, you must pass on to the recipients the same
  2727. freedoms that you received. You must make sure that they, too, receive
  2728. or can get the source code. And you must show them these terms so they
  2729. know their rights.
  2730. Developers that use the GNU GPL protect your rights with two steps:
  2731. (1) assert copyright on the software, and (2) offer you this License
  2732. giving you legal permission to copy, distribute and/or modify it.
  2733. For the developers’ and authors’ protection, the GPL clearly explains
  2734. that there is no warranty for this free software. For both users’ and
  2735. authors’ sake, the GPL requires that modified versions be marked as
  2736. changed, so that their problems will not be attributed erroneously to
  2737. authors of previous versions.
  2738. Some devices are designed to deny users access to install or run
  2739. modified versions of the software inside them, although the manufacturer
  2740. can do so. This is fundamentally incompatible with the aim of
  2741. protecting users’ freedom to change the software. The systematic
  2742. pattern of such abuse occurs in the area of products for individuals to
  2743. use, which is precisely where it is most unacceptable. Therefore, we
  2744. have designed this version of the GPL to prohibit the practice for those
  2745. products. If such problems arise substantially in other domains, we
  2746. stand ready to extend this provision to those domains in future versions
  2747. of the GPL, as needed to protect the freedom of users.
  2748. Finally, every program is threatened constantly by software patents.
  2749. States should not allow patents to restrict development and use of
  2750. software on general-purpose computers, but in those that do, we wish to
  2751. avoid the special danger that patents applied to a free program could
  2752. make it effectively proprietary. To prevent this, the GPL assures that
  2753. patents cannot be used to render the program non-free.
  2754. The precise terms and conditions for copying, distribution and
  2755. modification follow.
  2756. TERMS AND CONDITIONS
  2757. ====================
  2758. 0. Definitions.
  2759. “This License” refers to version 3 of the GNU General Public
  2760. License.
  2761. “Copyright” also means copyright-like laws that apply to other
  2762. kinds of works, such as semiconductor masks.
  2763. “The Program” refers to any copyrightable work licensed under this
  2764. License. Each licensee is addressed as “you”. “Licensees” and
  2765. “recipients” may be individuals or organizations.
  2766. To “modify” a work means to copy from or adapt all or part of the
  2767. work in a fashion requiring copyright permission, other than the
  2768. making of an exact copy. The resulting work is called a “modified
  2769. version” of the earlier work or a work “based on” the earlier work.
  2770. A “covered work” means either the unmodified Program or a work
  2771. based on the Program.
  2772. To “propagate” a work means to do anything with it that, without
  2773. permission, would make you directly or secondarily liable for
  2774. infringement under applicable copyright law, except executing it on
  2775. a computer or modifying a private copy. Propagation includes
  2776. copying, distribution (with or without modification), making
  2777. available to the public, and in some countries other activities as
  2778. well.
  2779. To “convey” a work means any kind of propagation that enables other
  2780. parties to make or receive copies. Mere interaction with a user
  2781. through a computer network, with no transfer of a copy, is not
  2782. conveying.
  2783. An interactive user interface displays “Appropriate Legal Notices”
  2784. to the extent that it includes a convenient and prominently visible
  2785. feature that (1) displays an appropriate copyright notice, and (2)
  2786. tells the user that there is no warranty for the work (except to
  2787. the extent that warranties are provided), that licensees may convey
  2788. the work under this License, and how to view a copy of this
  2789. License. If the interface presents a list of user commands or
  2790. options, such as a menu, a prominent item in the list meets this
  2791. criterion.
  2792. 1. Source Code.
  2793. The “source code” for a work means the preferred form of the work
  2794. for making modifications to it. “Object code” means any non-source
  2795. form of a work.
  2796. A “Standard Interface” means an interface that either is an
  2797. official standard defined by a recognized standards body, or, in
  2798. the case of interfaces specified for a particular programming
  2799. language, one that is widely used among developers working in that
  2800. language.
  2801. The “System Libraries” of an executable work include anything,
  2802. other than the work as a whole, that (a) is included in the normal
  2803. form of packaging a Major Component, but which is not part of that
  2804. Major Component, and (b) serves only to enable use of the work with
  2805. that Major Component, or to implement a Standard Interface for
  2806. which an implementation is available to the public in source code
  2807. form. A “Major Component”, in this context, means a major
  2808. essential component (kernel, window system, and so on) of the
  2809. specific operating system (if any) on which the executable work
  2810. runs, or a compiler used to produce the work, or an object code
  2811. interpreter used to run it.
  2812. The “Corresponding Source” for a work in object code form means all
  2813. the source code needed to generate, install, and (for an executable
  2814. work) run the object code and to modify the work, including scripts
  2815. to control those activities. However, it does not include the
  2816. work’s System Libraries, or general-purpose tools or generally
  2817. available free programs which are used unmodified in performing
  2818. those activities but which are not part of the work. For example,
  2819. Corresponding Source includes interface definition files associated
  2820. with source files for the work, and the source code for shared
  2821. libraries and dynamically linked subprograms that the work is
  2822. specifically designed to require, such as by intimate data
  2823. communication or control flow between those subprograms and other
  2824. parts of the work.
  2825. The Corresponding Source need not include anything that users can
  2826. regenerate automatically from other parts of the Corresponding
  2827. Source.
  2828. The Corresponding Source for a work in source code form is that
  2829. same work.
  2830. 2. Basic Permissions.
  2831. All rights granted under this License are granted for the term of
  2832. copyright on the Program, and are irrevocable provided the stated
  2833. conditions are met. This License explicitly affirms your unlimited
  2834. permission to run the unmodified Program. The output from running
  2835. a covered work is covered by this License only if the output, given
  2836. its content, constitutes a covered work. This License acknowledges
  2837. your rights of fair use or other equivalent, as provided by
  2838. copyright law.
  2839. You may make, run and propagate covered works that you do not
  2840. convey, without conditions so long as your license otherwise
  2841. remains in force. You may convey covered works to others for the
  2842. sole purpose of having them make modifications exclusively for you,
  2843. or provide you with facilities for running those works, provided
  2844. that you comply with the terms of this License in conveying all
  2845. material for which you do not control copyright. Those thus making
  2846. or running the covered works for you must do so exclusively on your
  2847. behalf, under your direction and control, on terms that prohibit
  2848. them from making any copies of your copyrighted material outside
  2849. their relationship with you.
  2850. Conveying under any other circumstances is permitted solely under
  2851. the conditions stated below. Sublicensing is not allowed; section
  2852. 10 makes it unnecessary.
  2853. 3. Protecting Users’ Legal Rights From Anti-Circumvention Law.
  2854. No covered work shall be deemed part of an effective technological
  2855. measure under any applicable law fulfilling obligations under
  2856. article 11 of the WIPO copyright treaty adopted on 20 December
  2857. 1996, or similar laws prohibiting or restricting circumvention of
  2858. such measures.
  2859. When you convey a covered work, you waive any legal power to forbid
  2860. circumvention of technological measures to the extent such
  2861. circumvention is effected by exercising rights under this License
  2862. with respect to the covered work, and you disclaim any intention to
  2863. limit operation or modification of the work as a means of
  2864. enforcing, against the work’s users, your or third parties’ legal
  2865. rights to forbid circumvention of technological measures.
  2866. 4. Conveying Verbatim Copies.
  2867. You may convey verbatim copies of the Program’s source code as you
  2868. receive it, in any medium, provided that you conspicuously and
  2869. appropriately publish on each copy an appropriate copyright notice;
  2870. keep intact all notices stating that this License and any
  2871. non-permissive terms added in accord with section 7 apply to the
  2872. code; keep intact all notices of the absence of any warranty; and
  2873. give all recipients a copy of this License along with the Program.
  2874. You may charge any price or no price for each copy that you convey,
  2875. and you may offer support or warranty protection for a fee.
  2876. 5. Conveying Modified Source Versions.
  2877. You may convey a work based on the Program, or the modifications to
  2878. produce it from the Program, in the form of source code under the
  2879. terms of section 4, provided that you also meet all of these
  2880. conditions:
  2881. a. The work must carry prominent notices stating that you
  2882. modified it, and giving a relevant date.
  2883. b. The work must carry prominent notices stating that it is
  2884. released under this License and any conditions added under
  2885. section 7. This requirement modifies the requirement in
  2886. section 4 to “keep intact all notices”.
  2887. c. You must license the entire work, as a whole, under this
  2888. License to anyone who comes into possession of a copy. This
  2889. License will therefore apply, along with any applicable
  2890. section 7 additional terms, to the whole of the work, and all
  2891. its parts, regardless of how they are packaged. This License
  2892. gives no permission to license the work in any other way, but
  2893. it does not invalidate such permission if you have separately
  2894. received it.
  2895. d. If the work has interactive user interfaces, each must display
  2896. Appropriate Legal Notices; however, if the Program has
  2897. interactive interfaces that do not display Appropriate Legal
  2898. Notices, your work need not make them do so.
  2899. A compilation of a covered work with other separate and independent
  2900. works, which are not by their nature extensions of the covered
  2901. work, and which are not combined with it such as to form a larger
  2902. program, in or on a volume of a storage or distribution medium, is
  2903. called an “aggregate” if the compilation and its resulting
  2904. copyright are not used to limit the access or legal rights of the
  2905. compilation’s users beyond what the individual works permit.
  2906. Inclusion of a covered work in an aggregate does not cause this
  2907. License to apply to the other parts of the aggregate.
  2908. 6. Conveying Non-Source Forms.
  2909. You may convey a covered work in object code form under the terms
  2910. of sections 4 and 5, provided that you also convey the
  2911. machine-readable Corresponding Source under the terms of this
  2912. License, in one of these ways:
  2913. a. Convey the object code in, or embodied in, a physical product
  2914. (including a physical distribution medium), accompanied by the
  2915. Corresponding Source fixed on a durable physical medium
  2916. customarily used for software interchange.
  2917. b. Convey the object code in, or embodied in, a physical product
  2918. (including a physical distribution medium), accompanied by a
  2919. written offer, valid for at least three years and valid for as
  2920. long as you offer spare parts or customer support for that
  2921. product model, to give anyone who possesses the object code
  2922. either (1) a copy of the Corresponding Source for all the
  2923. software in the product that is covered by this License, on a
  2924. durable physical medium customarily used for software
  2925. interchange, for a price no more than your reasonable cost of
  2926. physically performing this conveying of source, or (2) access
  2927. to copy the Corresponding Source from a network server at no
  2928. charge.
  2929. c. Convey individual copies of the object code with a copy of the
  2930. written offer to provide the Corresponding Source. This
  2931. alternative is allowed only occasionally and noncommercially,
  2932. and only if you received the object code with such an offer,
  2933. in accord with subsection 6b.
  2934. d. Convey the object code by offering access from a designated
  2935. place (gratis or for a charge), and offer equivalent access to
  2936. the Corresponding Source in the same way through the same
  2937. place at no further charge. You need not require recipients
  2938. to copy the Corresponding Source along with the object code.
  2939. If the place to copy the object code is a network server, the
  2940. Corresponding Source may be on a different server (operated by
  2941. you or a third party) that supports equivalent copying
  2942. facilities, provided you maintain clear directions next to the
  2943. object code saying where to find the Corresponding Source.
  2944. Regardless of what server hosts the Corresponding Source, you
  2945. remain obligated to ensure that it is available for as long as
  2946. needed to satisfy these requirements.
  2947. e. Convey the object code using peer-to-peer transmission,
  2948. provided you inform other peers where the object code and
  2949. Corresponding Source of the work are being offered to the
  2950. general public at no charge under subsection 6d.
  2951. A separable portion of the object code, whose source code is
  2952. excluded from the Corresponding Source as a System Library, need
  2953. not be included in conveying the object code work.
  2954. A “User Product” is either (1) a “consumer product”, which means
  2955. any tangible personal property which is normally used for personal,
  2956. family, or household purposes, or (2) anything designed or sold for
  2957. incorporation into a dwelling. In determining whether a product is
  2958. a consumer product, doubtful cases shall be resolved in favor of
  2959. coverage. For a particular product received by a particular user,
  2960. “normally used” refers to a typical or common use of that class of
  2961. product, regardless of the status of the particular user or of the
  2962. way in which the particular user actually uses, or expects or is
  2963. expected to use, the product. A product is a consumer product
  2964. regardless of whether the product has substantial commercial,
  2965. industrial or non-consumer uses, unless such uses represent the
  2966. only significant mode of use of the product.
  2967. “Installation Information” for a User Product means any methods,
  2968. procedures, authorization keys, or other information required to
  2969. install and execute modified versions of a covered work in that
  2970. User Product from a modified version of its Corresponding Source.
  2971. The information must suffice to ensure that the continued
  2972. functioning of the modified object code is in no case prevented or
  2973. interfered with solely because modification has been made.
  2974. If you convey an object code work under this section in, or with,
  2975. or specifically for use in, a User Product, and the conveying
  2976. occurs as part of a transaction in which the right of possession
  2977. and use of the User Product is transferred to the recipient in
  2978. perpetuity or for a fixed term (regardless of how the transaction
  2979. is characterized), the Corresponding Source conveyed under this
  2980. section must be accompanied by the Installation Information. But
  2981. this requirement does not apply if neither you nor any third party
  2982. retains the ability to install modified object code on the User
  2983. Product (for example, the work has been installed in ROM).
  2984. The requirement to provide Installation Information does not
  2985. include a requirement to continue to provide support service,
  2986. warranty, or updates for a work that has been modified or installed
  2987. by the recipient, or for the User Product in which it has been
  2988. modified or installed. Access to a network may be denied when the
  2989. modification itself materially and adversely affects the operation
  2990. of the network or violates the rules and protocols for
  2991. communication across the network.
  2992. Corresponding Source conveyed, and Installation Information
  2993. provided, in accord with this section must be in a format that is
  2994. publicly documented (and with an implementation available to the
  2995. public in source code form), and must require no special password
  2996. or key for unpacking, reading or copying.
  2997. 7. Additional Terms.
  2998. “Additional permissions” are terms that supplement the terms of
  2999. this License by making exceptions from one or more of its
  3000. conditions. Additional permissions that are applicable to the
  3001. entire Program shall be treated as though they were included in
  3002. this License, to the extent that they are valid under applicable
  3003. law. If additional permissions apply only to part of the Program,
  3004. that part may be used separately under those permissions, but the
  3005. entire Program remains governed by this License without regard to
  3006. the additional permissions.
  3007. When you convey a copy of a covered work, you may at your option
  3008. remove any additional permissions from that copy, or from any part
  3009. of it. (Additional permissions may be written to require their own
  3010. removal in certain cases when you modify the work.) You may place
  3011. additional permissions on material, added by you to a covered work,
  3012. for which you have or can give appropriate copyright permission.
  3013. Notwithstanding any other provision of this License, for material
  3014. you add to a covered work, you may (if authorized by the copyright
  3015. holders of that material) supplement the terms of this License with
  3016. terms:
  3017. a. Disclaiming warranty or limiting liability differently from
  3018. the terms of sections 15 and 16 of this License; or
  3019. b. Requiring preservation of specified reasonable legal notices
  3020. or author attributions in that material or in the Appropriate
  3021. Legal Notices displayed by works containing it; or
  3022. c. Prohibiting misrepresentation of the origin of that material,
  3023. or requiring that modified versions of such material be marked
  3024. in reasonable ways as different from the original version; or
  3025. d. Limiting the use for publicity purposes of names of licensors
  3026. or authors of the material; or
  3027. e. Declining to grant rights under trademark law for use of some
  3028. trade names, trademarks, or service marks; or
  3029. f. Requiring indemnification of licensors and authors of that
  3030. material by anyone who conveys the material (or modified
  3031. versions of it) with contractual assumptions of liability to
  3032. the recipient, for any liability that these contractual
  3033. assumptions directly impose on those licensors and authors.
  3034. All other non-permissive additional terms are considered “further
  3035. restrictions” within the meaning of section 10. If the Program as
  3036. you received it, or any part of it, contains a notice stating that
  3037. it is governed by this License along with a term that is a further
  3038. restriction, you may remove that term. If a license document
  3039. contains a further restriction but permits relicensing or conveying
  3040. under this License, you may add to a covered work material governed
  3041. by the terms of that license document, provided that the further
  3042. restriction does not survive such relicensing or conveying.
  3043. If you add terms to a covered work in accord with this section, you
  3044. must place, in the relevant source files, a statement of the
  3045. additional terms that apply to those files, or a notice indicating
  3046. where to find the applicable terms.
  3047. Additional terms, permissive or non-permissive, may be stated in
  3048. the form of a separately written license, or stated as exceptions;
  3049. the above requirements apply either way.
  3050. 8. Termination.
  3051. You may not propagate or modify a covered work except as expressly
  3052. provided under this License. Any attempt otherwise to propagate or
  3053. modify it is void, and will automatically terminate your rights
  3054. under this License (including any patent licenses granted under the
  3055. third paragraph of section 11).
  3056. However, if you cease all violation of this License, then your
  3057. license from a particular copyright holder is reinstated (a)
  3058. provisionally, unless and until the copyright holder explicitly and
  3059. finally terminates your license, and (b) permanently, if the
  3060. copyright holder fails to notify you of the violation by some
  3061. reasonable means prior to 60 days after the cessation.
  3062. Moreover, your license from a particular copyright holder is
  3063. reinstated permanently if the copyright holder notifies you of the
  3064. violation by some reasonable means, this is the first time you have
  3065. received notice of violation of this License (for any work) from
  3066. that copyright holder, and you cure the violation prior to 30 days
  3067. after your receipt of the notice.
  3068. Termination of your rights under this section does not terminate
  3069. the licenses of parties who have received copies or rights from you
  3070. under this License. If your rights have been terminated and not
  3071. permanently reinstated, you do not qualify to receive new licenses
  3072. for the same material under section 10.
  3073. 9. Acceptance Not Required for Having Copies.
  3074. You are not required to accept this License in order to receive or
  3075. run a copy of the Program. Ancillary propagation of a covered work
  3076. occurring solely as a consequence of using peer-to-peer
  3077. transmission to receive a copy likewise does not require
  3078. acceptance. However, nothing other than this License grants you
  3079. permission to propagate or modify any covered work. These actions
  3080. infringe copyright if you do not accept this License. Therefore,
  3081. by modifying or propagating a covered work, you indicate your
  3082. acceptance of this License to do so.
  3083. 10. Automatic Licensing of Downstream Recipients.
  3084. Each time you convey a covered work, the recipient automatically
  3085. receives a license from the original licensors, to run, modify and
  3086. propagate that work, subject to this License. You are not
  3087. responsible for enforcing compliance by third parties with this
  3088. License.
  3089. An “entity transaction” is a transaction transferring control of an
  3090. organization, or substantially all assets of one, or subdividing an
  3091. organization, or merging organizations. If propagation of a
  3092. covered work results from an entity transaction, each party to that
  3093. transaction who receives a copy of the work also receives whatever
  3094. licenses to the work the party’s predecessor in interest had or
  3095. could give under the previous paragraph, plus a right to possession
  3096. of the Corresponding Source of the work from the predecessor in
  3097. interest, if the predecessor has it or can get it with reasonable
  3098. efforts.
  3099. You may not impose any further restrictions on the exercise of the
  3100. rights granted or affirmed under this License. For example, you
  3101. may not impose a license fee, royalty, or other charge for exercise
  3102. of rights granted under this License, and you may not initiate
  3103. litigation (including a cross-claim or counterclaim in a lawsuit)
  3104. alleging that any patent claim is infringed by making, using,
  3105. selling, offering for sale, or importing the Program or any portion
  3106. of it.
  3107. 11. Patents.
  3108. A “contributor” is a copyright holder who authorizes use under this
  3109. License of the Program or a work on which the Program is based.
  3110. The work thus licensed is called the contributor’s “contributor
  3111. version”.
  3112. A contributor’s “essential patent claims” are all patent claims
  3113. owned or controlled by the contributor, whether already acquired or
  3114. hereafter acquired, that would be infringed by some manner,
  3115. permitted by this License, of making, using, or selling its
  3116. contributor version, but do not include claims that would be
  3117. infringed only as a consequence of further modification of the
  3118. contributor version. For purposes of this definition, “control”
  3119. includes the right to grant patent sublicenses in a manner
  3120. consistent with the requirements of this License.
  3121. Each contributor grants you a non-exclusive, worldwide,
  3122. royalty-free patent license under the contributor’s essential
  3123. patent claims, to make, use, sell, offer for sale, import and
  3124. otherwise run, modify and propagate the contents of its contributor
  3125. version.
  3126. In the following three paragraphs, a “patent license” is any
  3127. express agreement or commitment, however denominated, not to
  3128. enforce a patent (such as an express permission to practice a
  3129. patent or covenant not to sue for patent infringement). To “grant”
  3130. such a patent license to a party means to make such an agreement or
  3131. commitment not to enforce a patent against the party.
  3132. If you convey a covered work, knowingly relying on a patent
  3133. license, and the Corresponding Source of the work is not available
  3134. for anyone to copy, free of charge and under the terms of this
  3135. License, through a publicly available network server or other
  3136. readily accessible means, then you must either (1) cause the
  3137. Corresponding Source to be so available, or (2) arrange to deprive
  3138. yourself of the benefit of the patent license for this particular
  3139. work, or (3) arrange, in a manner consistent with the requirements
  3140. of this License, to extend the patent license to downstream
  3141. recipients. “Knowingly relying” means you have actual knowledge
  3142. that, but for the patent license, your conveying the covered work
  3143. in a country, or your recipient’s use of the covered work in a
  3144. country, would infringe one or more identifiable patents in that
  3145. country that you have reason to believe are valid.
  3146. If, pursuant to or in connection with a single transaction or
  3147. arrangement, you convey, or propagate by procuring conveyance of, a
  3148. covered work, and grant a patent license to some of the parties
  3149. receiving the covered work authorizing them to use, propagate,
  3150. modify or convey a specific copy of the covered work, then the
  3151. patent license you grant is automatically extended to all
  3152. recipients of the covered work and works based on it.
  3153. A patent license is “discriminatory” if it does not include within
  3154. the scope of its coverage, prohibits the exercise of, or is
  3155. conditioned on the non-exercise of one or more of the rights that
  3156. are specifically granted under this License. You may not convey a
  3157. covered work if you are a party to an arrangement with a third
  3158. party that is in the business of distributing software, under which
  3159. you make payment to the third party based on the extent of your
  3160. activity of conveying the work, and under which the third party
  3161. grants, to any of the parties who would receive the covered work
  3162. from you, a discriminatory patent license (a) in connection with
  3163. copies of the covered work conveyed by you (or copies made from
  3164. those copies), or (b) primarily for and in connection with specific
  3165. products or compilations that contain the covered work, unless you
  3166. entered into that arrangement, or that patent license was granted,
  3167. prior to 28 March 2007.
  3168. Nothing in this License shall be construed as excluding or limiting
  3169. any implied license or other defenses to infringement that may
  3170. otherwise be available to you under applicable patent law.
  3171. 12. No Surrender of Others’ Freedom.
  3172. If conditions are imposed on you (whether by court order, agreement
  3173. or otherwise) that contradict the conditions of this License, they
  3174. do not excuse you from the conditions of this License. If you
  3175. cannot convey a covered work so as to satisfy simultaneously your
  3176. obligations under this License and any other pertinent obligations,
  3177. then as a consequence you may not convey it at all. For example,
  3178. if you agree to terms that obligate you to collect a royalty for
  3179. further conveying from those to whom you convey the Program, the
  3180. only way you could satisfy both those terms and this License would
  3181. be to refrain entirely from conveying the Program.
  3182. 13. Use with the GNU Affero General Public License.
  3183. Notwithstanding any other provision of this License, you have
  3184. permission to link or combine any covered work with a work licensed
  3185. under version 3 of the GNU Affero General Public License into a
  3186. single combined work, and to convey the resulting work. The terms
  3187. of this License will continue to apply to the part which is the
  3188. covered work, but the special requirements of the GNU Affero
  3189. General Public License, section 13, concerning interaction through
  3190. a network will apply to the combination as such.
  3191. 14. Revised Versions of this License.
  3192. The Free Software Foundation may publish revised and/or new
  3193. versions of the GNU General Public License from time to time. Such
  3194. new versions will be similar in spirit to the present version, but
  3195. may differ in detail to address new problems or concerns.
  3196. Each version is given a distinguishing version number. If the
  3197. Program specifies that a certain numbered version of the GNU
  3198. General Public License “or any later version” applies to it, you
  3199. have the option of following the terms and conditions either of
  3200. that numbered version or of any later version published by the Free
  3201. Software Foundation. If the Program does not specify a version
  3202. number of the GNU General Public License, you may choose any
  3203. version ever published by the Free Software Foundation.
  3204. If the Program specifies that a proxy can decide which future
  3205. versions of the GNU General Public License can be used, that
  3206. proxy’s public statement of acceptance of a version permanently
  3207. authorizes you to choose that version for the Program.
  3208. Later license versions may give you additional or different
  3209. permissions. However, no additional obligations are imposed on any
  3210. author or copyright holder as a result of your choosing to follow a
  3211. later version.
  3212. 15. Disclaimer of Warranty.
  3213. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
  3214. APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE
  3215. COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS”
  3216. WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
  3217. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  3218. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE
  3219. RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
  3220. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
  3221. NECESSARY SERVICING, REPAIR OR CORRECTION.
  3222. 16. Limitation of Liability.
  3223. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
  3224. WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES
  3225. AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR
  3226. DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
  3227. CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
  3228. THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
  3229. BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
  3230. PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
  3231. PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
  3232. THE POSSIBILITY OF SUCH DAMAGES.
  3233. 17. Interpretation of Sections 15 and 16.
  3234. If the disclaimer of warranty and limitation of liability provided
  3235. above cannot be given local legal effect according to their terms,
  3236. reviewing courts shall apply local law that most closely
  3237. approximates an absolute waiver of all civil liability in
  3238. connection with the Program, unless a warranty or assumption of
  3239. liability accompanies a copy of the Program in return for a fee.
  3240. END OF TERMS AND CONDITIONS
  3241. ===========================
  3242. How to Apply These Terms to Your New Programs
  3243. =============================================
  3244. If you develop a new program, and you want it to be of the greatest
  3245. possible use to the public, the best way to achieve this is to make it
  3246. free software which everyone can redistribute and change under these
  3247. terms.
  3248. To do so, attach the following notices to the program. It is safest
  3249. to attach them to the start of each source file to most effectively
  3250. state the exclusion of warranty; and each file should have at least the
  3251. “copyright” line and a pointer to where the full notice is found.
  3252. ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES.
  3253. Copyright (C) YEAR NAME OF AUTHOR
  3254. This program is free software: you can redistribute it and/or modify
  3255. it under the terms of the GNU General Public License as published by
  3256. the Free Software Foundation, either version 3 of the License, or (at
  3257. your option) any later version.
  3258. This program is distributed in the hope that it will be useful, but
  3259. WITHOUT ANY WARRANTY; without even the implied warranty of
  3260. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  3261. General Public License for more details.
  3262. You should have received a copy of the GNU General Public License
  3263. along with this program. If not, see <https://www.gnu.org/licenses/>.
  3264. Also add information on how to contact you by electronic and paper
  3265. mail.
  3266. If the program does terminal interaction, make it output a short
  3267. notice like this when it starts in an interactive mode:
  3268. PROGRAM Copyright (C) YEAR NAME OF AUTHOR
  3269. This program comes with ABSOLUTELY NO WARRANTY; for details type ‘show w’.
  3270. This is free software, and you are welcome to redistribute it
  3271. under certain conditions; type ‘show c’ for details.
  3272. The hypothetical commands ‘show w’ and ‘show c’ should show the
  3273. appropriate parts of the General Public License. Of course, your
  3274. program’s commands might be different; for a GUI interface, you would
  3275. use an “about box”.
  3276. You should also get your employer (if you work as a programmer) or
  3277. school, if any, to sign a “copyright disclaimer” for the program, if
  3278. necessary. For more information on this, and how to apply and follow
  3279. the GNU GPL, see <https://www.gnu.org/licenses/>.
  3280. The GNU General Public License does not permit incorporating your
  3281. program into proprietary programs. If your program is a subroutine
  3282. library, you may consider it more useful to permit linking proprietary
  3283. applications with the library. If this is what you want to do, use the
  3284. GNU Lesser General Public License instead of this License. But first,
  3285. please read <https://www.gnu.org/licenses/why-not-lgpl.html>.
  3286. 
  3287. File: dash.info, Node: Index, Prev: GPL, Up: Top
  3288. Index
  3289. *****
  3290. [index]
  3291. * Menu:
  3292. * !cdr: Destructive operations.
  3293. (line 16)
  3294. * !cons: Destructive operations.
  3295. (line 8)
  3296. * -->: Threading macros. (line 35)
  3297. * ->: Threading macros. (line 9)
  3298. * ->>: Threading macros. (line 22)
  3299. * -all?: Predicates. (line 20)
  3300. * -andfn: Function combinators.
  3301. (line 137)
  3302. * -annotate: Maps. (line 84)
  3303. * -any?: Predicates. (line 8)
  3304. * -applify: Function combinators.
  3305. (line 54)
  3306. * -as->: Threading macros. (line 49)
  3307. * -butlast: Other list operations.
  3308. (line 350)
  3309. * -clone: Tree operations. (line 122)
  3310. * -common-prefix: Reductions. (line 242)
  3311. * -common-suffix: Reductions. (line 252)
  3312. * -compose: Function combinators.
  3313. (line 41)
  3314. * -concat: List to list. (line 23)
  3315. * -cons*: Other list operations.
  3316. (line 30)
  3317. * -cons-pair?: Predicates. (line 126)
  3318. * -const: Function combinators.
  3319. (line 91)
  3320. * -contains?: Predicates. (line 59)
  3321. * -copy: Maps. (line 139)
  3322. * -count: Reductions. (line 172)
  3323. * -cut: Function combinators.
  3324. (line 103)
  3325. * -cycle: Other list operations.
  3326. (line 180)
  3327. * -difference: Set operations. (line 20)
  3328. * -distinct: Set operations. (line 62)
  3329. * -dotimes: Side effects. (line 80)
  3330. * -doto: Threading macros. (line 99)
  3331. * -drop: Sublist selection. (line 147)
  3332. * -drop-last: Sublist selection. (line 161)
  3333. * -drop-while: Sublist selection. (line 192)
  3334. * -each: Side effects. (line 8)
  3335. * -each-indexed: Side effects. (line 38)
  3336. * -each-r: Side effects. (line 52)
  3337. * -each-r-while: Side effects. (line 65)
  3338. * -each-while: Side effects. (line 24)
  3339. * -elem-index: Indexing. (line 9)
  3340. * -elem-indices: Indexing. (line 21)
  3341. * -fifth-item: Other list operations.
  3342. (line 330)
  3343. * -filter: Sublist selection. (line 8)
  3344. * -find-index: Indexing. (line 32)
  3345. * -find-indices: Indexing. (line 60)
  3346. * -find-last-index: Indexing. (line 46)
  3347. * -first: Other list operations.
  3348. (line 246)
  3349. * -first-item: Other list operations.
  3350. (line 287)
  3351. * -fix: Other list operations.
  3352. (line 390)
  3353. * -fixfn: Function combinators.
  3354. (line 174)
  3355. * -flatten: List to list. (line 34)
  3356. * -flatten-n: List to list. (line 56)
  3357. * -flip: Function combinators.
  3358. (line 79)
  3359. * -fourth-item: Other list operations.
  3360. (line 320)
  3361. * -grade-down: Indexing. (line 81)
  3362. * -grade-up: Indexing. (line 71)
  3363. * -group-by: Partitioning. (line 193)
  3364. * -if-let: Binding. (line 34)
  3365. * -if-let*: Binding. (line 45)
  3366. * -inits: Reductions. (line 222)
  3367. * -insert-at: List to list. (line 110)
  3368. * -interleave: Other list operations.
  3369. (line 67)
  3370. * -interpose: Other list operations.
  3371. (line 57)
  3372. * -intersection: Set operations. (line 32)
  3373. * -iota: Other list operations.
  3374. (line 78)
  3375. * -is-infix?: Predicates. (line 112)
  3376. * -is-prefix?: Predicates. (line 88)
  3377. * -is-suffix?: Predicates. (line 100)
  3378. * -iterate: Unfolding. (line 9)
  3379. * -iteratefn: Function combinators.
  3380. (line 151)
  3381. * -juxt: Function combinators.
  3382. (line 30)
  3383. * -keep: List to list. (line 8)
  3384. * -lambda: Binding. (line 247)
  3385. * -last: Other list operations.
  3386. (line 277)
  3387. * -last-item: Other list operations.
  3388. (line 340)
  3389. * -let: Binding. (line 61)
  3390. * -let*: Binding. (line 227)
  3391. * -list: Other list operations.
  3392. (line 373)
  3393. * -map: Maps. (line 10)
  3394. * -map-first: Maps. (line 38)
  3395. * -map-indexed: Maps. (line 66)
  3396. * -map-last: Maps. (line 52)
  3397. * -map-when: Maps. (line 22)
  3398. * -mapcat: Maps. (line 128)
  3399. * -max: Reductions. (line 286)
  3400. * -max-by: Reductions. (line 296)
  3401. * -min: Reductions. (line 262)
  3402. * -min-by: Reductions. (line 272)
  3403. * -non-nil: Sublist selection. (line 94)
  3404. * -none?: Predicates. (line 32)
  3405. * -not: Function combinators.
  3406. (line 116)
  3407. * -on: Function combinators.
  3408. (line 65)
  3409. * -only-some?: Predicates. (line 44)
  3410. * -orfn: Function combinators.
  3411. (line 125)
  3412. * -pad: Other list operations.
  3413. (line 191)
  3414. * -partial: Function combinators.
  3415. (line 8)
  3416. * -partition: Partitioning. (line 80)
  3417. * -partition-after-item: Partitioning. (line 183)
  3418. * -partition-after-pred: Partitioning. (line 151)
  3419. * -partition-all: Partitioning. (line 92)
  3420. * -partition-all-in-steps: Partitioning. (line 115)
  3421. * -partition-before-item: Partitioning. (line 173)
  3422. * -partition-before-pred: Partitioning. (line 162)
  3423. * -partition-by: Partitioning. (line 127)
  3424. * -partition-by-header: Partitioning. (line 138)
  3425. * -partition-in-steps: Partitioning. (line 103)
  3426. * -permutations: Set operations. (line 52)
  3427. * -powerset: Set operations. (line 44)
  3428. * -prodfn: Function combinators.
  3429. (line 208)
  3430. * -product: Reductions. (line 201)
  3431. * -reduce: Reductions. (line 53)
  3432. * -reduce-from: Reductions. (line 8)
  3433. * -reduce-r: Reductions. (line 72)
  3434. * -reduce-r-from: Reductions. (line 26)
  3435. * -reductions: Reductions. (line 136)
  3436. * -reductions-from: Reductions. (line 100)
  3437. * -reductions-r: Reductions. (line 154)
  3438. * -reductions-r-from: Reductions. (line 118)
  3439. * -remove: Sublist selection. (line 26)
  3440. * -remove-at: List to list. (line 146)
  3441. * -remove-at-indices: List to list. (line 159)
  3442. * -remove-first: Sublist selection. (line 43)
  3443. * -remove-item: Sublist selection. (line 83)
  3444. * -remove-last: Sublist selection. (line 64)
  3445. * -repeat: Other list operations.
  3446. (line 19)
  3447. * -replace: List to list. (line 68)
  3448. * -replace-at: List to list. (line 121)
  3449. * -replace-first: List to list. (line 82)
  3450. * -replace-last: List to list. (line 96)
  3451. * -rotate: Other list operations.
  3452. (line 8)
  3453. * -rpartial: Function combinators.
  3454. (line 19)
  3455. * -running-product: Reductions. (line 211)
  3456. * -running-sum: Reductions. (line 190)
  3457. * -same-items?: Predicates. (line 74)
  3458. * -second-item: Other list operations.
  3459. (line 300)
  3460. * -select-by-indices: Sublist selection. (line 208)
  3461. * -select-column: Sublist selection. (line 238)
  3462. * -select-columns: Sublist selection. (line 219)
  3463. * -separate: Partitioning. (line 69)
  3464. * -setq: Binding. (line 270)
  3465. * -slice: Sublist selection. (line 104)
  3466. * -snoc: Other list operations.
  3467. (line 43)
  3468. * -some: Other list operations.
  3469. (line 262)
  3470. * -some-->: Threading macros. (line 86)
  3471. * -some->: Threading macros. (line 62)
  3472. * -some->>: Threading macros. (line 74)
  3473. * -sort: Other list operations.
  3474. (line 360)
  3475. * -splice: Maps. (line 95)
  3476. * -splice-list: Maps. (line 115)
  3477. * -split-at: Partitioning. (line 8)
  3478. * -split-on: Partitioning. (line 34)
  3479. * -split-when: Partitioning. (line 52)
  3480. * -split-with: Partitioning. (line 23)
  3481. * -sum: Reductions. (line 180)
  3482. * -table: Other list operations.
  3483. (line 202)
  3484. * -table-flat: Other list operations.
  3485. (line 221)
  3486. * -tails: Reductions. (line 232)
  3487. * -take: Sublist selection. (line 120)
  3488. * -take-last: Sublist selection. (line 133)
  3489. * -take-while: Sublist selection. (line 175)
  3490. * -third-item: Other list operations.
  3491. (line 310)
  3492. * -tree-map: Tree operations. (line 28)
  3493. * -tree-map-nodes: Tree operations. (line 39)
  3494. * -tree-mapreduce: Tree operations. (line 84)
  3495. * -tree-mapreduce-from: Tree operations. (line 103)
  3496. * -tree-reduce: Tree operations. (line 52)
  3497. * -tree-reduce-from: Tree operations. (line 69)
  3498. * -tree-seq: Tree operations. (line 8)
  3499. * -unfold: Unfolding. (line 25)
  3500. * -union: Set operations. (line 8)
  3501. * -unzip: Other list operations.
  3502. (line 158)
  3503. * -update-at: List to list. (line 133)
  3504. * -when-let: Binding. (line 9)
  3505. * -when-let*: Binding. (line 21)
  3506. * -zip: Other list operations.
  3507. (line 107)
  3508. * -zip-fill: Other list operations.
  3509. (line 150)
  3510. * -zip-lists: Other list operations.
  3511. (line 131)
  3512. * -zip-with: Other list operations.
  3513. (line 91)
  3514. * dash-fontify-mode: Fontification of special variables.
  3515. (line 6)
  3516. * dash-register-info-lookup: Info symbol lookup. (line 6)
  3517. * global-dash-fontify-mode: Fontification of special variables.
  3518. (line 12)
  3519. 
  3520. Tag Table:
  3521. Node: Top742
  3522. Node: Installation2397
  3523. Node: Using in a package3112
  3524. Node: Fontification of special variables3457
  3525. Node: Info symbol lookup4247
  3526. Node: Functions4830
  3527. Node: Maps6314
  3528. Ref: -map6611
  3529. Ref: -map-when6984
  3530. Ref: -map-first7559
  3531. Ref: -map-last8034
  3532. Ref: -map-indexed8504
  3533. Ref: -annotate9190
  3534. Ref: -splice9677
  3535. Ref: -splice-list10455
  3536. Ref: -mapcat10914
  3537. Ref: -copy11287
  3538. Node: Sublist selection11475
  3539. Ref: -filter11668
  3540. Ref: -remove12215
  3541. Ref: -remove-first12753
  3542. Ref: -remove-last13595
  3543. Ref: -remove-item14320
  3544. Ref: -non-nil14720
  3545. Ref: -slice14996
  3546. Ref: -take15525
  3547. Ref: -take-last15932
  3548. Ref: -drop16363
  3549. Ref: -drop-last16804
  3550. Ref: -take-while17230
  3551. Ref: -drop-while17845
  3552. Ref: -select-by-indices18461
  3553. Ref: -select-columns18972
  3554. Ref: -select-column19675
  3555. Node: List to list20138
  3556. Ref: -keep20330
  3557. Ref: -concat20894
  3558. Ref: -flatten21188
  3559. Ref: -flatten-n21944
  3560. Ref: -replace22328
  3561. Ref: -replace-first22789
  3562. Ref: -replace-last23284
  3563. Ref: -insert-at23772
  3564. Ref: -replace-at24097
  3565. Ref: -update-at24484
  3566. Ref: -remove-at24972
  3567. Ref: -remove-at-indices25457
  3568. Node: Reductions26036
  3569. Ref: -reduce-from26232
  3570. Ref: -reduce-r-from26956
  3571. Ref: -reduce28219
  3572. Ref: -reduce-r28970
  3573. Ref: -reductions-from30248
  3574. Ref: -reductions-r-from31054
  3575. Ref: -reductions31884
  3576. Ref: -reductions-r32595
  3577. Ref: -count33340
  3578. Ref: -sum33564
  3579. Ref: -running-sum33752
  3580. Ref: -product34073
  3581. Ref: -running-product34281
  3582. Ref: -inits34622
  3583. Ref: -tails34867
  3584. Ref: -common-prefix35111
  3585. Ref: -common-suffix35405
  3586. Ref: -min35699
  3587. Ref: -min-by35925
  3588. Ref: -max36446
  3589. Ref: -max-by36671
  3590. Node: Unfolding37197
  3591. Ref: -iterate37438
  3592. Ref: -unfold37885
  3593. Node: Predicates38690
  3594. Ref: -any?38867
  3595. Ref: -all?39187
  3596. Ref: -none?39517
  3597. Ref: -only-some?39819
  3598. Ref: -contains?40304
  3599. Ref: -same-items?40693
  3600. Ref: -is-prefix?41078
  3601. Ref: -is-suffix?41404
  3602. Ref: -is-infix?41730
  3603. Ref: -cons-pair?42084
  3604. Node: Partitioning42409
  3605. Ref: -split-at42597
  3606. Ref: -split-with43261
  3607. Ref: -split-on43661
  3608. Ref: -split-when44334
  3609. Ref: -separate44971
  3610. Ref: -partition45410
  3611. Ref: -partition-all45859
  3612. Ref: -partition-in-steps46284
  3613. Ref: -partition-all-in-steps46778
  3614. Ref: -partition-by47260
  3615. Ref: -partition-by-header47638
  3616. Ref: -partition-after-pred48239
  3617. Ref: -partition-before-pred48617
  3618. Ref: -partition-before-item49002
  3619. Ref: -partition-after-item49309
  3620. Ref: -group-by49611
  3621. Node: Indexing50044
  3622. Ref: -elem-index50246
  3623. Ref: -elem-indices50641
  3624. Ref: -find-index51021
  3625. Ref: -find-last-index51510
  3626. Ref: -find-indices52014
  3627. Ref: -grade-up52419
  3628. Ref: -grade-down52826
  3629. Node: Set operations53240
  3630. Ref: -union53423
  3631. Ref: -difference53861
  3632. Ref: -intersection54273
  3633. Ref: -powerset54705
  3634. Ref: -permutations54915
  3635. Ref: -distinct55211
  3636. Node: Other list operations55585
  3637. Ref: -rotate55810
  3638. Ref: -repeat56177
  3639. Ref: -cons*56456
  3640. Ref: -snoc56872
  3641. Ref: -interpose57282
  3642. Ref: -interleave57576
  3643. Ref: -iota57942
  3644. Ref: -zip-with58425
  3645. Ref: -zip59139
  3646. Ref: -zip-lists59968
  3647. Ref: -zip-fill60666
  3648. Ref: -unzip60988
  3649. Ref: -cycle61730
  3650. Ref: -pad62129
  3651. Ref: -table62448
  3652. Ref: -table-flat63234
  3653. Ref: -first64239
  3654. Ref: -some64725
  3655. Ref: -last65209
  3656. Ref: -first-item65543
  3657. Ref: -second-item65942
  3658. Ref: -third-item66206
  3659. Ref: -fourth-item66468
  3660. Ref: -fifth-item66734
  3661. Ref: -last-item66996
  3662. Ref: -butlast67287
  3663. Ref: -sort67532
  3664. Ref: -list68018
  3665. Ref: -fix68587
  3666. Node: Tree operations69076
  3667. Ref: -tree-seq69272
  3668. Ref: -tree-map70127
  3669. Ref: -tree-map-nodes70567
  3670. Ref: -tree-reduce71414
  3671. Ref: -tree-reduce-from72296
  3672. Ref: -tree-mapreduce72896
  3673. Ref: -tree-mapreduce-from73755
  3674. Ref: -clone75040
  3675. Node: Threading macros75367
  3676. Ref: ->75592
  3677. Ref: ->>76080
  3678. Ref: -->76583
  3679. Ref: -as->77139
  3680. Ref: -some->77593
  3681. Ref: -some->>77966
  3682. Ref: -some-->78401
  3683. Ref: -doto78950
  3684. Node: Binding79503
  3685. Ref: -when-let79710
  3686. Ref: -when-let*80165
  3687. Ref: -if-let80688
  3688. Ref: -if-let*81048
  3689. Ref: -let81665
  3690. Ref: -let*87737
  3691. Ref: -lambda88674
  3692. Ref: -setq89480
  3693. Node: Side effects90281
  3694. Ref: -each90475
  3695. Ref: -each-while90996
  3696. Ref: -each-indexed91598
  3697. Ref: -each-r92184
  3698. Ref: -each-r-while92620
  3699. Ref: -dotimes93246
  3700. Node: Destructive operations93799
  3701. Ref: !cons94017
  3702. Ref: !cdr94221
  3703. Node: Function combinators94414
  3704. Ref: -partial94618
  3705. Ref: -rpartial95012
  3706. Ref: -juxt95415
  3707. Ref: -compose95845
  3708. Ref: -applify96398
  3709. Ref: -on96827
  3710. Ref: -flip97351
  3711. Ref: -const97662
  3712. Ref: -cut98000
  3713. Ref: -not98480
  3714. Ref: -orfn98789
  3715. Ref: -andfn99222
  3716. Ref: -iteratefn99716
  3717. Ref: -fixfn100418
  3718. Ref: -prodfn101974
  3719. Node: Development103032
  3720. Node: Contribute103321
  3721. Node: Contributors104333
  3722. Node: FDL106426
  3723. Node: GPL131746
  3724. Node: Index169495
  3725. 
  3726. End Tag Table
  3727. 
  3728. Local Variables:
  3729. coding: utf-8
  3730. End: