dash.info (202692B)
1 This is dash.info, produced by makeinfo version 6.7 from dash.texi. 2 3 This manual is for Dash version 2.19.1. 4 5 Copyright © 2012–2024 Free Software Foundation, Inc. 6 7 Permission is granted to copy, distribute and/or modify this 8 document under the terms of the GNU Free Documentation License, 9 Version 1.3 or any later version published by the Free Software 10 Foundation; with the Invariant Sections being “GNU General Public 11 License,” and no Front-Cover Texts or Back-Cover Texts. A copy of 12 the license is included in the section entitled “GNU Free 13 Documentation License”. 14 INFO-DIR-SECTION Emacs 15 START-INFO-DIR-ENTRY 16 * Dash: (dash.info). A modern list library for GNU Emacs. 17 END-INFO-DIR-ENTRY 18 19 20 File: dash.info, Node: Top, Next: Installation, Up: (dir) 21 22 Dash 23 **** 24 25 This manual is for Dash version 2.19.1. 26 27 Copyright © 2012–2024 Free Software Foundation, Inc. 28 29 Permission is granted to copy, distribute and/or modify this 30 document under the terms of the GNU Free Documentation License, 31 Version 1.3 or any later version published by the Free Software 32 Foundation; with the Invariant Sections being “GNU General Public 33 License,” and no Front-Cover Texts or Back-Cover Texts. A copy of 34 the license is included in the section entitled “GNU Free 35 Documentation License”. 36 37 * Menu: 38 39 * Installation:: Installing and configuring Dash. 40 * Functions:: Dash API reference. 41 * Development:: Contributing to Dash development. 42 43 Appendices 44 45 * FDL:: The license for this documentation. 46 * GPL:: Conditions for copying and changing Dash. 47 * Index:: Index including functions and macros. 48 49 — The Detailed Node Listing — 50 51 Installation 52 53 * Using in a package:: Listing Dash as a package dependency. 54 * Fontification of special variables:: Font Lock of anaphoric macro variables. 55 * Info symbol lookup:: Looking up Dash symbols in this manual. 56 57 Functions 58 59 * Maps:: 60 * Sublist selection:: 61 * List to list:: 62 * Reductions:: 63 * Unfolding:: 64 * Predicates:: 65 * Partitioning:: 66 * Indexing:: 67 * Set operations:: 68 * Other list operations:: 69 * Tree operations:: 70 * Threading macros:: 71 * Binding:: 72 * Side effects:: 73 * Destructive operations:: 74 * Function combinators:: 75 76 Development 77 78 * Contribute:: How to contribute. 79 * Contributors:: List of contributors. 80 81 82 File: dash.info, Node: Installation, Next: Functions, Prev: Top, Up: Top 83 84 1 Installation 85 ************** 86 87 Dash is available on GNU ELPA (https://elpa.gnu.org/), GNU-devel ELPA 88 (https://elpa.gnu.org/devel/), and MELPA (https://melpa.org/), and can 89 be installed with the standard command ‘package-install’ (*note 90 (emacs)Package Installation::). 91 92 ‘M-x package-install <RET> dash <RET>’ 93 Install the Dash library. 94 95 Alternatively, you can just dump ‘dash.el’ in your ‘load-path’ 96 somewhere (*note (emacs)Lisp Libraries::). 97 98 * Menu: 99 100 * Using in a package:: Listing Dash as a package dependency. 101 * Fontification of special variables:: Font Lock of anaphoric macro variables. 102 * Info symbol lookup:: Looking up Dash symbols in this manual. 103 104 105 File: dash.info, Node: Using in a package, Next: Fontification of special variables, Up: Installation 106 107 1.1 Using in a package 108 ====================== 109 110 If you use Dash in your own package, be sure to list it as a dependency 111 in the library’s headers as follows (*note (elisp)Library Headers::). 112 113 ;; Package-Requires: ((dash "2.19.1")) 114 115 116 File: dash.info, Node: Fontification of special variables, Next: Info symbol lookup, Prev: Using in a package, Up: Installation 117 118 1.2 Fontification of special variables 119 ====================================== 120 121 The autoloaded minor mode ‘dash-fontify-mode’ is provided for optional 122 fontification of anaphoric Dash variables (‘it’, ‘acc’, etc.) in Emacs 123 Lisp buffers using search-based Font Lock (*note (emacs)Font Lock::). 124 In older Emacs versions which do not dynamically detect macros, the 125 minor mode also fontifies calls to Dash macros. 126 127 To automatically enable the minor mode in all Emacs Lisp buffers, 128 just call its autoloaded global counterpart ‘global-dash-fontify-mode’, 129 either interactively or from your ‘user-init-file’: 130 131 (global-dash-fontify-mode) 132 133 134 File: dash.info, Node: Info symbol lookup, Prev: Fontification of special variables, Up: Installation 135 136 1.3 Info symbol lookup 137 ====================== 138 139 While editing Elisp files, you can use ‘C-h S’ (‘info-lookup-symbol’) to 140 look up Elisp symbols in the relevant Info manuals (*note (emacs)Info 141 Lookup::). To enable the same for Dash symbols, use the command 142 ‘dash-register-info-lookup’. It can be called directly when needed, or 143 automatically from your ‘user-init-file’. For example: 144 145 (with-eval-after-load 'info-look 146 (dash-register-info-lookup)) 147 148 149 File: dash.info, Node: Functions, Next: Development, Prev: Installation, Up: Top 150 151 2 Functions 152 *********** 153 154 This chapter contains reference documentation for the Dash API 155 (Application Programming Interface). The names of all public functions 156 defined in the library are prefixed with a dash character (‘-’). 157 158 The library also provides anaphoric macro versions of functions where 159 that makes sense. The names of these macros are prefixed with two 160 dashes (‘--’) instead of one. 161 162 For instance, while the function ‘-map’ applies a function to each 163 element of a list, its anaphoric counterpart ‘--map’ evaluates a form 164 with the local variable ‘it’ temporarily bound to the current list 165 element instead. 166 167 ;; Normal version. 168 (-map (lambda (n) (* n n)) '(1 2 3 4)) 169 ⇒ (1 4 9 16) 170 171 ;; Anaphoric version. 172 (--map (* it it) '(1 2 3 4)) 173 ⇒ (1 4 9 16) 174 175 The normal version can, of course, also be written as in the 176 following example, which demonstrates the utility of both versions. 177 178 (defun my-square (n) 179 "Return N multiplied by itself." 180 (* n n)) 181 182 (-map #'my-square '(1 2 3 4)) 183 ⇒ (1 4 9 16) 184 185 * Menu: 186 187 * Maps:: 188 * Sublist selection:: 189 * List to list:: 190 * Reductions:: 191 * Unfolding:: 192 * Predicates:: 193 * Partitioning:: 194 * Indexing:: 195 * Set operations:: 196 * Other list operations:: 197 * Tree operations:: 198 * Threading macros:: 199 * Binding:: 200 * Side effects:: 201 * Destructive operations:: 202 * Function combinators:: 203 204 205 File: dash.info, Node: Maps, Next: Sublist selection, Up: Functions 206 207 2.1 Maps 208 ======== 209 210 Functions in this category take a transforming function, which is then 211 applied sequentially to each or selected elements of the input list. 212 The results are collected in order and returned as a new list. 213 214 -- Function: -map (fn list) 215 Apply FN to each item in LIST and return the list of results. 216 217 This function’s anaphoric counterpart is ‘--map’. 218 219 (-map (lambda (num) (* num num)) '(1 2 3 4)) 220 ⇒ (1 4 9 16) 221 (-map #'1+ '(1 2 3 4)) 222 ⇒ (2 3 4 5) 223 (--map (* it it) '(1 2 3 4)) 224 ⇒ (1 4 9 16) 225 226 -- Function: -map-when (pred rep list) 227 Use PRED to conditionally apply REP to each item in LIST. Return a 228 copy of LIST where the items for which PRED returns ‘nil’ are 229 unchanged, and the rest are mapped through the REP function. 230 231 Alias: ‘-replace-where’ 232 233 See also: ‘-update-at’ (*note -update-at::) 234 235 (-map-when 'even? 'square '(1 2 3 4)) 236 ⇒ (1 4 3 16) 237 (--map-when (> it 2) (* it it) '(1 2 3 4)) 238 ⇒ (1 2 9 16) 239 (--map-when (= it 2) 17 '(1 2 3 4)) 240 ⇒ (1 17 3 4) 241 242 -- Function: -map-first (pred rep list) 243 Use PRED to determine the first item in LIST to call REP on. 244 Return a copy of LIST where the first item for which PRED returns 245 non-‘nil’ is replaced with the result of calling REP on that item. 246 247 See also: ‘-map-when’ (*note -map-when::), ‘-replace-first’ (*note 248 -replace-first::) 249 250 (-map-first 'even? 'square '(1 2 3 4)) 251 ⇒ (1 4 3 4) 252 (--map-first (> it 2) (* it it) '(1 2 3 4)) 253 ⇒ (1 2 9 4) 254 (--map-first (= it 2) 17 '(1 2 3 2)) 255 ⇒ (1 17 3 2) 256 257 -- Function: -map-last (pred rep list) 258 Use PRED to determine the last item in LIST to call REP on. Return 259 a copy of LIST where the last item for which PRED returns non-‘nil’ 260 is replaced with the result of calling REP on that item. 261 262 See also: ‘-map-when’ (*note -map-when::), ‘-replace-last’ (*note 263 -replace-last::) 264 265 (-map-last 'even? 'square '(1 2 3 4)) 266 ⇒ (1 2 3 16) 267 (--map-last (> it 2) (* it it) '(1 2 3 4)) 268 ⇒ (1 2 3 16) 269 (--map-last (= it 2) 17 '(1 2 3 2)) 270 ⇒ (1 2 3 17) 271 272 -- Function: -map-indexed (fn list) 273 Apply FN to each index and item in LIST and return the list of 274 results. This is like ‘-map’ (*note -map::), but FN takes two 275 arguments: the index of the current element within LIST, and the 276 element itself. 277 278 This function’s anaphoric counterpart is ‘--map-indexed’. 279 280 For a side-effecting variant, see also ‘-each-indexed’ (*note 281 -each-indexed::). 282 283 (-map-indexed (lambda (index item) (- item index)) '(1 2 3 4)) 284 ⇒ (1 1 1 1) 285 (--map-indexed (- it it-index) '(1 2 3 4)) 286 ⇒ (1 1 1 1) 287 (-map-indexed #'* '(1 2 3 4)) 288 ⇒ (0 2 6 12) 289 290 -- Function: -annotate (fn list) 291 Pair each item in LIST with the result of passing it to FN. 292 293 Return an alist of (RESULT . ITEM), where each ITEM is the 294 corresponding element of LIST, and RESULT is the value obtained by 295 calling FN on ITEM. 296 297 This function’s anaphoric counterpart is ‘--annotate’. 298 299 (-annotate #'1+ '(1 2 3)) 300 ⇒ ((2 . 1) (3 . 2) (4 . 3)) 301 (-annotate #'length '((f o o) (bar baz))) 302 ⇒ ((3 f o o) (2 bar baz)) 303 (--annotate (> it 1) '(0 1 2 3)) 304 ⇒ ((nil . 0) (nil . 1) (t . 2) (t . 3)) 305 306 -- Function: -splice (pred fun list) 307 Splice lists generated by FUN in place of items satisfying PRED in 308 LIST. 309 310 Call PRED on each element of LIST. Whenever the result of PRED is 311 ‘nil’, leave that ‘it’ as-is. Otherwise, call FUN on the same ‘it’ 312 that satisfied PRED. The result should be a (possibly empty) list 313 of items to splice in place of ‘it’ in LIST. 314 315 This can be useful as an alternative to the ‘,@’ construct in a ‘`’ 316 structure, in case you need to splice several lists at marked 317 positions (for example with keywords). 318 319 This function’s anaphoric counterpart is ‘--splice’. 320 321 See also: ‘-splice-list’ (*note -splice-list::), ‘-insert-at’ 322 (*note -insert-at::). 323 324 (-splice #'numberp (lambda (n) (list n n)) '(a 1 b 2)) 325 ⇒ (a 1 1 b 2 2) 326 (--splice t (list it it) '(1 2 3 4)) 327 ⇒ (1 1 2 2 3 3 4 4) 328 (--splice (eq it :magic) '((magical) (code)) '((foo) :magic (bar))) 329 ⇒ ((foo) (magical) (code) (bar)) 330 331 -- Function: -splice-list (pred new-list list) 332 Splice NEW-LIST in place of elements matching PRED in LIST. 333 334 See also: ‘-splice’ (*note -splice::), ‘-insert-at’ (*note 335 -insert-at::) 336 337 (-splice-list 'keywordp '(a b c) '(1 :foo 2)) 338 ⇒ (1 a b c 2) 339 (-splice-list 'keywordp nil '(1 :foo 2)) 340 ⇒ (1 2) 341 (--splice-list (keywordp it) '(a b c) '(1 :foo 2)) 342 ⇒ (1 a b c 2) 343 344 -- Function: -mapcat (fn list) 345 Return the concatenation of the result of mapping FN over LIST. 346 Thus function FN should return a list. 347 348 (-mapcat 'list '(1 2 3)) 349 ⇒ (1 2 3) 350 (-mapcat (lambda (item) (list 0 item)) '(1 2 3)) 351 ⇒ (0 1 0 2 0 3) 352 (--mapcat (list 0 it) '(1 2 3)) 353 ⇒ (0 1 0 2 0 3) 354 355 -- Function: -copy (list) 356 Create a shallow copy of LIST. 357 358 (-copy '(1 2 3)) 359 ⇒ (1 2 3) 360 (let ((a '(1 2 3))) (eq a (-copy a))) 361 ⇒ nil 362 363 364 File: dash.info, Node: Sublist selection, Next: List to list, Prev: Maps, Up: Functions 365 366 2.2 Sublist selection 367 ===================== 368 369 Functions returning a sublist of the original list. 370 371 -- Function: -filter (pred list) 372 Return a new list of the items in LIST for which PRED returns 373 non-‘nil’. 374 375 Alias: ‘-select’. 376 377 This function’s anaphoric counterpart is ‘--filter’. 378 379 For similar operations, see also ‘-keep’ (*note -keep::) and 380 ‘-remove’ (*note -remove::). 381 382 (-filter (lambda (num) (= 0 (% num 2))) '(1 2 3 4)) 383 ⇒ (2 4) 384 (-filter #'natnump '(-2 -1 0 1 2)) 385 ⇒ (0 1 2) 386 (--filter (= 0 (% it 2)) '(1 2 3 4)) 387 ⇒ (2 4) 388 389 -- Function: -remove (pred list) 390 Return a new list of the items in LIST for which PRED returns 391 ‘nil’. 392 393 Alias: ‘-reject’. 394 395 This function’s anaphoric counterpart is ‘--remove’. 396 397 For similar operations, see also ‘-keep’ (*note -keep::) and 398 ‘-filter’ (*note -filter::). 399 400 (-remove (lambda (num) (= 0 (% num 2))) '(1 2 3 4)) 401 ⇒ (1 3) 402 (-remove #'natnump '(-2 -1 0 1 2)) 403 ⇒ (-2 -1) 404 (--remove (= 0 (% it 2)) '(1 2 3 4)) 405 ⇒ (1 3) 406 407 -- Function: -remove-first (pred list) 408 Remove the first item from LIST for which PRED returns non-‘nil’. 409 This is a non-destructive operation, but only the front of LIST 410 leading up to the removed item is a copy; the rest is LIST’s 411 original tail. If no item is removed, then the result is a 412 complete copy. 413 414 Alias: ‘-reject-first’. 415 416 This function’s anaphoric counterpart is ‘--remove-first’. 417 418 See also ‘-map-first’ (*note -map-first::), ‘-remove-item’ (*note 419 -remove-item::), and ‘-remove-last’ (*note -remove-last::). 420 421 (-remove-first #'natnump '(-2 -1 0 1 2)) 422 ⇒ (-2 -1 1 2) 423 (-remove-first #'stringp '(1 2 "first" "second")) 424 ⇒ (1 2 "second") 425 (--remove-first (> it 3) '(1 2 3 4 5 6)) 426 ⇒ (1 2 3 5 6) 427 428 -- Function: -remove-last (pred list) 429 Remove the last item from LIST for which PRED returns non-‘nil’. 430 The result is a copy of LIST regardless of whether an element is 431 removed. 432 433 Alias: ‘-reject-last’. 434 435 This function’s anaphoric counterpart is ‘--remove-last’. 436 437 See also ‘-map-last’ (*note -map-last::), ‘-remove-item’ (*note 438 -remove-item::), and ‘-remove-first’ (*note -remove-first::). 439 440 (-remove-last #'natnump '(1 3 5 4 7 8 10 -11)) 441 ⇒ (1 3 5 4 7 8 -11) 442 (-remove-last #'stringp '(1 2 "last" "second")) 443 ⇒ (1 2 "last") 444 (--remove-last (> it 3) '(1 2 3 4 5 6 7 8 9 10)) 445 ⇒ (1 2 3 4 5 6 7 8 9) 446 447 -- Function: -remove-item (item list) 448 Return a copy of LIST with all occurrences of ITEM removed. The 449 comparison is done with ‘equal’. 450 451 (-remove-item 3 '(1 2 3 2 3 4 5 3)) 452 ⇒ (1 2 2 4 5) 453 (-remove-item 'foo '(foo bar baz foo)) 454 ⇒ (bar baz) 455 (-remove-item "bob" '("alice" "bob" "eve" "bob")) 456 ⇒ ("alice" "eve") 457 458 -- Function: -non-nil (list) 459 Return a copy of LIST with all ‘nil’ items removed. 460 461 (-non-nil '(nil 1 nil 2 nil nil 3 4 nil 5 nil)) 462 ⇒ (1 2 3 4 5) 463 (-non-nil '((nil))) 464 ⇒ ((nil)) 465 (-non-nil ()) 466 ⇒ () 467 468 -- Function: -slice (list from &optional to step) 469 Return copy of LIST, starting from index FROM to index TO. 470 471 FROM or TO may be negative. These values are then interpreted 472 modulo the length of the list. 473 474 If STEP is a number, only each STEPth item in the resulting section 475 is returned. Defaults to 1. 476 477 (-slice '(1 2 3 4 5) 1) 478 ⇒ (2 3 4 5) 479 (-slice '(1 2 3 4 5) 0 3) 480 ⇒ (1 2 3) 481 (-slice '(1 2 3 4 5 6 7 8 9) 1 -1 2) 482 ⇒ (2 4 6 8) 483 484 -- Function: -take (n list) 485 Return a copy of the first N items in LIST. Return a copy of LIST 486 if it contains N items or fewer. Return ‘nil’ if N is zero or 487 less. 488 489 See also: ‘-take-last’ (*note -take-last::). 490 491 (-take 3 '(1 2 3 4 5)) 492 ⇒ (1 2 3) 493 (-take 17 '(1 2 3 4 5)) 494 ⇒ (1 2 3 4 5) 495 (-take 0 '(1 2 3 4 5)) 496 ⇒ () 497 498 -- Function: -take-last (n list) 499 Return a copy of the last N items of LIST in order. Return a copy 500 of LIST if it contains N items or fewer. Return ‘nil’ if N is zero 501 or less. 502 503 See also: ‘-take’ (*note -take::). 504 505 (-take-last 3 '(1 2 3 4 5)) 506 ⇒ (3 4 5) 507 (-take-last 17 '(1 2 3 4 5)) 508 ⇒ (1 2 3 4 5) 509 (-take-last 1 '(1 2 3 4 5)) 510 ⇒ (5) 511 512 -- Function: -drop (n list) 513 Return the tail (not a copy) of LIST without the first N items. 514 Return ‘nil’ if LIST contains N items or fewer. Return LIST if N 515 is zero or less. 516 517 For another variant, see also ‘-drop-last’ (*note -drop-last::). 518 519 (-drop 3 '(1 2 3 4 5)) 520 ⇒ (4 5) 521 (-drop 17 '(1 2 3 4 5)) 522 ⇒ () 523 (-drop 0 '(1 2 3 4 5)) 524 ⇒ (1 2 3 4 5) 525 526 -- Function: -drop-last (n list) 527 Return a copy of LIST without its last N items. Return a copy of 528 LIST if N is zero or less. Return ‘nil’ if LIST contains N items 529 or fewer. 530 531 See also: ‘-drop’ (*note -drop::). 532 533 (-drop-last 3 '(1 2 3 4 5)) 534 ⇒ (1 2) 535 (-drop-last 17 '(1 2 3 4 5)) 536 ⇒ () 537 (-drop-last 0 '(1 2 3 4 5)) 538 ⇒ (1 2 3 4 5) 539 540 -- Function: -take-while (pred list) 541 Take successive items from LIST for which PRED returns non-‘nil’. 542 PRED is a function of one argument. Return a new list of the 543 successive elements from the start of LIST for which PRED returns 544 non-‘nil’. 545 546 This function’s anaphoric counterpart is ‘--take-while’. 547 548 For another variant, see also ‘-drop-while’ (*note -drop-while::). 549 550 (-take-while #'even? '(1 2 3 4)) 551 ⇒ () 552 (-take-while #'even? '(2 4 5 6)) 553 ⇒ (2 4) 554 (--take-while (< it 4) '(1 2 3 4 3 2 1)) 555 ⇒ (1 2 3) 556 557 -- Function: -drop-while (pred list) 558 Drop successive items from LIST for which PRED returns non-‘nil’. 559 PRED is a function of one argument. Return the tail (not a copy) 560 of LIST starting from its first element for which PRED returns 561 ‘nil’. 562 563 This function’s anaphoric counterpart is ‘--drop-while’. 564 565 For another variant, see also ‘-take-while’ (*note -take-while::). 566 567 (-drop-while #'even? '(1 2 3 4)) 568 ⇒ (1 2 3 4) 569 (-drop-while #'even? '(2 4 5 6)) 570 ⇒ (5 6) 571 (--drop-while (< it 4) '(1 2 3 4 3 2 1)) 572 ⇒ (4 3 2 1) 573 574 -- Function: -select-by-indices (indices list) 575 Return a list whose elements are elements from LIST selected as 576 ‘(nth i list)‘ for all i from INDICES. 577 578 (-select-by-indices '(4 10 2 3 6) '("v" "e" "l" "o" "c" "i" "r" "a" "p" "t" "o" "r")) 579 ⇒ ("c" "o" "l" "o" "r") 580 (-select-by-indices '(2 1 0) '("a" "b" "c")) 581 ⇒ ("c" "b" "a") 582 (-select-by-indices '(0 1 2 0 1 3 3 1) '("f" "a" "r" "l")) 583 ⇒ ("f" "a" "r" "f" "a" "l" "l" "a") 584 585 -- Function: -select-columns (columns table) 586 Select COLUMNS from TABLE. 587 588 TABLE is a list of lists where each element represents one row. It 589 is assumed each row has the same length. 590 591 Each row is transformed such that only the specified COLUMNS are 592 selected. 593 594 See also: ‘-select-column’ (*note -select-column::), 595 ‘-select-by-indices’ (*note -select-by-indices::) 596 597 (-select-columns '(0 2) '((1 2 3) (a b c) (:a :b :c))) 598 ⇒ ((1 3) (a c) (:a :c)) 599 (-select-columns '(1) '((1 2 3) (a b c) (:a :b :c))) 600 ⇒ ((2) (b) (:b)) 601 (-select-columns nil '((1 2 3) (a b c) (:a :b :c))) 602 ⇒ (nil nil nil) 603 604 -- Function: -select-column (column table) 605 Select COLUMN from TABLE. 606 607 TABLE is a list of lists where each element represents one row. It 608 is assumed each row has the same length. 609 610 The single selected column is returned as a list. 611 612 See also: ‘-select-columns’ (*note -select-columns::), 613 ‘-select-by-indices’ (*note -select-by-indices::) 614 615 (-select-column 1 '((1 2 3) (a b c) (:a :b :c))) 616 ⇒ (2 b :b) 617 618 619 File: dash.info, Node: List to list, Next: Reductions, Prev: Sublist selection, Up: Functions 620 621 2.3 List to list 622 ================ 623 624 Functions returning a modified copy of the input list. 625 626 -- Function: -keep (fn list) 627 Return a new list of the non-‘nil’ results of applying FN to each 628 item in LIST. Like ‘-filter’ (*note -filter::), but returns the 629 non-‘nil’ results of FN instead of the corresponding elements of 630 LIST. 631 632 Its anaphoric counterpart is ‘--keep’. 633 634 (-keep #'cdr '((1 2 3) (4 5) (6))) 635 ⇒ ((2 3) (5)) 636 (-keep (lambda (n) (and (> n 3) (* 10 n))) '(1 2 3 4 5 6)) 637 ⇒ (40 50 60) 638 (--keep (and (> it 3) (* 10 it)) '(1 2 3 4 5 6)) 639 ⇒ (40 50 60) 640 641 -- Function: -concat (&rest sequences) 642 Concatenate all the arguments and make the result a list. The 643 result is a list whose elements are the elements of all the 644 arguments. Each argument may be a list, vector or string. 645 646 All arguments except the last argument are copied. The last 647 argument is just used as the tail of the new list. 648 649 (-concat '(1)) 650 ⇒ (1) 651 (-concat '(1) '(2)) 652 ⇒ (1 2) 653 (-concat '(1) '(2 3) '(4)) 654 ⇒ (1 2 3 4) 655 656 -- Function: -flatten (l) 657 Take a nested list L and return its contents as a single, flat 658 list. 659 660 Note that because ‘nil’ represents a list of zero elements (an 661 empty list), any mention of ‘nil’ in L will disappear after 662 flattening. If you need to preserve nils, consider ‘-flatten-n’ 663 (*note -flatten-n::) or map them to some unique symbol and then map 664 them back. 665 666 Conses of two atoms are considered "terminals", that is, they 667 aren’t flattened further. 668 669 See also: ‘-flatten-n’ (*note -flatten-n::) 670 671 (-flatten '((1))) 672 ⇒ (1) 673 (-flatten '((1 (2 3) (((4 (5))))))) 674 ⇒ (1 2 3 4 5) 675 (-flatten '(1 2 (3 . 4))) 676 ⇒ (1 2 (3 . 4)) 677 678 -- Function: -flatten-n (num list) 679 Flatten NUM levels of a nested LIST. 680 681 See also: ‘-flatten’ (*note -flatten::) 682 683 (-flatten-n 1 '((1 2) ((3 4) ((5 6))))) 684 ⇒ (1 2 (3 4) ((5 6))) 685 (-flatten-n 2 '((1 2) ((3 4) ((5 6))))) 686 ⇒ (1 2 3 4 (5 6)) 687 (-flatten-n 3 '((1 2) ((3 4) ((5 6))))) 688 ⇒ (1 2 3 4 5 6) 689 690 -- Function: -replace (old new list) 691 Replace all OLD items in LIST with NEW. 692 693 Elements are compared using ‘equal’. 694 695 See also: ‘-replace-at’ (*note -replace-at::) 696 697 (-replace 1 "1" '(1 2 3 4 3 2 1)) 698 ⇒ ("1" 2 3 4 3 2 "1") 699 (-replace "foo" "bar" '("a" "nice" "foo" "sentence" "about" "foo")) 700 ⇒ ("a" "nice" "bar" "sentence" "about" "bar") 701 (-replace 1 2 nil) 702 ⇒ nil 703 704 -- Function: -replace-first (old new list) 705 Replace the first occurrence of OLD with NEW in LIST. 706 707 Elements are compared using ‘equal’. 708 709 See also: ‘-map-first’ (*note -map-first::) 710 711 (-replace-first 1 "1" '(1 2 3 4 3 2 1)) 712 ⇒ ("1" 2 3 4 3 2 1) 713 (-replace-first "foo" "bar" '("a" "nice" "foo" "sentence" "about" "foo")) 714 ⇒ ("a" "nice" "bar" "sentence" "about" "foo") 715 (-replace-first 1 2 nil) 716 ⇒ nil 717 718 -- Function: -replace-last (old new list) 719 Replace the last occurrence of OLD with NEW in LIST. 720 721 Elements are compared using ‘equal’. 722 723 See also: ‘-map-last’ (*note -map-last::) 724 725 (-replace-last 1 "1" '(1 2 3 4 3 2 1)) 726 ⇒ (1 2 3 4 3 2 "1") 727 (-replace-last "foo" "bar" '("a" "nice" "foo" "sentence" "about" "foo")) 728 ⇒ ("a" "nice" "foo" "sentence" "about" "bar") 729 (-replace-last 1 2 nil) 730 ⇒ nil 731 732 -- Function: -insert-at (n x list) 733 Return a list with X inserted into LIST at position N. 734 735 See also: ‘-splice’ (*note -splice::), ‘-splice-list’ (*note 736 -splice-list::) 737 738 (-insert-at 1 'x '(a b c)) 739 ⇒ (a x b c) 740 (-insert-at 12 'x '(a b c)) 741 ⇒ (a b c x) 742 743 -- Function: -replace-at (n x list) 744 Return a list with element at Nth position in LIST replaced with X. 745 746 See also: ‘-replace’ (*note -replace::) 747 748 (-replace-at 0 9 '(0 1 2 3 4 5)) 749 ⇒ (9 1 2 3 4 5) 750 (-replace-at 1 9 '(0 1 2 3 4 5)) 751 ⇒ (0 9 2 3 4 5) 752 (-replace-at 4 9 '(0 1 2 3 4 5)) 753 ⇒ (0 1 2 3 9 5) 754 755 -- Function: -update-at (n func list) 756 Use FUNC to update the Nth element of LIST. Return a copy of LIST 757 where the Nth element is replaced with the result of calling FUNC 758 on it. 759 760 See also: ‘-map-when’ (*note -map-when::) 761 762 (-update-at 0 (lambda (x) (+ x 9)) '(0 1 2 3 4 5)) 763 ⇒ (9 1 2 3 4 5) 764 (-update-at 1 (lambda (x) (+ x 8)) '(0 1 2 3 4 5)) 765 ⇒ (0 9 2 3 4 5) 766 (--update-at 2 (length it) '("foo" "bar" "baz" "quux")) 767 ⇒ ("foo" "bar" 3 "quux") 768 769 -- Function: -remove-at (n list) 770 Return LIST with its element at index N removed. That is, remove 771 any element selected as (nth N LIST) from LIST and return the 772 result. 773 774 This is a non-destructive operation: parts of LIST (but not 775 necessarily all of it) are copied as needed to avoid destructively 776 modifying it. 777 778 See also: ‘-remove-at-indices’ (*note -remove-at-indices::), 779 ‘-remove’ (*note -remove::). 780 781 (-remove-at 0 '(a b c)) 782 ⇒ (b c) 783 (-remove-at 1 '(a b c)) 784 ⇒ (a c) 785 (-remove-at 2 '(a b c)) 786 ⇒ (a b) 787 788 -- Function: -remove-at-indices (indices list) 789 Return LIST with its elements at INDICES removed. That is, for 790 each index I in INDICES, remove any element selected as (nth I 791 LIST) from LIST. 792 793 This is a non-destructive operation: parts of LIST (but not 794 necessarily all of it) are copied as needed to avoid destructively 795 modifying it. 796 797 See also: ‘-remove-at’ (*note -remove-at::), ‘-remove’ (*note 798 -remove::). 799 800 (-remove-at-indices '(0) '(a b c d e)) 801 ⇒ (b c d e) 802 (-remove-at-indices '(1 3) '(a b c d e)) 803 ⇒ (a c e) 804 (-remove-at-indices '(4 0 2) '(a b c d e)) 805 ⇒ (b d) 806 807 808 File: dash.info, Node: Reductions, Next: Unfolding, Prev: List to list, Up: Functions 809 810 2.4 Reductions 811 ============== 812 813 Functions reducing lists to a single value (which may also be a list). 814 815 -- Function: -reduce-from (fn init list) 816 Reduce the function FN across LIST, starting with INIT. Return the 817 result of applying FN to INIT and the first element of LIST, then 818 applying FN to that result and the second element, etc. If LIST is 819 empty, return INIT without calling FN. 820 821 This function’s anaphoric counterpart is ‘--reduce-from’. 822 823 For other folds, see also ‘-reduce’ (*note -reduce::) and 824 ‘-reduce-r’ (*note -reduce-r::). 825 826 (-reduce-from #'- 10 '(1 2 3)) 827 ⇒ 4 828 (-reduce-from #'list 10 '(1 2 3)) 829 ⇒ (((10 1) 2) 3) 830 (--reduce-from (concat acc " " it) "START" '("a" "b" "c")) 831 ⇒ "START a b c" 832 833 -- Function: -reduce-r-from (fn init list) 834 Reduce the function FN across LIST in reverse, starting with INIT. 835 Return the result of applying FN to the last element of LIST and 836 INIT, then applying FN to the second-to-last element and the 837 previous result of FN, etc. That is, the first argument of FN is 838 the current element, and its second argument the accumulated value. 839 If LIST is empty, return INIT without calling FN. 840 841 This function is like ‘-reduce-from’ (*note -reduce-from::) but the 842 operation associates from the right rather than left. In other 843 words, it starts from the end of LIST and flips the arguments to 844 FN. Conceptually, it is like replacing the conses in LIST with 845 applications of FN, and its last link with INIT, and evaluating the 846 resulting expression. 847 848 This function’s anaphoric counterpart is ‘--reduce-r-from’. 849 850 For other folds, see also ‘-reduce-r’ (*note -reduce-r::) and 851 ‘-reduce’ (*note -reduce::). 852 853 (-reduce-r-from #'- 10 '(1 2 3)) 854 ⇒ -8 855 (-reduce-r-from #'list 10 '(1 2 3)) 856 ⇒ (1 (2 (3 10))) 857 (--reduce-r-from (concat it " " acc) "END" '("a" "b" "c")) 858 ⇒ "a b c END" 859 860 -- Function: -reduce (fn list) 861 Reduce the function FN across LIST. Return the result of applying 862 FN to the first two elements of LIST, then applying FN to that 863 result and the third element, etc. If LIST contains a single 864 element, return it without calling FN. If LIST is empty, return 865 the result of calling FN with no arguments. 866 867 This function’s anaphoric counterpart is ‘--reduce’. 868 869 For other folds, see also ‘-reduce-from’ (*note -reduce-from::) and 870 ‘-reduce-r’ (*note -reduce-r::). 871 872 (-reduce #'- '(1 2 3 4)) 873 ⇒ -8 874 (-reduce #'list '(1 2 3 4)) 875 ⇒ (((1 2) 3) 4) 876 (--reduce (format "%s-%d" acc it) '(1 2 3)) 877 ⇒ "1-2-3" 878 879 -- Function: -reduce-r (fn list) 880 Reduce the function FN across LIST in reverse. Return the result 881 of applying FN to the last two elements of LIST, then applying FN 882 to the third-to-last element and the previous result of FN, etc. 883 That is, the first argument of FN is the current element, and its 884 second argument the accumulated value. If LIST contains a single 885 element, return it without calling FN. If LIST is empty, return 886 the result of calling FN with no arguments. 887 888 This function is like ‘-reduce’ (*note -reduce::) but the operation 889 associates from the right rather than left. In other words, it 890 starts from the end of LIST and flips the arguments to FN. 891 Conceptually, it is like replacing the conses in LIST with 892 applications of FN, ignoring its last link, and evaluating the 893 resulting expression. 894 895 This function’s anaphoric counterpart is ‘--reduce-r’. 896 897 For other folds, see also ‘-reduce-r-from’ (*note -reduce-r-from::) 898 and ‘-reduce’ (*note -reduce::). 899 900 (-reduce-r #'- '(1 2 3 4)) 901 ⇒ -2 902 (-reduce-r #'list '(1 2 3 4)) 903 ⇒ (1 (2 (3 4))) 904 (--reduce-r (format "%s-%d" acc it) '(1 2 3)) 905 ⇒ "3-2-1" 906 907 -- Function: -reductions-from (fn init list) 908 Return a list of FN’s intermediate reductions across LIST. That 909 is, a list of the intermediate values of the accumulator when 910 ‘-reduce-from’ (*note -reduce-from::) (which see) is called with 911 the same arguments. 912 913 This function’s anaphoric counterpart is ‘--reductions-from’. 914 915 For other folds, see also ‘-reductions’ (*note -reductions::) and 916 ‘-reductions-r’ (*note -reductions-r::). 917 918 (-reductions-from #'max 0 '(2 1 4 3)) 919 ⇒ (0 2 2 4 4) 920 (-reductions-from #'* 1 '(1 2 3 4)) 921 ⇒ (1 1 2 6 24) 922 (--reductions-from (format "(FN %s %d)" acc it) "INIT" '(1 2 3)) 923 ⇒ ("INIT" "(FN INIT 1)" "(FN (FN INIT 1) 2)" "(FN (FN (FN INIT 1) 2) 3)") 924 925 -- Function: -reductions-r-from (fn init list) 926 Return a list of FN’s intermediate reductions across reversed LIST. 927 That is, a list of the intermediate values of the accumulator when 928 ‘-reduce-r-from’ (*note -reduce-r-from::) (which see) is called 929 with the same arguments. 930 931 This function’s anaphoric counterpart is ‘--reductions-r-from’. 932 933 For other folds, see also ‘-reductions’ (*note -reductions::) and 934 ‘-reductions-r’ (*note -reductions-r::). 935 936 (-reductions-r-from #'max 0 '(2 1 4 3)) 937 ⇒ (4 4 4 3 0) 938 (-reductions-r-from #'* 1 '(1 2 3 4)) 939 ⇒ (24 24 12 4 1) 940 (--reductions-r-from (format "(FN %d %s)" it acc) "INIT" '(1 2 3)) 941 ⇒ ("(FN 1 (FN 2 (FN 3 INIT)))" "(FN 2 (FN 3 INIT))" "(FN 3 INIT)" "INIT") 942 943 -- Function: -reductions (fn list) 944 Return a list of FN’s intermediate reductions across LIST. That 945 is, a list of the intermediate values of the accumulator when 946 ‘-reduce’ (*note -reduce::) (which see) is called with the same 947 arguments. 948 949 This function’s anaphoric counterpart is ‘--reductions’. 950 951 For other folds, see also ‘-reductions’ (*note -reductions::) and 952 ‘-reductions-r’ (*note -reductions-r::). 953 954 (-reductions #'+ '(1 2 3 4)) 955 ⇒ (1 3 6 10) 956 (-reductions #'* '(1 2 3 4)) 957 ⇒ (1 2 6 24) 958 (--reductions (format "(FN %s %d)" acc it) '(1 2 3)) 959 ⇒ (1 "(FN 1 2)" "(FN (FN 1 2) 3)") 960 961 -- Function: -reductions-r (fn list) 962 Return a list of FN’s intermediate reductions across reversed LIST. 963 That is, a list of the intermediate values of the accumulator when 964 ‘-reduce-r’ (*note -reduce-r::) (which see) is called with the same 965 arguments. 966 967 This function’s anaphoric counterpart is ‘--reductions-r’. 968 969 For other folds, see also ‘-reductions-r-from’ (*note 970 -reductions-r-from::) and ‘-reductions’ (*note -reductions::). 971 972 (-reductions-r #'+ '(1 2 3 4)) 973 ⇒ (10 9 7 4) 974 (-reductions-r #'* '(1 2 3 4)) 975 ⇒ (24 24 12 4) 976 (--reductions-r (format "(FN %d %s)" it acc) '(1 2 3)) 977 ⇒ ("(FN 1 (FN 2 3))" "(FN 2 3)" 3) 978 979 -- Function: -count (pred list) 980 Counts the number of items in LIST where (PRED item) is non-‘nil’. 981 982 (-count 'even? '(1 2 3 4 5)) 983 ⇒ 2 984 (--count (< it 4) '(1 2 3 4)) 985 ⇒ 3 986 987 -- Function: -sum (list) 988 Return the sum of LIST. 989 990 (-sum ()) 991 ⇒ 0 992 (-sum '(1)) 993 ⇒ 1 994 (-sum '(1 2 3 4)) 995 ⇒ 10 996 997 -- Function: -running-sum (list) 998 Return a list with running sums of items in LIST. LIST must be 999 non-empty. 1000 1001 (-running-sum '(1 2 3 4)) 1002 ⇒ (1 3 6 10) 1003 (-running-sum '(1)) 1004 ⇒ (1) 1005 (-running-sum ()) 1006 error→ Wrong type argument: consp, nil 1007 1008 -- Function: -product (list) 1009 Return the product of LIST. 1010 1011 (-product ()) 1012 ⇒ 1 1013 (-product '(1)) 1014 ⇒ 1 1015 (-product '(1 2 3 4)) 1016 ⇒ 24 1017 1018 -- Function: -running-product (list) 1019 Return a list with running products of items in LIST. LIST must be 1020 non-empty. 1021 1022 (-running-product '(1 2 3 4)) 1023 ⇒ (1 2 6 24) 1024 (-running-product '(1)) 1025 ⇒ (1) 1026 (-running-product ()) 1027 error→ Wrong type argument: consp, nil 1028 1029 -- Function: -inits (list) 1030 Return all prefixes of LIST. 1031 1032 (-inits '(1 2 3 4)) 1033 ⇒ (nil (1) (1 2) (1 2 3) (1 2 3 4)) 1034 (-inits nil) 1035 ⇒ (nil) 1036 (-inits '(1)) 1037 ⇒ (nil (1)) 1038 1039 -- Function: -tails (list) 1040 Return all suffixes of LIST. 1041 1042 (-tails '(1 2 3 4)) 1043 ⇒ ((1 2 3 4) (2 3 4) (3 4) (4) nil) 1044 (-tails nil) 1045 ⇒ (nil) 1046 (-tails '(1)) 1047 ⇒ ((1) nil) 1048 1049 -- Function: -common-prefix (&rest lists) 1050 Return the longest common prefix of LISTS. 1051 1052 (-common-prefix '(1)) 1053 ⇒ (1) 1054 (-common-prefix '(1 2) '(3 4) '(1 2)) 1055 ⇒ () 1056 (-common-prefix '(1 2) '(1 2 3) '(1 2 3 4)) 1057 ⇒ (1 2) 1058 1059 -- Function: -common-suffix (&rest lists) 1060 Return the longest common suffix of LISTS. 1061 1062 (-common-suffix '(1)) 1063 ⇒ (1) 1064 (-common-suffix '(1 2) '(3 4) '(1 2)) 1065 ⇒ () 1066 (-common-suffix '(1 2 3 4) '(2 3 4) '(3 4)) 1067 ⇒ (3 4) 1068 1069 -- Function: -min (list) 1070 Return the smallest value from LIST of numbers or markers. 1071 1072 (-min '(0)) 1073 ⇒ 0 1074 (-min '(3 2 1)) 1075 ⇒ 1 1076 (-min '(1 2 3)) 1077 ⇒ 1 1078 1079 -- Function: -min-by (comparator list) 1080 Take a comparison function COMPARATOR and a LIST and return the 1081 least element of the list by the comparison function. 1082 1083 See also combinator ‘-on’ (*note -on::) which can transform the 1084 values before comparing them. 1085 1086 (-min-by '> '(4 3 6 1)) 1087 ⇒ 1 1088 (--min-by (> (car it) (car other)) '((1 2 3) (2) (3 2))) 1089 ⇒ (1 2 3) 1090 (--min-by (> (length it) (length other)) '((1 2 3) (2) (3 2))) 1091 ⇒ (2) 1092 1093 -- Function: -max (list) 1094 Return the largest value from LIST of numbers or markers. 1095 1096 (-max '(0)) 1097 ⇒ 0 1098 (-max '(3 2 1)) 1099 ⇒ 3 1100 (-max '(1 2 3)) 1101 ⇒ 3 1102 1103 -- Function: -max-by (comparator list) 1104 Take a comparison function COMPARATOR and a LIST and return the 1105 greatest element of the list by the comparison function. 1106 1107 See also combinator ‘-on’ (*note -on::) which can transform the 1108 values before comparing them. 1109 1110 (-max-by '> '(4 3 6 1)) 1111 ⇒ 6 1112 (--max-by (> (car it) (car other)) '((1 2 3) (2) (3 2))) 1113 ⇒ (3 2) 1114 (--max-by (> (length it) (length other)) '((1 2 3) (2) (3 2))) 1115 ⇒ (1 2 3) 1116 1117 -- Function: -frequencies (list) 1118 Count the occurrences of each distinct element of LIST. 1119 1120 Return an alist of (ELEMENT . N), where each ELEMENT occurs N 1121 times in LIST. 1122 1123 The test for equality is done with ‘equal’, or with ‘-compare-fn’ 1124 if that is non-‘nil’. 1125 1126 See also ‘-count’ (*note -count::) and ‘-group-by’ (*note 1127 -group-by::). 1128 1129 (-frequencies ()) 1130 ⇒ () 1131 (-frequencies '(1 2 3 1 2 1)) 1132 ⇒ ((1 . 3) (2 . 2) (3 . 1)) 1133 (let ((-compare-fn #'string=)) (-frequencies '(a "a"))) 1134 ⇒ ((a . 2)) 1135 1136 1137 File: dash.info, Node: Unfolding, Next: Predicates, Prev: Reductions, Up: Functions 1138 1139 2.5 Unfolding 1140 ============= 1141 1142 Operations dual to reductions, building lists from a seed value rather 1143 than consuming a list to produce a single value. 1144 1145 -- Function: -iterate (fun init n) 1146 Return a list of iterated applications of FUN to INIT. 1147 1148 This means a list of the form: 1149 1150 (INIT (FUN INIT) (FUN (FUN INIT)) ...) 1151 1152 N is the length of the returned list. 1153 1154 (-iterate #'1+ 1 10) 1155 ⇒ (1 2 3 4 5 6 7 8 9 10) 1156 (-iterate (lambda (x) (+ x x)) 2 5) 1157 ⇒ (2 4 8 16 32) 1158 (--iterate (* it it) 2 5) 1159 ⇒ (2 4 16 256 65536) 1160 1161 -- Function: -unfold (fun seed) 1162 Build a list from SEED using FUN. 1163 1164 This is "dual" operation to ‘-reduce-r’ (*note -reduce-r::): while 1165 -reduce-r consumes a list to produce a single value, ‘-unfold’ 1166 (*note -unfold::) takes a seed value and builds a (potentially 1167 infinite!) list. 1168 1169 FUN should return ‘nil’ to stop the generating process, or a cons 1170 (A . B), where A will be prepended to the result and B is the new 1171 seed. 1172 1173 (-unfold (lambda (x) (unless (= x 0) (cons x (1- x)))) 10) 1174 ⇒ (10 9 8 7 6 5 4 3 2 1) 1175 (--unfold (when it (cons it (cdr it))) '(1 2 3 4)) 1176 ⇒ ((1 2 3 4) (2 3 4) (3 4) (4)) 1177 (--unfold (when it (cons it (butlast it))) '(1 2 3 4)) 1178 ⇒ ((1 2 3 4) (1 2 3) (1 2) (1)) 1179 1180 -- Function: -repeat (n x) 1181 Return a new list of length N with each element being X. Return 1182 ‘nil’ if N is less than 1. 1183 1184 (-repeat 3 :a) 1185 ⇒ (:a :a :a) 1186 (-repeat 1 :a) 1187 ⇒ (:a) 1188 (-repeat 0 :a) 1189 ⇒ () 1190 1191 -- Function: -cycle (list) 1192 Return an infinite circular copy of LIST. The returned list cycles 1193 through the elements of LIST and repeats from the beginning. 1194 1195 (-take 5 (-cycle '(1 2 3))) 1196 ⇒ (1 2 3 1 2) 1197 (-take 7 (-cycle '(1 "and" 3))) 1198 ⇒ (1 "and" 3 1 "and" 3 1) 1199 (-zip-lists (-cycle '(3)) '(1 2)) 1200 ⇒ ((3 1) (3 2)) 1201 1202 1203 File: dash.info, Node: Predicates, Next: Partitioning, Prev: Unfolding, Up: Functions 1204 1205 2.6 Predicates 1206 ============== 1207 1208 Reductions of one or more lists to a boolean value. 1209 1210 -- Function: -some (pred list) 1211 Return (PRED x) for the first LIST item where (PRED x) is 1212 non-‘nil’, else ‘nil’. 1213 1214 Alias: ‘-any’. 1215 1216 This function’s anaphoric counterpart is ‘--some’. 1217 1218 (-some #'stringp '(1 "2" 3)) 1219 ⇒ t 1220 (--some (string-match-p "x" it) '("foo" "axe" "xor")) 1221 ⇒ 1 1222 (--some (= it-index 3) '(0 1 2)) 1223 ⇒ nil 1224 1225 -- Function: -every (pred list) 1226 Return non-‘nil’ if PRED returns non-‘nil’ for all items in LIST. 1227 If so, return the last such result of PRED. Otherwise, once an 1228 item is reached for which PRED returns ‘nil’, return ‘nil’ without 1229 calling PRED on any further LIST elements. 1230 1231 This function is like ‘-every-p’, but on success returns the last 1232 non-‘nil’ result of PRED instead of just ‘t’. 1233 1234 This function’s anaphoric counterpart is ‘--every’. 1235 1236 (-every #'numberp '(1 2 3)) 1237 ⇒ t 1238 (--every (string-match-p "x" it) '("axe" "xor")) 1239 ⇒ 0 1240 (--every (= it it-index) '(0 1 3)) 1241 ⇒ nil 1242 1243 -- Function: -any? (pred list) 1244 Return ‘t’ if (PRED X) is non-‘nil’ for any X in LIST, else ‘nil’. 1245 1246 Alias: ‘-any-p’, ‘-some?’, ‘-some-p’ 1247 1248 (-any? #'numberp '(nil 0 t)) 1249 ⇒ t 1250 (-any? #'numberp '(nil t t)) 1251 ⇒ nil 1252 (-any? #'null '(1 3 5)) 1253 ⇒ nil 1254 1255 -- Function: -all? (pred list) 1256 Return ‘t’ if (PRED X) is non-‘nil’ for all X in LIST, else ‘nil’. 1257 In the latter case, stop after the first X for which (PRED X) is 1258 ‘nil’, without calling PRED on any subsequent elements of LIST. 1259 1260 The similar function ‘-every’ (*note -every::) is more widely 1261 useful, since it returns the last non-‘nil’ result of PRED instead 1262 of just ‘t’ on success. 1263 1264 Alias: ‘-all-p’, ‘-every-p’, ‘-every?’. 1265 1266 This function’s anaphoric counterpart is ‘--all?’. 1267 1268 (-all? #'numberp '(1 2 3)) 1269 ⇒ t 1270 (-all? #'numberp '(2 t 6)) 1271 ⇒ nil 1272 (--all? (= 0 (% it 2)) '(2 4 6)) 1273 ⇒ t 1274 1275 -- Function: -none? (pred list) 1276 Return ‘t’ if (PRED X) is ‘nil’ for all X in LIST, else ‘nil’. 1277 1278 Alias: ‘-none-p’ 1279 1280 (-none? 'even? '(1 2 3)) 1281 ⇒ nil 1282 (-none? 'even? '(1 3 5)) 1283 ⇒ t 1284 (--none? (= 0 (% it 2)) '(1 2 3)) 1285 ⇒ nil 1286 1287 -- Function: -only-some? (pred list) 1288 Return ‘t’ if different LIST items both satisfy and do not satisfy 1289 PRED. That is, if PRED returns both ‘nil’ for at least one item, 1290 and non-‘nil’ for at least one other item in LIST. Return ‘nil’ if 1291 all items satisfy the predicate or none of them do. 1292 1293 Alias: ‘-only-some-p’ 1294 1295 (-only-some? 'even? '(1 2 3)) 1296 ⇒ t 1297 (-only-some? 'even? '(1 3 5)) 1298 ⇒ nil 1299 (-only-some? 'even? '(2 4 6)) 1300 ⇒ nil 1301 1302 -- Function: -contains? (list element) 1303 Return non-‘nil’ if LIST contains ELEMENT. 1304 1305 The test for equality is done with ‘equal’, or with ‘-compare-fn’ 1306 if that is non-‘nil’. As with ‘member’, the return value is 1307 actually the tail of LIST whose car is ELEMENT. 1308 1309 Alias: ‘-contains-p’. 1310 1311 (-contains? '(1 2 3) 1) 1312 ⇒ (1 2 3) 1313 (-contains? '(1 2 3) 2) 1314 ⇒ (2 3) 1315 (-contains? '(1 2 3) 4) 1316 ⇒ () 1317 1318 -- Function: -is-prefix? (prefix list) 1319 Return non-‘nil’ if PREFIX is a prefix of LIST. 1320 1321 Alias: ‘-is-prefix-p’. 1322 1323 (-is-prefix? '(1 2 3) '(1 2 3 4 5)) 1324 ⇒ t 1325 (-is-prefix? '(1 2 3 4 5) '(1 2 3)) 1326 ⇒ nil 1327 (-is-prefix? '(1 3) '(1 2 3 4 5)) 1328 ⇒ nil 1329 1330 -- Function: -is-suffix? (suffix list) 1331 Return non-‘nil’ if SUFFIX is a suffix of LIST. 1332 1333 Alias: ‘-is-suffix-p’. 1334 1335 (-is-suffix? '(3 4 5) '(1 2 3 4 5)) 1336 ⇒ t 1337 (-is-suffix? '(1 2 3 4 5) '(3 4 5)) 1338 ⇒ nil 1339 (-is-suffix? '(3 5) '(1 2 3 4 5)) 1340 ⇒ nil 1341 1342 -- Function: -is-infix? (infix list) 1343 Return non-‘nil’ if INFIX is infix of LIST. 1344 1345 This operation runs in O(n^2) time 1346 1347 Alias: ‘-is-infix-p’ 1348 1349 (-is-infix? '(1 2 3) '(1 2 3 4 5)) 1350 ⇒ t 1351 (-is-infix? '(2 3 4) '(1 2 3 4 5)) 1352 ⇒ t 1353 (-is-infix? '(3 4 5) '(1 2 3 4 5)) 1354 ⇒ t 1355 1356 -- Function: -cons-pair? (obj) 1357 Return non-‘nil’ if OBJ is a true cons pair. That is, a cons (A . 1358 B) where B is not a list. 1359 1360 Alias: ‘-cons-pair-p’. 1361 1362 (-cons-pair? '(1 . 2)) 1363 ⇒ t 1364 (-cons-pair? '(1 2)) 1365 ⇒ nil 1366 (-cons-pair? '(1)) 1367 ⇒ nil 1368 1369 1370 File: dash.info, Node: Partitioning, Next: Indexing, Prev: Predicates, Up: Functions 1371 1372 2.7 Partitioning 1373 ================ 1374 1375 Functions partitioning the input list into a list of lists. 1376 1377 -- Function: -split-at (n list) 1378 Split LIST into two sublists after the Nth element. The result is 1379 a list of two elements (TAKE DROP) where TAKE is a new list of the 1380 first N elements of LIST, and DROP is the remaining elements of 1381 LIST (not a copy). TAKE and DROP are like the results of ‘-take’ 1382 (*note -take::) and ‘-drop’ (*note -drop::), respectively, but the 1383 split is done in a single list traversal. 1384 1385 (-split-at 3 '(1 2 3 4 5)) 1386 ⇒ ((1 2 3) (4 5)) 1387 (-split-at 17 '(1 2 3 4 5)) 1388 ⇒ ((1 2 3 4 5) nil) 1389 (-split-at 0 '(1 2 3 4 5)) 1390 ⇒ (nil (1 2 3 4 5)) 1391 1392 -- Function: -split-with (pred list) 1393 Split LIST into a prefix satisfying PRED, and the rest. The first 1394 sublist is the prefix of LIST with successive elements satisfying 1395 PRED, and the second sublist is the remaining elements that do not. 1396 The result is like performing 1397 1398 ((-take-while PRED LIST) (-drop-while PRED LIST)) 1399 1400 but in no more than a single pass through LIST. 1401 1402 (-split-with 'even? '(1 2 3 4)) 1403 ⇒ (nil (1 2 3 4)) 1404 (-split-with 'even? '(2 4 5 6)) 1405 ⇒ ((2 4) (5 6)) 1406 (--split-with (< it 4) '(1 2 3 4 3 2 1)) 1407 ⇒ ((1 2 3) (4 3 2 1)) 1408 1409 -- Macro: -split-on (item list) 1410 Split the LIST each time ITEM is found. 1411 1412 Unlike ‘-partition-by’ (*note -partition-by::), the ITEM is 1413 discarded from the results. Empty lists are also removed from the 1414 result. 1415 1416 Comparison is done by ‘equal’. 1417 1418 See also ‘-split-when’ (*note -split-when::) 1419 1420 (-split-on '| '(Nil | Leaf a | Node [Tree a])) 1421 ⇒ ((Nil) (Leaf a) (Node [Tree a])) 1422 (-split-on :endgroup '("a" "b" :endgroup "c" :endgroup "d" "e")) 1423 ⇒ (("a" "b") ("c") ("d" "e")) 1424 (-split-on :endgroup '("a" "b" :endgroup :endgroup "d" "e")) 1425 ⇒ (("a" "b") ("d" "e")) 1426 1427 -- Function: -split-when (fn list) 1428 Split the LIST on each element where FN returns non-‘nil’. 1429 1430 Unlike ‘-partition-by’ (*note -partition-by::), the "matched" 1431 element is discarded from the results. Empty lists are also 1432 removed from the result. 1433 1434 This function can be thought of as a generalization of 1435 ‘split-string’. 1436 1437 (-split-when 'even? '(1 2 3 4 5 6)) 1438 ⇒ ((1) (3) (5)) 1439 (-split-when 'even? '(1 2 3 4 6 8 9)) 1440 ⇒ ((1) (3) (9)) 1441 (--split-when (memq it '(&optional &rest)) '(a b &optional c d &rest args)) 1442 ⇒ ((a b) (c d) (args)) 1443 1444 -- Function: -separate (pred list) 1445 Split LIST into two sublists based on whether items satisfy PRED. 1446 The result is like performing 1447 1448 ((-filter PRED LIST) (-remove PRED LIST)) 1449 1450 but in a single pass through LIST. 1451 1452 (-separate (lambda (num) (= 0 (% num 2))) '(1 2 3 4 5 6 7)) 1453 ⇒ ((2 4 6) (1 3 5 7)) 1454 (--separate (< it 5) '(3 7 5 9 3 2 1 4 6)) 1455 ⇒ ((3 3 2 1 4) (7 5 9 6)) 1456 (-separate 'cdr '((1 2) (1) (1 2 3) (4))) 1457 ⇒ (((1 2) (1 2 3)) ((1) (4))) 1458 1459 -- Function: -partition (n list) 1460 Return a new list with the items in LIST grouped into N-sized 1461 sublists. If there are not enough items to make the last group 1462 N-sized, those items are discarded. 1463 1464 (-partition 2 '(1 2 3 4 5 6)) 1465 ⇒ ((1 2) (3 4) (5 6)) 1466 (-partition 2 '(1 2 3 4 5 6 7)) 1467 ⇒ ((1 2) (3 4) (5 6)) 1468 (-partition 3 '(1 2 3 4 5 6 7)) 1469 ⇒ ((1 2 3) (4 5 6)) 1470 1471 -- Function: -partition-all (n list) 1472 Return a new list with the items in LIST grouped into N-sized 1473 sublists. The last group may contain less than N items. 1474 1475 (-partition-all 2 '(1 2 3 4 5 6)) 1476 ⇒ ((1 2) (3 4) (5 6)) 1477 (-partition-all 2 '(1 2 3 4 5 6 7)) 1478 ⇒ ((1 2) (3 4) (5 6) (7)) 1479 (-partition-all 3 '(1 2 3 4 5 6 7)) 1480 ⇒ ((1 2 3) (4 5 6) (7)) 1481 1482 -- Function: -partition-in-steps (n step list) 1483 Partition LIST into sublists of length N that are STEP items apart. 1484 Like ‘-partition-all-in-steps’ (*note -partition-all-in-steps::), 1485 but if there are not enough items to make the last group N-sized, 1486 those items are discarded. 1487 1488 (-partition-in-steps 2 1 '(1 2 3 4)) 1489 ⇒ ((1 2) (2 3) (3 4)) 1490 (-partition-in-steps 3 2 '(1 2 3 4)) 1491 ⇒ ((1 2 3)) 1492 (-partition-in-steps 3 2 '(1 2 3 4 5)) 1493 ⇒ ((1 2 3) (3 4 5)) 1494 1495 -- Function: -partition-all-in-steps (n step list) 1496 Partition LIST into sublists of length N that are STEP items apart. 1497 Adjacent groups may overlap if N exceeds the STEP stride. Trailing 1498 groups may contain less than N items. 1499 1500 (-partition-all-in-steps 2 1 '(1 2 3 4)) 1501 ⇒ ((1 2) (2 3) (3 4) (4)) 1502 (-partition-all-in-steps 3 2 '(1 2 3 4)) 1503 ⇒ ((1 2 3) (3 4)) 1504 (-partition-all-in-steps 3 2 '(1 2 3 4 5)) 1505 ⇒ ((1 2 3) (3 4 5) (5)) 1506 1507 -- Function: -partition-by (fn list) 1508 Apply FN to each item in LIST, splitting it each time FN returns a 1509 new value. 1510 1511 (-partition-by 'even? ()) 1512 ⇒ () 1513 (-partition-by 'even? '(1 1 2 2 2 3 4 6 8)) 1514 ⇒ ((1 1) (2 2 2) (3) (4 6 8)) 1515 (--partition-by (< it 3) '(1 2 3 4 3 2 1)) 1516 ⇒ ((1 2) (3 4 3) (2 1)) 1517 1518 -- Function: -partition-by-header (fn list) 1519 Apply FN to the first item in LIST. That is the header value. 1520 Apply FN to each item in LIST, splitting it each time FN returns 1521 the header value, but only after seeing at least one other value 1522 (the body). 1523 1524 (--partition-by-header (= it 1) '(1 2 3 1 2 1 2 3 4)) 1525 ⇒ ((1 2 3) (1 2) (1 2 3 4)) 1526 (--partition-by-header (> it 0) '(1 2 0 1 0 1 2 3 0)) 1527 ⇒ ((1 2 0) (1 0) (1 2 3 0)) 1528 (-partition-by-header 'even? '(2 1 1 1 4 1 3 5 6 6 1)) 1529 ⇒ ((2 1 1 1) (4 1 3 5) (6 6 1)) 1530 1531 -- Function: -partition-after-pred (pred list) 1532 Partition LIST after each element for which PRED returns non-‘nil’. 1533 1534 This function’s anaphoric counterpart is ‘--partition-after-pred’. 1535 1536 (-partition-after-pred #'booleanp ()) 1537 ⇒ () 1538 (-partition-after-pred #'booleanp '(t t)) 1539 ⇒ ((t) (t)) 1540 (-partition-after-pred #'booleanp '(0 0 t t 0 t)) 1541 ⇒ ((0 0 t) (t) (0 t)) 1542 1543 -- Function: -partition-before-pred (pred list) 1544 Partition directly before each time PRED is true on an element of 1545 LIST. 1546 1547 (-partition-before-pred #'booleanp ()) 1548 ⇒ () 1549 (-partition-before-pred #'booleanp '(0 t)) 1550 ⇒ ((0) (t)) 1551 (-partition-before-pred #'booleanp '(0 0 t 0 t t)) 1552 ⇒ ((0 0) (t 0) (t) (t)) 1553 1554 -- Function: -partition-before-item (item list) 1555 Partition directly before each time ITEM appears in LIST. 1556 1557 (-partition-before-item 3 ()) 1558 ⇒ () 1559 (-partition-before-item 3 '(1)) 1560 ⇒ ((1)) 1561 (-partition-before-item 3 '(3)) 1562 ⇒ ((3)) 1563 1564 -- Function: -partition-after-item (item list) 1565 Partition directly after each time ITEM appears in LIST. 1566 1567 (-partition-after-item 3 ()) 1568 ⇒ () 1569 (-partition-after-item 3 '(1)) 1570 ⇒ ((1)) 1571 (-partition-after-item 3 '(3)) 1572 ⇒ ((3)) 1573 1574 -- Function: -group-by (fn list) 1575 Separate LIST into an alist whose keys are FN applied to the 1576 elements of LIST. Keys are compared by ‘equal’. 1577 1578 (-group-by 'even? ()) 1579 ⇒ () 1580 (-group-by 'even? '(1 1 2 2 2 3 4 6 8)) 1581 ⇒ ((nil 1 1 3) (t 2 2 2 4 6 8)) 1582 (--group-by (car (split-string it "/")) '("a/b" "c/d" "a/e")) 1583 ⇒ (("a" "a/b" "a/e") ("c" "c/d")) 1584 1585 1586 File: dash.info, Node: Indexing, Next: Set operations, Prev: Partitioning, Up: Functions 1587 1588 2.8 Indexing 1589 ============ 1590 1591 Functions retrieving or sorting based on list indices and related 1592 predicates. 1593 1594 -- Function: -elem-index (elem list) 1595 Return the first index of ELEM in LIST. That is, the index within 1596 LIST of the first element that is ‘equal’ to ELEM. Return ‘nil’ if 1597 there is no such element. 1598 1599 See also: ‘-find-index’ (*note -find-index::). 1600 1601 (-elem-index 2 '(6 7 8 3 4)) 1602 ⇒ nil 1603 (-elem-index "bar" '("foo" "bar" "baz")) 1604 ⇒ 1 1605 (-elem-index '(1 2) '((3) (5 6) (1 2) nil)) 1606 ⇒ 2 1607 1608 -- Function: -elem-indices (elem list) 1609 Return the list of indices at which ELEM appears in LIST. That is, 1610 the indices of all elements of LIST ‘equal’ to ELEM, in the same 1611 ascending order as they appear in LIST. 1612 1613 (-elem-indices 2 '(6 7 8 3 4 1)) 1614 ⇒ () 1615 (-elem-indices "bar" '("foo" "bar" "baz")) 1616 ⇒ (1) 1617 (-elem-indices '(1 2) '((3) (1 2) (5 6) (1 2) nil)) 1618 ⇒ (1 3) 1619 1620 -- Function: -find-index (pred list) 1621 Return the index of the first item satisfying PRED in LIST. Return 1622 ‘nil’ if no such item is found. 1623 1624 PRED is called with one argument, the current list element, until 1625 it returns non-‘nil’, at which point the search terminates. 1626 1627 This function’s anaphoric counterpart is ‘--find-index’. 1628 1629 See also: ‘-first’ (*note -first::), ‘-find-last-index’ (*note 1630 -find-last-index::). 1631 1632 (-find-index #'numberp '(a b c)) 1633 ⇒ nil 1634 (-find-index #'natnump '(1 0 -1)) 1635 ⇒ 0 1636 (--find-index (> it 5) '(2 4 1 6 3 3 5 8)) 1637 ⇒ 3 1638 1639 -- Function: -find-last-index (pred list) 1640 Return the index of the last item satisfying PRED in LIST. Return 1641 ‘nil’ if no such item is found. 1642 1643 Predicate PRED is called with one argument each time, namely the 1644 current list element. 1645 1646 This function’s anaphoric counterpart is ‘--find-last-index’. 1647 1648 See also: ‘-last’ (*note -last::), ‘-find-index’ (*note 1649 -find-index::). 1650 1651 (-find-last-index #'numberp '(a b c)) 1652 ⇒ nil 1653 (--find-last-index (> it 5) '(2 7 1 6 3 8 5 2)) 1654 ⇒ 5 1655 (-find-last-index (-partial #'string< 'a) '(c b a)) 1656 ⇒ 1 1657 1658 -- Function: -find-indices (pred list) 1659 Return the list of indices in LIST satisfying PRED. 1660 1661 Each element of LIST in turn is passed to PRED. If the result is 1662 non-‘nil’, the index of that element in LIST is included in the 1663 result. The returned indices are in ascending order, i.e., in the 1664 same order as they appear in LIST. 1665 1666 This function’s anaphoric counterpart is ‘--find-indices’. 1667 1668 See also: ‘-find-index’ (*note -find-index::), ‘-elem-indices’ 1669 (*note -elem-indices::). 1670 1671 (-find-indices #'numberp '(a b c)) 1672 ⇒ () 1673 (-find-indices #'numberp '(8 1 d 2 b c a 3)) 1674 ⇒ (0 1 3 7) 1675 (--find-indices (> it 5) '(2 4 1 6 3 3 5 8)) 1676 ⇒ (3 7) 1677 1678 -- Function: -grade-up (comparator list) 1679 Grade elements of LIST using COMPARATOR relation. This yields a 1680 permutation vector such that applying this permutation to LIST 1681 sorts it in ascending order. 1682 1683 (-grade-up #'< '(3 1 4 2 1 3 3)) 1684 ⇒ (1 4 3 0 5 6 2) 1685 (let ((l '(3 1 4 2 1 3 3))) (-select-by-indices (-grade-up #'< l) l)) 1686 ⇒ (1 1 2 3 3 3 4) 1687 1688 -- Function: -grade-down (comparator list) 1689 Grade elements of LIST using COMPARATOR relation. This yields a 1690 permutation vector such that applying this permutation to LIST 1691 sorts it in descending order. 1692 1693 (-grade-down #'< '(3 1 4 2 1 3 3)) 1694 ⇒ (2 0 5 6 3 1 4) 1695 (let ((l '(3 1 4 2 1 3 3))) (-select-by-indices (-grade-down #'< l) l)) 1696 ⇒ (4 3 3 3 2 1 1) 1697 1698 1699 File: dash.info, Node: Set operations, Next: Other list operations, Prev: Indexing, Up: Functions 1700 1701 2.9 Set operations 1702 ================== 1703 1704 Operations pretending lists are sets. 1705 1706 -- Function: -union (list1 list2) 1707 Return a new list of distinct elements appearing in either LIST1 or 1708 LIST2. 1709 1710 The test for equality is done with ‘equal’, or with ‘-compare-fn’ 1711 if that is non-‘nil’. 1712 1713 (-union '(1 2 3) '(3 4 5)) 1714 ⇒ (1 2 3 4 5) 1715 (-union '(1 2 2 4) ()) 1716 ⇒ (1 2 4) 1717 (-union '(1 1 2 2) '(4 4 3 2 1)) 1718 ⇒ (1 2 4 3) 1719 1720 -- Function: -difference (list1 list2) 1721 Return a new list with the distinct members of LIST1 that are not 1722 in LIST2. 1723 1724 The test for equality is done with ‘equal’, or with ‘-compare-fn’ 1725 if that is non-‘nil’. 1726 1727 (-difference () ()) 1728 ⇒ () 1729 (-difference '(1 2 3) '(4 5 6)) 1730 ⇒ (1 2 3) 1731 (-difference '(1 2 3 4) '(3 4 5 6)) 1732 ⇒ (1 2) 1733 1734 -- Function: -intersection (list1 list2) 1735 Return a new list of distinct elements appearing in both LIST1 and 1736 LIST2. 1737 1738 The test for equality is done with ‘equal’, or with ‘-compare-fn’ 1739 if that is non-‘nil’. 1740 1741 (-intersection () ()) 1742 ⇒ () 1743 (-intersection '(1 2 3) '(4 5 6)) 1744 ⇒ () 1745 (-intersection '(1 2 2 3) '(4 3 3 2)) 1746 ⇒ (2 3) 1747 1748 -- Function: -powerset (list) 1749 Return the power set of LIST. 1750 1751 (-powerset ()) 1752 ⇒ (nil) 1753 (-powerset '(x y)) 1754 ⇒ ((x y) (x) (y) nil) 1755 (-powerset '(x y z)) 1756 ⇒ ((x y z) (x y) (x z) (x) (y z) (y) (z) nil) 1757 1758 -- Function: -permutations (list) 1759 Return the distinct permutations of LIST. 1760 1761 Duplicate elements of LIST are determined by ‘equal’, or by 1762 ‘-compare-fn’ if that is non-‘nil’. 1763 1764 (-permutations ()) 1765 ⇒ (nil) 1766 (-permutations '(a a b)) 1767 ⇒ ((a a b) (a b a) (b a a)) 1768 (-permutations '(a b c)) 1769 ⇒ ((a b c) (a c b) (b a c) (b c a) (c a b) (c b a)) 1770 1771 -- Function: -distinct (list) 1772 Return a copy of LIST with all duplicate elements removed. 1773 1774 The test for equality is done with ‘equal’, or with ‘-compare-fn’ 1775 if that is non-‘nil’. 1776 1777 Alias: ‘-uniq’. 1778 1779 (-distinct ()) 1780 ⇒ () 1781 (-distinct '(1 1 2 3 3)) 1782 ⇒ (1 2 3) 1783 (-distinct '(t t t)) 1784 ⇒ (t) 1785 1786 -- Function: -same-items? (list1 list2) 1787 Return non-‘nil’ if LIST1 and LIST2 have the same distinct 1788 elements. 1789 1790 The order of the elements in the lists does not matter. The lists 1791 may be of different lengths, i.e., contain duplicate elements. The 1792 test for equality is done with ‘equal’, or with ‘-compare-fn’ if 1793 that is non-‘nil’. 1794 1795 Alias: ‘-same-items-p’. 1796 1797 (-same-items? '(1 2 3) '(1 2 3)) 1798 ⇒ t 1799 (-same-items? '(1 1 2 3) '(3 3 2 1)) 1800 ⇒ t 1801 (-same-items? '(1 2 3) '(1 2 3 4)) 1802 ⇒ nil 1803 1804 1805 File: dash.info, Node: Other list operations, Next: Tree operations, Prev: Set operations, Up: Functions 1806 1807 2.10 Other list operations 1808 ========================== 1809 1810 Other list functions not fit to be classified elsewhere. 1811 1812 -- Function: -rotate (n list) 1813 Rotate LIST N places to the right (left if N is negative). The 1814 time complexity is O(n). 1815 1816 (-rotate 3 '(1 2 3 4 5 6 7)) 1817 ⇒ (5 6 7 1 2 3 4) 1818 (-rotate -3 '(1 2 3 4 5 6 7)) 1819 ⇒ (4 5 6 7 1 2 3) 1820 (-rotate 16 '(1 2 3 4 5 6 7)) 1821 ⇒ (6 7 1 2 3 4 5) 1822 1823 -- Function: -cons* (&rest args) 1824 Make a new list from the elements of ARGS. The last 2 elements of 1825 ARGS are used as the final cons of the result, so if the final 1826 element of ARGS is not a list, the result is a dotted list. With 1827 no ARGS, return ‘nil’. 1828 1829 (-cons* 1 2) 1830 ⇒ (1 . 2) 1831 (-cons* 1 2 3) 1832 ⇒ (1 2 . 3) 1833 (-cons* 1) 1834 ⇒ 1 1835 1836 -- Function: -snoc (list elem &rest elements) 1837 Append ELEM to the end of the list. 1838 1839 This is like ‘cons’, but operates on the end of list. 1840 1841 If any ELEMENTS are given, append them to the list as well. 1842 1843 (-snoc '(1 2 3) 4) 1844 ⇒ (1 2 3 4) 1845 (-snoc '(1 2 3) 4 5 6) 1846 ⇒ (1 2 3 4 5 6) 1847 (-snoc '(1 2 3) '(4 5 6)) 1848 ⇒ (1 2 3 (4 5 6)) 1849 1850 -- Function: -interpose (sep list) 1851 Return a new list of all elements in LIST separated by SEP. 1852 1853 (-interpose "-" ()) 1854 ⇒ () 1855 (-interpose "-" '("a")) 1856 ⇒ ("a") 1857 (-interpose "-" '("a" "b" "c")) 1858 ⇒ ("a" "-" "b" "-" "c") 1859 1860 -- Function: -interleave (&rest lists) 1861 Return a new list of the first item in each list, then the second 1862 etc. 1863 1864 (-interleave '(1 2) '("a" "b")) 1865 ⇒ (1 "a" 2 "b") 1866 (-interleave '(1 2) '("a" "b") '("A" "B")) 1867 ⇒ (1 "a" "A" 2 "b" "B") 1868 (-interleave '(1 2 3) '("a" "b")) 1869 ⇒ (1 "a" 2 "b") 1870 1871 -- Function: -iota (count &optional start step) 1872 Return a list containing COUNT numbers. Starts from START and adds 1873 STEP each time. The default START is zero, the default STEP is 1. 1874 This function takes its name from the corresponding primitive in 1875 the APL language. 1876 1877 (-iota 6) 1878 ⇒ (0 1 2 3 4 5) 1879 (-iota 4 2.5 -2) 1880 ⇒ (2.5 0.5 -1.5 -3.5) 1881 (-iota -1) 1882 error→ Wrong type argument: natnump, -1 1883 1884 -- Function: -zip-with (fn list1 list2) 1885 Zip LIST1 and LIST2 into a new list using the function FN. That 1886 is, apply FN pairwise taking as first argument the next element of 1887 LIST1 and as second argument the next element of LIST2 at the 1888 corresponding position. The result is as long as the shorter list. 1889 1890 This function’s anaphoric counterpart is ‘--zip-with’. 1891 1892 For other zips, see also ‘-zip-lists’ (*note -zip-lists::) and 1893 ‘-zip-fill’ (*note -zip-fill::). 1894 1895 (-zip-with #'+ '(1 2 3 4) '(5 6 7)) 1896 ⇒ (6 8 10) 1897 (-zip-with #'cons '(1 2 3) '(4 5 6 7)) 1898 ⇒ ((1 . 4) (2 . 5) (3 . 6)) 1899 (--zip-with (format "%s & %s" it other) '(Batman Jekyll) '(Robin Hyde)) 1900 ⇒ ("Batman & Robin" "Jekyll & Hyde") 1901 1902 -- Function: -zip-pair (list1 list2) 1903 Zip LIST1 and LIST2 together. 1904 1905 Make a pair with the head of each list, followed by a pair with the 1906 second element of each list, and so on. The number of pairs 1907 returned is equal to the length of the shorter input list. 1908 1909 See also: ‘-zip-lists’ (*note -zip-lists::). 1910 1911 (-zip-pair '(1 2 3 4) '(5 6 7)) 1912 ⇒ ((1 . 5) (2 . 6) (3 . 7)) 1913 (-zip-pair '(1 2 3) '(4 5 6)) 1914 ⇒ ((1 . 4) (2 . 5) (3 . 6)) 1915 (-zip-pair '(1 2) '(3)) 1916 ⇒ ((1 . 3)) 1917 1918 -- Function: -zip-lists (&rest lists) 1919 Zip LISTS together. 1920 1921 Group the head of each list, followed by the second element of each 1922 list, and so on. The number of returned groupings is equal to the 1923 length of the shortest input list, and the length of each grouping 1924 is equal to the number of input LISTS. 1925 1926 The return value is always a list of proper lists, in contrast to 1927 ‘-zip’ (*note -zip::) which returns a list of dotted pairs when 1928 only two input LISTS are provided. 1929 1930 See also: ‘-zip-pair’ (*note -zip-pair::). 1931 1932 (-zip-lists '(1 2 3) '(4 5 6)) 1933 ⇒ ((1 4) (2 5) (3 6)) 1934 (-zip-lists '(1 2 3) '(4 5 6 7)) 1935 ⇒ ((1 4) (2 5) (3 6)) 1936 (-zip-lists '(1 2) '(3 4 5) '(6)) 1937 ⇒ ((1 3 6)) 1938 1939 -- Function: -zip-lists-fill (fill-value &rest lists) 1940 Zip LISTS together, padding shorter lists with FILL-VALUE. This is 1941 like ‘-zip-lists’ (*note -zip-lists::) (which see), except it 1942 retains all elements at positions beyond the end of the shortest 1943 list. The number of returned groupings is equal to the length of 1944 the longest input list, and the length of each grouping is equal to 1945 the number of input LISTS. 1946 1947 (-zip-lists-fill 0 '(1 2) '(3 4 5) '(6)) 1948 ⇒ ((1 3 6) (2 4 0) (0 5 0)) 1949 (-zip-lists-fill 0 '(1 2) '(3 4) '(5 6)) 1950 ⇒ ((1 3 5) (2 4 6)) 1951 (-zip-lists-fill 0 '(1 2 3) nil) 1952 ⇒ ((1 0) (2 0) (3 0)) 1953 1954 -- Function: -zip (&rest lists) 1955 Zip LISTS together. 1956 1957 Group the head of each list, followed by the second element of each 1958 list, and so on. The number of returned groupings is equal to the 1959 length of the shortest input list, and the number of items in each 1960 grouping is equal to the number of input LISTS. 1961 1962 If only two LISTS are provided as arguments, return the groupings 1963 as a list of dotted pairs. Otherwise, return the groupings as a 1964 list of proper lists. 1965 1966 Since the return value changes form depending on the number of 1967 arguments, it is generally recommended to use ‘-zip-lists’ (*note 1968 -zip-lists::) instead, or ‘-zip-pair’ (*note -zip-pair::) if a list 1969 of dotted pairs is desired. 1970 1971 See also: ‘-unzip’ (*note -unzip::). 1972 1973 (-zip '(1 2 3 4) '(5 6 7) '(8 9)) 1974 ⇒ ((1 5 8) (2 6 9)) 1975 (-zip '(1 2 3) '(4 5 6) '(7 8 9)) 1976 ⇒ ((1 4 7) (2 5 8) (3 6 9)) 1977 (-zip '(1 2 3)) 1978 ⇒ ((1) (2) (3)) 1979 1980 -- Function: -zip-fill (fill-value &rest lists) 1981 Zip LISTS together, padding shorter lists with FILL-VALUE. This is 1982 like ‘-zip’ (*note -zip::) (which see), except it retains all 1983 elements at positions beyond the end of the shortest list. The 1984 number of returned groupings is equal to the length of the longest 1985 input list, and the length of each grouping is equal to the number 1986 of input LISTS. 1987 1988 Since the return value changes form depending on the number of 1989 arguments, it is generally recommended to use ‘-zip-lists-fill’ 1990 (*note -zip-lists-fill::) instead, unless a list of dotted pairs is 1991 explicitly desired. 1992 1993 (-zip-fill 0 '(1 2 3) '(4 5)) 1994 ⇒ ((1 . 4) (2 . 5) (3 . 0)) 1995 (-zip-fill 0 () '(1 2 3)) 1996 ⇒ ((0 . 1) (0 . 2) (0 . 3)) 1997 (-zip-fill 0 '(1 2) '(3 4) '(5 6)) 1998 ⇒ ((1 3 5) (2 4 6)) 1999 2000 -- Function: -unzip-lists (lists) 2001 Unzip LISTS. 2002 2003 This works just like ‘-zip-lists’ (*note -zip-lists::) (which see), 2004 but takes a list of lists instead of a variable number of 2005 arguments, such that 2006 2007 (-unzip-lists (-zip-lists ARGS...)) 2008 2009 is identity (given that the lists comprising ARGS are of the same 2010 length). 2011 2012 (-unzip-lists (-zip-lists '(1 2) '(3 4) '(5 6))) 2013 ⇒ ((1 2) (3 4) (5 6)) 2014 (-unzip-lists '((1 2 3) (4 5) (6 7) (8 9))) 2015 ⇒ ((1 4 6 8) (2 5 7 9)) 2016 (-unzip-lists '((1 2 3) (4 5 6))) 2017 ⇒ ((1 4) (2 5) (3 6)) 2018 2019 -- Function: -unzip (lists) 2020 Unzip LISTS. 2021 2022 This works just like ‘-zip’ (*note -zip::) (which see), but takes a 2023 list of lists instead of a variable number of arguments, such that 2024 2025 (-unzip (-zip L1 L2 L3 ...)) 2026 2027 is identity (given that the lists are of the same length, and that 2028 ‘-zip’ (*note -zip::) is not called with two arguments, because of 2029 the caveat described in its docstring). 2030 2031 Note in particular that calling ‘-unzip’ (*note -unzip::) on a list 2032 of two lists will return a list of dotted pairs. 2033 2034 Since the return value changes form depending on the number of 2035 LISTS, it is generally recommended to use ‘-unzip-lists’ (*note 2036 -unzip-lists::) instead. 2037 2038 (-unzip (-zip '(1 2) '(3 4) '(5 6))) 2039 ⇒ ((1 . 2) (3 . 4) (5 . 6)) 2040 (-unzip '((1 2 3) (4 5 6))) 2041 ⇒ ((1 . 4) (2 . 5) (3 . 6)) 2042 (-unzip '((1 2 3) (4 5) (6 7) (8 9))) 2043 ⇒ ((1 4 6 8) (2 5 7 9)) 2044 2045 -- Function: -pad (fill-value &rest lists) 2046 Pad each of LISTS with FILL-VALUE until they all have equal 2047 lengths. 2048 2049 Ensure all LISTS are as long as the longest one by repeatedly 2050 appending FILL-VALUE to the shorter lists, and return the resulting 2051 LISTS. 2052 2053 (-pad 0 ()) 2054 ⇒ (nil) 2055 (-pad 0 '(1 2) '(3 4)) 2056 ⇒ ((1 2) (3 4)) 2057 (-pad 0 '(1 2) '(3 4 5 6) '(7 8 9)) 2058 ⇒ ((1 2 0 0) (3 4 5 6) (7 8 9 0)) 2059 2060 -- Function: -table (fn &rest lists) 2061 Compute outer product of LISTS using function FN. 2062 2063 The function FN should have the same arity as the number of 2064 supplied lists. 2065 2066 The outer product is computed by applying fn to all possible 2067 combinations created by taking one element from each list in order. 2068 The dimension of the result is (length lists). 2069 2070 See also: ‘-table-flat’ (*note -table-flat::) 2071 2072 (-table '* '(1 2 3) '(1 2 3)) 2073 ⇒ ((1 2 3) (2 4 6) (3 6 9)) 2074 (-table (lambda (a b) (-sum (-zip-with '* a b))) '((1 2) (3 4)) '((1 3) (2 4))) 2075 ⇒ ((7 15) (10 22)) 2076 (apply '-table 'list (-repeat 3 '(1 2))) 2077 ⇒ ((((1 1 1) (2 1 1)) ((1 2 1) (2 2 1))) (((1 1 2) (2 1 2)) ((1 2 2) (2 2 2)))) 2078 2079 -- Function: -table-flat (fn &rest lists) 2080 Compute flat outer product of LISTS using function FN. 2081 2082 The function FN should have the same arity as the number of 2083 supplied lists. 2084 2085 The outer product is computed by applying fn to all possible 2086 combinations created by taking one element from each list in order. 2087 The results are flattened, ignoring the tensor structure of the 2088 result. This is equivalent to calling: 2089 2090 (-flatten-n (1- (length lists)) (apply ’-table fn lists)) 2091 2092 but the implementation here is much more efficient. 2093 2094 See also: ‘-flatten-n’ (*note -flatten-n::), ‘-table’ (*note 2095 -table::) 2096 2097 (-table-flat 'list '(1 2 3) '(a b c)) 2098 ⇒ ((1 a) (2 a) (3 a) (1 b) (2 b) (3 b) (1 c) (2 c) (3 c)) 2099 (-table-flat '* '(1 2 3) '(1 2 3)) 2100 ⇒ (1 2 3 2 4 6 3 6 9) 2101 (apply '-table-flat 'list (-repeat 3 '(1 2))) 2102 ⇒ ((1 1 1) (2 1 1) (1 2 1) (2 2 1) (1 1 2) (2 1 2) (1 2 2) (2 2 2)) 2103 2104 -- Function: -first (pred list) 2105 Return the first item in LIST for which PRED returns non-‘nil’. 2106 Return ‘nil’ if no such element is found. 2107 2108 To get the first item in the list no questions asked, use 2109 ‘-first-item’ (*note -first-item::). 2110 2111 Alias: ‘-find’. 2112 2113 This function’s anaphoric counterpart is ‘--first’. 2114 2115 (-first #'natnump '(-1 0 1)) 2116 ⇒ 0 2117 (-first #'null '(1 2 3)) 2118 ⇒ nil 2119 (--first (> it 2) '(1 2 3)) 2120 ⇒ 3 2121 2122 -- Function: -last (pred list) 2123 Return the last x in LIST where (PRED x) is non-‘nil’, else ‘nil’. 2124 2125 (-last 'even? '(1 2 3 4 5 6 3 3 3)) 2126 ⇒ 6 2127 (-last 'even? '(1 3 7 5 9)) 2128 ⇒ nil 2129 (--last (> (length it) 3) '("a" "looong" "word" "and" "short" "one")) 2130 ⇒ "short" 2131 2132 -- Function: -first-item (list) 2133 Return the first item of LIST, or ‘nil’ on an empty list. 2134 2135 See also: ‘-second-item’ (*note -second-item::), ‘-last-item’ 2136 (*note -last-item::), etc. 2137 2138 (-first-item ()) 2139 ⇒ () 2140 (-first-item '(1 2 3 4 5)) 2141 ⇒ 1 2142 (let ((list (list 1 2 3))) (setf (-first-item list) 5) list) 2143 ⇒ (5 2 3) 2144 2145 -- Function: -second-item (list) 2146 Return the second item of LIST, or ‘nil’ if LIST is too short. 2147 2148 See also: ‘-first-item’ (*note -first-item::), ‘-third-item’ (*note 2149 -third-item::), etc. 2150 2151 (-second-item ()) 2152 ⇒ () 2153 (-second-item '(1 2 3 4 5)) 2154 ⇒ 2 2155 (let ((list (list 1 2))) (setf (-second-item list) 5) list) 2156 ⇒ (1 5) 2157 2158 -- Function: -third-item (list) 2159 Return the third item of LIST, or ‘nil’ if LIST is too short. 2160 2161 See also: ‘-second-item’ (*note -second-item::), ‘-fourth-item’ 2162 (*note -fourth-item::), etc. 2163 2164 (-third-item ()) 2165 ⇒ () 2166 (-third-item '(1 2)) 2167 ⇒ () 2168 (-third-item '(1 2 3 4 5)) 2169 ⇒ 3 2170 2171 -- Function: -fourth-item (list) 2172 Return the fourth item of LIST, or ‘nil’ if LIST is too short. 2173 2174 See also: ‘-third-item’ (*note -third-item::), ‘-fifth-item’ (*note 2175 -fifth-item::), etc. 2176 2177 (-fourth-item ()) 2178 ⇒ () 2179 (-fourth-item '(1 2 3)) 2180 ⇒ () 2181 (-fourth-item '(1 2 3 4 5)) 2182 ⇒ 4 2183 2184 -- Function: -fifth-item (list) 2185 Return the fifth item of LIST, or ‘nil’ if LIST is too short. 2186 2187 See also: ‘-fourth-item’ (*note -fourth-item::), ‘-last-item’ 2188 (*note -last-item::), etc. 2189 2190 (-fifth-item ()) 2191 ⇒ () 2192 (-fifth-item '(1 2 3 4)) 2193 ⇒ () 2194 (-fifth-item '(1 2 3 4 5)) 2195 ⇒ 5 2196 2197 -- Function: -last-item (list) 2198 Return the last item of LIST, or ‘nil’ on an empty list. 2199 2200 See also: ‘-first-item’ (*note -first-item::), etc. 2201 2202 (-last-item ()) 2203 ⇒ () 2204 (-last-item '(1 2 3 4 5)) 2205 ⇒ 5 2206 (let ((list (list 1 2 3))) (setf (-last-item list) 5) list) 2207 ⇒ (1 2 5) 2208 2209 -- Function: -butlast (list) 2210 Return a list of all items in list except for the last. 2211 2212 (-butlast '(1 2 3)) 2213 ⇒ (1 2) 2214 (-butlast '(1 2)) 2215 ⇒ (1) 2216 (-butlast '(1)) 2217 ⇒ nil 2218 2219 -- Function: -sort (comparator list) 2220 Sort LIST, stably, comparing elements using COMPARATOR. Return the 2221 sorted list. LIST is NOT modified by side effects. COMPARATOR is 2222 called with two elements of LIST, and should return non-‘nil’ if 2223 the first element should sort before the second. 2224 2225 (-sort #'< '(3 1 2)) 2226 ⇒ (1 2 3) 2227 (-sort #'> '(3 1 2)) 2228 ⇒ (3 2 1) 2229 (--sort (< it other) '(3 1 2)) 2230 ⇒ (1 2 3) 2231 2232 -- Function: -list (arg) 2233 Ensure ARG is a list. If ARG is already a list, return it as is 2234 (not a copy). Otherwise, return a new list with ARG as its only 2235 element. 2236 2237 Another supported calling convention is (-list &rest ARGS). In 2238 this case, if ARG is not a list, a new list with all of ARGS as 2239 elements is returned. This use is supported for backward 2240 compatibility and is otherwise deprecated. 2241 2242 (-list 1) 2243 ⇒ (1) 2244 (-list ()) 2245 ⇒ () 2246 (-list '(1 2 3)) 2247 ⇒ (1 2 3) 2248 2249 -- Function: -fix (fn list) 2250 Compute the (least) fixpoint of FN with initial input LIST. 2251 2252 FN is called at least once, results are compared with ‘equal’. 2253 2254 (-fix (lambda (l) (-non-nil (--mapcat (-split-at (/ (length it) 2) it) l))) '((1 2 3))) 2255 ⇒ ((1) (2) (3)) 2256 (let ((l '((starwars scifi) (jedi starwars warrior)))) (--fix (-uniq (--mapcat (cons it (cdr (assq it l))) it)) '(jedi book))) 2257 ⇒ (jedi starwars warrior scifi book) 2258 2259 2260 File: dash.info, Node: Tree operations, Next: Threading macros, Prev: Other list operations, Up: Functions 2261 2262 2.11 Tree operations 2263 ==================== 2264 2265 Functions pretending lists are trees. 2266 2267 -- Function: -tree-seq (branch children tree) 2268 Return a sequence of the nodes in TREE, in depth-first search 2269 order. 2270 2271 BRANCH is a predicate of one argument that returns non-‘nil’ if the 2272 passed argument is a branch, that is, a node that can have 2273 children. 2274 2275 CHILDREN is a function of one argument that returns the children of 2276 the passed branch node. 2277 2278 Non-branch nodes are simply copied. 2279 2280 (-tree-seq 'listp 'identity '(1 (2 3) 4 (5 (6 7)))) 2281 ⇒ ((1 (2 3) 4 (5 (6 7))) 1 (2 3) 2 3 4 (5 (6 7)) 5 (6 7) 6 7) 2282 (-tree-seq 'listp 'reverse '(1 (2 3) 4 (5 (6 7)))) 2283 ⇒ ((1 (2 3) 4 (5 (6 7))) (5 (6 7)) (6 7) 7 6 5 4 (2 3) 3 2 1) 2284 (--tree-seq (vectorp it) (append it nil) [1 [2 3] 4 [5 [6 7]]]) 2285 ⇒ ([1 [2 3] 4 [5 [6 7]]] 1 [2 3] 2 3 4 [5 [6 7]] 5 [6 7] 6 7) 2286 2287 -- Function: -tree-map (fn tree) 2288 Apply FN to each element of TREE while preserving the tree 2289 structure. 2290 2291 (-tree-map '1+ '(1 (2 3) (4 (5 6) 7))) 2292 ⇒ (2 (3 4) (5 (6 7) 8)) 2293 (-tree-map '(lambda (x) (cons x (expt 2 x))) '(1 (2 3) 4)) 2294 ⇒ ((1 . 2) ((2 . 4) (3 . 8)) (4 . 16)) 2295 (--tree-map (length it) '("<body>" ("<p>" "text" "</p>") "</body>")) 2296 ⇒ (6 (3 4 4) 7) 2297 2298 -- Function: -tree-map-nodes (pred fun tree) 2299 Call FUN on each node of TREE that satisfies PRED. 2300 2301 If PRED returns ‘nil’, continue descending down this node. If PRED 2302 returns non-‘nil’, apply FUN to this node and do not descend 2303 further. 2304 2305 (-tree-map-nodes 'vectorp (lambda (x) (-sum (append x nil))) '(1 [2 3] 4 (5 [6 7] 8))) 2306 ⇒ (1 5 4 (5 13 8)) 2307 (-tree-map-nodes 'keywordp (lambda (x) (symbol-name x)) '(1 :foo 4 ((5 6 :bar) :baz 8))) 2308 ⇒ (1 ":foo" 4 ((5 6 ":bar") ":baz" 8)) 2309 (--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)))) 2310 ⇒ (with-mode emacs-lisp-mode (foo bar) (add-mode a b :mode emacs-lisp-mode) (baz (add-mode c d :mode emacs-lisp-mode))) 2311 2312 -- Function: -tree-reduce (fn tree) 2313 Use FN to reduce elements of list TREE. If elements of TREE are 2314 lists themselves, apply the reduction recursively. 2315 2316 FN is first applied to first element of the list and second 2317 element, then on this result and third element from the list etc. 2318 2319 See ‘-reduce-r’ (*note -reduce-r::) for how exactly are lists of 2320 zero or one element handled. 2321 2322 (-tree-reduce '+ '(1 (2 3) (4 5))) 2323 ⇒ 15 2324 (-tree-reduce 'concat '("strings" (" on" " various") ((" levels")))) 2325 ⇒ "strings on various levels" 2326 (--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"))) 2327 ⇒ "<body><p>some words</p> <div>more <b>bold</b> words</div></body>" 2328 2329 -- Function: -tree-reduce-from (fn init-value tree) 2330 Use FN to reduce elements of list TREE. If elements of TREE are 2331 lists themselves, apply the reduction recursively. 2332 2333 FN is first applied to INIT-VALUE and first element of the list, 2334 then on this result and second element from the list etc. 2335 2336 The initial value is ignored on cons pairs as they always contain 2337 two elements. 2338 2339 (-tree-reduce-from '+ 1 '(1 (1 1) ((1)))) 2340 ⇒ 8 2341 (--tree-reduce-from (-concat acc (list it)) nil '(1 (2 3 (4 5)) (6 7))) 2342 ⇒ ((7 6) ((5 4) 3 2) 1) 2343 2344 -- Function: -tree-mapreduce (fn folder tree) 2345 Apply FN to each element of TREE, and make a list of the results. 2346 If elements of TREE are lists themselves, apply FN recursively to 2347 elements of these nested lists. 2348 2349 Then reduce the resulting lists using FOLDER and initial value 2350 INIT-VALUE. See ‘-reduce-r-from’ (*note -reduce-r-from::). 2351 2352 This is the same as calling ‘-tree-reduce’ (*note -tree-reduce::) 2353 after ‘-tree-map’ (*note -tree-map::) but is twice as fast as it 2354 only traverse the structure once. 2355 2356 (-tree-mapreduce 'list 'append '(1 (2 (3 4) (5 6)) (7 (8 9)))) 2357 ⇒ (1 2 3 4 5 6 7 8 9) 2358 (--tree-mapreduce 1 (+ it acc) '(1 (2 (4 9) (2 1)) (7 (4 3)))) 2359 ⇒ 9 2360 (--tree-mapreduce 0 (max acc (1+ it)) '(1 (2 (4 9) (2 1)) (7 (4 3)))) 2361 ⇒ 3 2362 2363 -- Function: -tree-mapreduce-from (fn folder init-value tree) 2364 Apply FN to each element of TREE, and make a list of the results. 2365 If elements of TREE are lists themselves, apply FN recursively to 2366 elements of these nested lists. 2367 2368 Then reduce the resulting lists using FOLDER and initial value 2369 INIT-VALUE. See ‘-reduce-r-from’ (*note -reduce-r-from::). 2370 2371 This is the same as calling ‘-tree-reduce-from’ (*note 2372 -tree-reduce-from::) after ‘-tree-map’ (*note -tree-map::) but is 2373 twice as fast as it only traverse the structure once. 2374 2375 (-tree-mapreduce-from 'identity '* 1 '(1 (2 (3 4) (5 6)) (7 (8 9)))) 2376 ⇒ 362880 2377 (--tree-mapreduce-from (+ it it) (cons it acc) nil '(1 (2 (4 9) (2 1)) (7 (4 3)))) 2378 ⇒ (2 (4 (8 18) (4 2)) (14 (8 6))) 2379 (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))))) 2380 ⇒ "{elisp-mode : {foo : {bar -> booze}, baz -> qux}, c-mode : {foo -> bla, bum -> bam}}" 2381 2382 -- Function: -clone (list) 2383 Create a deep copy of LIST. The new list has the same elements and 2384 structure but all cons are replaced with new ones. This is useful 2385 when you need to clone a structure such as plist or alist. 2386 2387 (let* ((a (list (list 1))) (b (-clone a))) (setcar (car a) 2) b) 2388 ⇒ ((1)) 2389 2390 2391 File: dash.info, Node: Threading macros, Next: Binding, Prev: Tree operations, Up: Functions 2392 2393 2.12 Threading macros 2394 ===================== 2395 2396 Macros that conditionally combine sequential forms for brevity or 2397 readability. 2398 2399 -- Macro: -> (x &optional form &rest more) 2400 Thread the expr through the forms. Insert X as the second item in 2401 the first form, making a list of it if it is not a list already. 2402 If there are more forms, insert the first form as the second item 2403 in second form, etc. 2404 2405 (-> '(2 3 5)) 2406 ⇒ (2 3 5) 2407 (-> '(2 3 5) (append '(8 13))) 2408 ⇒ (2 3 5 8 13) 2409 (-> '(2 3 5) (append '(8 13)) (-slice 1 -1)) 2410 ⇒ (3 5 8) 2411 2412 -- Macro: ->> (x &optional form &rest more) 2413 Thread the expr through the forms. Insert X as the last item in 2414 the first form, making a list of it if it is not a list already. 2415 If there are more forms, insert the first form as the last item in 2416 second form, etc. 2417 2418 (->> '(1 2 3) (-map 'square)) 2419 ⇒ (1 4 9) 2420 (->> '(1 2 3) (-map 'square) (-remove 'even?)) 2421 ⇒ (1 9) 2422 (->> '(1 2 3) (-map 'square) (-reduce '+)) 2423 ⇒ 14 2424 2425 -- Macro: --> (x &rest forms) 2426 Starting with the value of X, thread each expression through FORMS. 2427 2428 Insert X at the position signified by the symbol ‘it’ in the first 2429 form. If there are more forms, insert the first form at the 2430 position signified by ‘it’ in the second form, etc. 2431 2432 (--> "def" (concat "abc" it "ghi")) 2433 ⇒ "abcdefghi" 2434 (--> "def" (concat "abc" it "ghi") (upcase it)) 2435 ⇒ "ABCDEFGHI" 2436 (--> "def" (concat "abc" it "ghi") upcase) 2437 ⇒ "ABCDEFGHI" 2438 2439 -- Macro: -as-> (value variable &rest forms) 2440 Starting with VALUE, thread VARIABLE through FORMS. 2441 2442 In the first form, bind VARIABLE to VALUE. In the second form, 2443 bind VARIABLE to the result of the first form, and so forth. 2444 2445 (-as-> 3 my-var (1+ my-var) (list my-var) (mapcar (lambda (ele) (* 2 ele)) my-var)) 2446 ⇒ (8) 2447 (-as-> 3 my-var 1+) 2448 ⇒ 4 2449 (-as-> 3 my-var) 2450 ⇒ 3 2451 2452 -- Macro: -some-> (x &optional form &rest more) 2453 When expr is non-‘nil’, thread it through the first form (via ‘->’ 2454 (*note ->::)), and when that result is non-‘nil’, through the next 2455 form, etc. 2456 2457 (-some-> '(2 3 5)) 2458 ⇒ (2 3 5) 2459 (-some-> 5 square) 2460 ⇒ 25 2461 (-some-> 5 even? square) 2462 ⇒ nil 2463 2464 -- Macro: -some->> (x &optional form &rest more) 2465 When expr is non-‘nil’, thread it through the first form (via ‘->>’ 2466 (*note ->>::)), and when that result is non-‘nil’, through the next 2467 form, etc. 2468 2469 (-some->> '(1 2 3) (-map 'square)) 2470 ⇒ (1 4 9) 2471 (-some->> '(1 3 5) (-last 'even?) (+ 100)) 2472 ⇒ nil 2473 (-some->> '(2 4 6) (-last 'even?) (+ 100)) 2474 ⇒ 106 2475 2476 -- Macro: -some--> (expr &rest forms) 2477 Thread EXPR through FORMS via ‘-->’ (*note -->::), while the result 2478 is non-‘nil’. When EXPR evaluates to non-‘nil’, thread the result 2479 through the first of FORMS, and when that result is non-‘nil’, 2480 thread it through the next form, etc. 2481 2482 (-some--> "def" (concat "abc" it "ghi")) 2483 ⇒ "abcdefghi" 2484 (-some--> nil (concat "abc" it "ghi")) 2485 ⇒ nil 2486 (-some--> '(0 1) (-remove #'natnump it) (append it it) (-map #'1+ it)) 2487 ⇒ () 2488 2489 -- Macro: -doto (init &rest forms) 2490 Evaluate INIT and pass it as argument to FORMS with ‘->’ (*note 2491 ->::). The RESULT of evaluating INIT is threaded through each of 2492 FORMS individually using ‘->’ (*note ->::), which see. The return 2493 value is RESULT, which FORMS may have modified by side effect. 2494 2495 (-doto (list 1 2 3) pop pop) 2496 ⇒ (3) 2497 (-doto (cons 1 2) (setcar 3) (setcdr 4)) 2498 ⇒ (3 . 4) 2499 (gethash 'k (--doto (make-hash-table) (puthash 'k 'v it))) 2500 ⇒ v 2501 2502 2503 File: dash.info, Node: Binding, Next: Side effects, Prev: Threading macros, Up: Functions 2504 2505 2.13 Binding 2506 ============ 2507 2508 Macros that combine ‘let’ and ‘let*’ with destructuring and flow 2509 control. 2510 2511 -- Macro: -when-let ((var val) &rest body) 2512 If VAL evaluates to non-‘nil’, bind it to VAR and execute body. 2513 2514 Note: binding is done according to ‘-let’ (*note -let::). 2515 2516 (-when-let (match-index (string-match "d" "abcd")) (+ match-index 2)) 2517 ⇒ 5 2518 (-when-let ((&plist :foo foo) (list :foo "foo")) foo) 2519 ⇒ "foo" 2520 (-when-let ((&plist :foo foo) (list :bar "bar")) foo) 2521 ⇒ nil 2522 2523 -- Macro: -when-let* (vars-vals &rest body) 2524 If all VALS evaluate to true, bind them to their corresponding VARS 2525 and execute body. VARS-VALS should be a list of (VAR VAL) pairs. 2526 2527 Note: binding is done according to ‘-let*’ (*note -let*::). VALS 2528 are evaluated sequentially, and evaluation stops after the first 2529 ‘nil’ VAL is encountered. 2530 2531 (-when-let* ((x 5) (y 3) (z (+ y 4))) (+ x y z)) 2532 ⇒ 15 2533 (-when-let* ((x 5) (y nil) (z 7)) (+ x y z)) 2534 ⇒ nil 2535 2536 -- Macro: -if-let ((var val) then &rest else) 2537 If VAL evaluates to non-‘nil’, bind it to VAR and do THEN, 2538 otherwise do ELSE. 2539 2540 Note: binding is done according to ‘-let’ (*note -let::). 2541 2542 (-if-let (match-index (string-match "d" "abc")) (+ match-index 3) 7) 2543 ⇒ 7 2544 (--if-let (even? 4) it nil) 2545 ⇒ t 2546 2547 -- Macro: -if-let* (vars-vals then &rest else) 2548 If all VALS evaluate to true, bind them to their corresponding VARS 2549 and do THEN, otherwise do ELSE. VARS-VALS should be a list of (VAR 2550 VAL) pairs. 2551 2552 Note: binding is done according to ‘-let*’ (*note -let*::). VALS 2553 are evaluated sequentially, and evaluation stops after the first 2554 ‘nil’ VAL is encountered. 2555 2556 (-if-let* ((x 5) (y 3) (z 7)) (+ x y z) "foo") 2557 ⇒ 15 2558 (-if-let* ((x 5) (y nil) (z 7)) (+ x y z) "foo") 2559 ⇒ "foo" 2560 (-if-let* (((_ _ x) '(nil nil 7))) x) 2561 ⇒ 7 2562 2563 -- Macro: -let (varlist &rest body) 2564 Bind variables according to VARLIST then eval BODY. 2565 2566 VARLIST is a list of lists of the form (PATTERN SOURCE). Each 2567 PATTERN is matched against the SOURCE "structurally". SOURCE is 2568 only evaluated once for each PATTERN. Each PATTERN is matched 2569 recursively, and can therefore contain sub-patterns which are 2570 matched against corresponding sub-expressions of SOURCE. 2571 2572 All the SOURCEs are evalled before any symbols are bound (i.e. "in 2573 parallel"). 2574 2575 If VARLIST only contains one (PATTERN SOURCE) element, you can 2576 optionally specify it using a vector and discarding the outer-most 2577 parens. Thus 2578 2579 (-let ((PATTERN SOURCE)) ...) 2580 2581 becomes 2582 2583 (-let [PATTERN SOURCE] ...). 2584 2585 ‘-let’ (*note -let::) uses a convention of not binding places 2586 (symbols) starting with _ whenever it’s possible. You can use this 2587 to skip over entries you don’t care about. However, this is not 2588 *always* possible (as a result of implementation) and these symbols 2589 might get bound to undefined values. 2590 2591 Following is the overview of supported patterns. Remember that 2592 patterns can be matched recursively, so every a, b, aK in the 2593 following can be a matching construct and not necessarily a 2594 symbol/variable. 2595 2596 Symbol: 2597 2598 a - bind the SOURCE to A. This is just like regular ‘let’. 2599 2600 Conses and lists: 2601 2602 (a) - bind ‘car’ of cons/list to A 2603 2604 (a . b) - bind car of cons to A and ‘cdr’ to B 2605 2606 (a b) - bind car of list to A and ‘cadr’ to B 2607 2608 (a1 a2 a3 ...) - bind 0th car of list to A1, 1st to A2, 2nd to 2609 A3... 2610 2611 (a1 a2 a3 ... aN . rest) - as above, but bind the Nth cdr to REST. 2612 2613 Vectors: 2614 2615 [a] - bind 0th element of a non-list sequence to A (works with 2616 vectors, strings, bit arrays...) 2617 2618 [a1 a2 a3 ...] - bind 0th element of non-list sequence to A0, 1st 2619 to A1, 2nd to A2, ... If the PATTERN is shorter than SOURCE, the 2620 values at places not in PATTERN are ignored. If the PATTERN is 2621 longer than SOURCE, an ‘error’ is thrown. 2622 2623 [a1 a2 a3 ... &rest rest] - as above, but bind the rest of the 2624 sequence to REST. This is conceptually the same as improper list 2625 matching (a1 a2 ... aN . rest) 2626 2627 Key/value stores: 2628 2629 (&plist key0 a0 ... keyN aN) - bind value mapped by keyK in the 2630 SOURCE plist to aK. If the value is not found, aK is ‘nil’. Uses 2631 ‘plist-get’ to fetch values. 2632 2633 (&alist key0 a0 ... keyN aN) - bind value mapped by keyK in the 2634 SOURCE alist to aK. If the value is not found, aK is ‘nil’. Uses 2635 ‘assoc’ to fetch values. 2636 2637 (&hash key0 a0 ... keyN aN) - bind value mapped by keyK in the 2638 SOURCE hash table to aK. If the value is not found, aK is ‘nil’. 2639 Uses ‘gethash’ to fetch values. 2640 2641 Further, special keyword &keys supports "inline" matching of 2642 plist-like key-value pairs, similarly to &keys keyword of 2643 ‘cl-defun’. 2644 2645 (a1 a2 ... aN &keys key1 b1 ... keyN bK) 2646 2647 This binds N values from the list to a1 ... aN, then interprets the 2648 cdr as a plist (see key/value matching above). 2649 2650 A shorthand notation for kv-destructuring exists which allows the 2651 patterns be optionally left out and derived from the key name in 2652 the following fashion: 2653 2654 - a key :foo is converted into ‘foo’ pattern, - a key ’bar is 2655 converted into ‘bar’ pattern, - a key "baz" is converted into ‘baz’ 2656 pattern. 2657 2658 That is, the entire value under the key is bound to the derived 2659 variable without any further destructuring. 2660 2661 This is possible only when the form following the key is not a 2662 valid pattern (i.e. not a symbol, a cons cell or a vector). 2663 Otherwise the matching proceeds as usual and in case of an invalid 2664 spec fails with an error. 2665 2666 Thus the patterns are normalized as follows: 2667 2668 ;; derive all the missing patterns (&plist :foo ’bar "baz") => 2669 (&plist :foo foo ’bar bar "baz" baz) 2670 2671 ;; we can specify some but not others (&plist :foo ’bar 2672 explicit-bar) => (&plist :foo foo ’bar explicit-bar) 2673 2674 ;; nothing happens, we store :foo in x (&plist :foo x) => (&plist 2675 :foo x) 2676 2677 ;; nothing happens, we match recursively (&plist :foo (a b c)) => 2678 (&plist :foo (a b c)) 2679 2680 You can name the source using the syntax SYMBOL &as PATTERN. This 2681 syntax works with lists (proper or improper), vectors and all types 2682 of maps. 2683 2684 (list &as a b c) (list 1 2 3) 2685 2686 binds A to 1, B to 2, C to 3 and LIST to (1 2 3). 2687 2688 Similarly: 2689 2690 (bounds &as beg . end) (cons 1 2) 2691 2692 binds BEG to 1, END to 2 and BOUNDS to (1 . 2). 2693 2694 (items &as first . rest) (list 1 2 3) 2695 2696 binds FIRST to 1, REST to (2 3) and ITEMS to (1 2 3) 2697 2698 [vect &as _ b c] [1 2 3] 2699 2700 binds B to 2, C to 3 and VECT to [1 2 3] (_ avoids binding as 2701 usual). 2702 2703 (plist &as &plist :b b) (list :a 1 :b 2 :c 3) 2704 2705 binds B to 2 and PLIST to (:a 1 :b 2 :c 3). Same for &alist and 2706 &hash. 2707 2708 This is especially useful when we want to capture the result of a 2709 computation and destructure at the same time. Consider the form 2710 (function-returning-complex-structure) returning a list of two 2711 vectors with two items each. We want to capture this entire result 2712 and pass it to another computation, but at the same time we want to 2713 get the second item from each vector. We can achieve it with 2714 pattern 2715 2716 (result &as [_ a] [_ b]) (function-returning-complex-structure) 2717 2718 Note: Clojure programmers may know this feature as the ":as 2719 binding". The difference is that we put the &as at the front 2720 because we need to support improper list binding. 2721 2722 (-let (([a (b c) d] [1 (2 3) 4])) (list a b c d)) 2723 ⇒ (1 2 3 4) 2724 (-let [(a b c . d) (list 1 2 3 4 5 6)] (list a b c d)) 2725 ⇒ (1 2 3 (4 5 6)) 2726 (-let [(&plist :foo foo :bar bar) (list :baz 3 :foo 1 :qux 4 :bar 2)] (list foo bar)) 2727 ⇒ (1 2) 2728 2729 -- Macro: -let* (varlist &rest body) 2730 Bind variables according to VARLIST then eval BODY. 2731 2732 VARLIST is a list of lists of the form (PATTERN SOURCE). Each 2733 PATTERN is matched against the SOURCE structurally. SOURCE is only 2734 evaluated once for each PATTERN. 2735 2736 Each SOURCE can refer to the symbols already bound by this VARLIST. 2737 This is useful if you want to destructure SOURCE recursively but 2738 also want to name the intermediate structures. 2739 2740 See ‘-let’ (*note -let::) for the list of all possible patterns. 2741 2742 (-let* (((a . b) (cons 1 2)) ((c . d) (cons 3 4))) (list a b c d)) 2743 ⇒ (1 2 3 4) 2744 (-let* (((a . b) (cons 1 (cons 2 3))) ((c . d) b)) (list a b c d)) 2745 ⇒ (1 (2 . 3) 2 3) 2746 (-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)) 2747 ⇒ (1 a b c (a b c)) 2748 2749 -- Macro: -lambda (match-form &rest body) 2750 Return a lambda which destructures its input as MATCH-FORM and 2751 executes BODY. 2752 2753 Note that you have to enclose the MATCH-FORM in a pair of parens, 2754 such that: 2755 2756 (-lambda (x) body) (-lambda (x y ...) body) 2757 2758 has the usual semantics of ‘lambda’. Furthermore, these get 2759 translated into normal ‘lambda’, so there is no performance 2760 penalty. 2761 2762 See ‘-let’ (*note -let::) for a description of the destructuring 2763 mechanism. 2764 2765 (-map (-lambda ((x y)) (+ x y)) '((1 2) (3 4) (5 6))) 2766 ⇒ (3 7 11) 2767 (-map (-lambda ([x y]) (+ x y)) '([1 2] [3 4] [5 6])) 2768 ⇒ (3 7 11) 2769 (funcall (-lambda ((_ . a) (_ . b)) (-concat a b)) '(1 2 3) '(4 5 6)) 2770 ⇒ (2 3 5 6) 2771 2772 -- Macro: -setq ([match-form val] ...) 2773 Bind each MATCH-FORM to the value of its VAL. 2774 2775 MATCH-FORM destructuring is done according to the rules of ‘-let’ 2776 (*note -let::). 2777 2778 This macro allows you to bind multiple variables by destructuring 2779 the value, so for example: 2780 2781 (-setq (a b) x (&plist :c c) plist) 2782 2783 expands roughly speaking to the following code 2784 2785 (setq a (car x) b (cadr x) c (plist-get plist :c)) 2786 2787 Care is taken to only evaluate each VAL once so that in case of 2788 multiple assignments it does not cause unexpected side effects. 2789 2790 (let (a) (-setq a 1) a) 2791 ⇒ 1 2792 (let (a b) (-setq (a b) (list 1 2)) (list a b)) 2793 ⇒ (1 2) 2794 (let (c) (-setq (&plist :c c) (list :c "c")) c) 2795 ⇒ "c" 2796 2797 2798 File: dash.info, Node: Side effects, Next: Destructive operations, Prev: Binding, Up: Functions 2799 2800 2.14 Side effects 2801 ================= 2802 2803 Functions iterating over lists for side effect only. 2804 2805 -- Function: -each (list fn) 2806 Call FN on each element of LIST. Return ‘nil’; this function is 2807 intended for side effects. 2808 2809 Its anaphoric counterpart is ‘--each’. 2810 2811 For access to the current element’s index in LIST, see 2812 ‘-each-indexed’ (*note -each-indexed::). 2813 2814 (let (l) (-each '(1 2 3) (lambda (x) (push x l))) l) 2815 ⇒ (3 2 1) 2816 (let (l) (--each '(1 2 3) (push it l)) l) 2817 ⇒ (3 2 1) 2818 (-each '(1 2 3) #'identity) 2819 ⇒ nil 2820 2821 -- Function: -each-while (list pred fn) 2822 Call FN on each ITEM in LIST, while (PRED ITEM) is non-‘nil’. Once 2823 an ITEM is reached for which PRED returns ‘nil’, FN is no longer 2824 called. Return ‘nil’; this function is intended for side effects. 2825 2826 Its anaphoric counterpart is ‘--each-while’. 2827 2828 (let (l) (-each-while '(2 4 5 6) #'even? (lambda (x) (push x l))) l) 2829 ⇒ (4 2) 2830 (let (l) (--each-while '(1 2 3 4) (< it 3) (push it l)) l) 2831 ⇒ (2 1) 2832 (let ((s 0)) (--each-while '(1 3 4 5) (< it 5) (setq s (+ s it))) s) 2833 ⇒ 8 2834 2835 -- Function: -each-indexed (list fn) 2836 Call FN on each index and element of LIST. For each ITEM at INDEX 2837 in LIST, call (funcall FN INDEX ITEM). Return ‘nil’; this function 2838 is intended for side effects. 2839 2840 See also: ‘-map-indexed’ (*note -map-indexed::). 2841 2842 (let (l) (-each-indexed '(a b c) (lambda (i x) (push (list x i) l))) l) 2843 ⇒ ((c 2) (b 1) (a 0)) 2844 (let (l) (--each-indexed '(a b c) (push (list it it-index) l)) l) 2845 ⇒ ((c 2) (b 1) (a 0)) 2846 (let (l) (--each-indexed () (push it l)) l) 2847 ⇒ () 2848 2849 -- Function: -each-r (list fn) 2850 Call FN on each element of LIST in reversed order. Return ‘nil’; 2851 this function is intended for side effects. 2852 2853 Its anaphoric counterpart is ‘--each-r’. 2854 2855 (let (l) (-each-r '(1 2 3) (lambda (x) (push x l))) l) 2856 ⇒ (1 2 3) 2857 (let (l) (--each-r '(1 2 3) (push it l)) l) 2858 ⇒ (1 2 3) 2859 (-each-r '(1 2 3) #'identity) 2860 ⇒ nil 2861 2862 -- Function: -each-r-while (list pred fn) 2863 Call FN on each ITEM in reversed LIST, while (PRED ITEM) is 2864 non-‘nil’. Once an ITEM is reached for which PRED returns ‘nil’, 2865 FN is no longer called. Return ‘nil’; this function is intended 2866 for side effects. 2867 2868 Its anaphoric counterpart is ‘--each-r-while’. 2869 2870 (let (l) (-each-r-while '(2 4 5 6) #'even? (lambda (x) (push x l))) l) 2871 ⇒ (6) 2872 (let (l) (--each-r-while '(1 2 3 4) (>= it 3) (push it l)) l) 2873 ⇒ (3 4) 2874 (let ((s 0)) (--each-r-while '(1 2 3 5) (> it 1) (setq s (+ s it))) s) 2875 ⇒ 10 2876 2877 -- Function: -dotimes (num fn) 2878 Call FN NUM times, presumably for side effects. FN is called with 2879 a single argument on successive integers running from 0, inclusive, 2880 to NUM, exclusive. FN is not called if NUM is less than 1. 2881 2882 This function’s anaphoric counterpart is ‘--dotimes’. 2883 2884 (let (s) (-dotimes 3 (lambda (n) (push n s))) s) 2885 ⇒ (2 1 0) 2886 (let (s) (-dotimes 0 (lambda (n) (push n s))) s) 2887 ⇒ () 2888 (let (s) (--dotimes 5 (push it s)) s) 2889 ⇒ (4 3 2 1 0) 2890 2891 2892 File: dash.info, Node: Destructive operations, Next: Function combinators, Prev: Side effects, Up: Functions 2893 2894 2.15 Destructive operations 2895 =========================== 2896 2897 Macros that modify variables holding lists. 2898 2899 -- Macro: !cons (car cdr) 2900 Destructive: Set CDR to the cons of CAR and CDR. 2901 2902 (let (l) (!cons 5 l) l) 2903 ⇒ (5) 2904 (let ((l '(3))) (!cons 5 l) l) 2905 ⇒ (5 3) 2906 2907 -- Macro: !cdr (list) 2908 Destructive: Set LIST to the cdr of LIST. 2909 2910 (let ((l '(3))) (!cdr l) l) 2911 ⇒ () 2912 (let ((l '(3 5))) (!cdr l) l) 2913 ⇒ (5) 2914 2915 2916 File: dash.info, Node: Function combinators, Prev: Destructive operations, Up: Functions 2917 2918 2.16 Function combinators 2919 ========================= 2920 2921 Functions that manipulate and compose other functions. 2922 2923 -- Function: -partial (fun &rest args) 2924 Return a function that is a partial application of FUN to ARGS. 2925 ARGS is a list of the first N arguments to pass to FUN. The result 2926 is a new function which does the same as FUN, except that the first 2927 N arguments are fixed at the values with which this function was 2928 called. 2929 2930 (funcall (-partial #'+ 5)) 2931 ⇒ 5 2932 (funcall (-partial #'- 5) 3) 2933 ⇒ 2 2934 (funcall (-partial #'+ 5 2) 3) 2935 ⇒ 10 2936 2937 -- Function: -rpartial (fn &rest args) 2938 Return a function that is a partial application of FN to ARGS. 2939 ARGS is a list of the last N arguments to pass to FN. The result 2940 is a new function which does the same as FN, except that the last N 2941 arguments are fixed at the values with which this function was 2942 called. This is like ‘-partial’ (*note -partial::), except the 2943 arguments are fixed starting from the right rather than the left. 2944 2945 (funcall (-rpartial #'- 5)) 2946 ⇒ -5 2947 (funcall (-rpartial #'- 5) 8) 2948 ⇒ 3 2949 (funcall (-rpartial #'- 5 2) 10) 2950 ⇒ 3 2951 2952 -- Function: -juxt (&rest fns) 2953 Return a function that is the juxtaposition of FNS. The returned 2954 function takes a variable number of ARGS, applies each of FNS in 2955 turn to ARGS, and returns the list of results. 2956 2957 (funcall (-juxt) 1 2) 2958 ⇒ () 2959 (funcall (-juxt #'+ #'- #'* #'/) 7 5) 2960 ⇒ (12 2 35 1) 2961 (mapcar (-juxt #'number-to-string #'1+) '(1 2)) 2962 ⇒ (("1" 2) ("2" 3)) 2963 2964 -- Function: -compose (&rest fns) 2965 Compose FNS into a single composite function. Return a function 2966 that takes a variable number of ARGS, applies the last function in 2967 FNS to ARGS, and returns the result of calling each remaining 2968 function on the result of the previous function, right-to-left. If 2969 no FNS are given, return a variadic ‘identity’ function. 2970 2971 (funcall (-compose #'- #'1+ #'+) 1 2 3) 2972 ⇒ -7 2973 (funcall (-compose #'identity #'1+) 3) 2974 ⇒ 4 2975 (mapcar (-compose #'not #'stringp) '(nil "")) 2976 ⇒ (t nil) 2977 2978 -- Function: -applify (fn) 2979 Return a function that applies FN to a single list of args. This 2980 changes the arity of FN from taking N distinct arguments to taking 2981 1 argument which is a list of N arguments. 2982 2983 (funcall (-applify #'+) nil) 2984 ⇒ 0 2985 (mapcar (-applify #'+) '((1 1 1) (1 2 3) (5 5 5))) 2986 ⇒ (3 6 15) 2987 (funcall (-applify #'<) '(3 6)) 2988 ⇒ t 2989 2990 -- Function: -on (op trans) 2991 Return a function that calls TRANS on each arg and OP on the 2992 results. The returned function takes a variable number of 2993 arguments, calls the function TRANS on each one in turn, and then 2994 passes those results as the list of arguments to OP, in the same 2995 order. 2996 2997 For example, the following pairs of expressions are morally 2998 equivalent: 2999 3000 (funcall (-on #’+ #’1+) 1 2 3) = (+ (1+ 1) (1+ 2) (1+ 3)) (funcall 3001 (-on #’+ #’1+)) = (+) 3002 3003 (-sort (-on #'< #'length) '((1 2 3) (1) (1 2))) 3004 ⇒ ((1) (1 2) (1 2 3)) 3005 (funcall (-on #'min #'string-to-number) "22" "2" "1" "12") 3006 ⇒ 1 3007 (-min-by (-on #'> #'length) '((1 2 3) (4) (1 2))) 3008 ⇒ (4) 3009 3010 -- Function: -flip (fn) 3011 Return a function that calls FN with its arguments reversed. The 3012 returned function takes the same number of arguments as FN. 3013 3014 For example, the following two expressions are morally equivalent: 3015 3016 (funcall (-flip #’-) 1 2) = (- 2 1) 3017 3018 See also: ‘-rotate-args’ (*note -rotate-args::). 3019 3020 (-sort (-flip #'<) '(4 3 6 1)) 3021 ⇒ (6 4 3 1) 3022 (funcall (-flip #'-) 3 2 1 10) 3023 ⇒ 4 3024 (funcall (-flip #'1+) 1) 3025 ⇒ 2 3026 3027 -- Function: -rotate-args (n fn) 3028 Return a function that calls FN with args rotated N places to the 3029 right. The returned function takes the same number of arguments as 3030 FN, rotates the list of arguments N places to the right (left if N 3031 is negative) just like ‘-rotate’ (*note -rotate::), and applies FN 3032 to the result. 3033 3034 See also: ‘-flip’ (*note -flip::). 3035 3036 (funcall (-rotate-args -1 #'list) 1 2 3 4) 3037 ⇒ (2 3 4 1) 3038 (funcall (-rotate-args 1 #'-) 1 10 100) 3039 ⇒ 89 3040 (funcall (-rotate-args 2 #'list) 3 4 5 1 2) 3041 ⇒ (1 2 3 4 5) 3042 3043 -- Function: -const (c) 3044 Return a function that returns C ignoring any additional arguments. 3045 3046 In types: a -> b -> a 3047 3048 (funcall (-const 2) 1 3 "foo") 3049 ⇒ 2 3050 (mapcar (-const 1) '("a" "b" "c" "d")) 3051 ⇒ (1 1 1 1) 3052 (-sum (mapcar (-const 1) '("a" "b" "c" "d"))) 3053 ⇒ 4 3054 3055 -- Macro: -cut (&rest params) 3056 Take n-ary function and n arguments and specialize some of them. 3057 Arguments denoted by <> will be left unspecialized. 3058 3059 See SRFI-26 for detailed description. 3060 3061 (funcall (-cut list 1 <> 3 <> 5) 2 4) 3062 ⇒ (1 2 3 4 5) 3063 (-map (-cut funcall <> 5) `(1+ 1- ,(lambda (x) (/ 1.0 x)))) 3064 ⇒ (6 4 0.2) 3065 (-map (-cut <> 1 2 3) '(list vector string)) 3066 ⇒ ((1 2 3) [1 2 3] "\1\2\3") 3067 3068 -- Function: -not (pred) 3069 Return a predicate that negates the result of PRED. The returned 3070 predicate passes its arguments to PRED. If PRED returns ‘nil’, the 3071 result is non-‘nil’; otherwise the result is ‘nil’. 3072 3073 See also: ‘-andfn’ (*note -andfn::) and ‘-orfn’ (*note -orfn::). 3074 3075 (funcall (-not #'numberp) "5") 3076 ⇒ t 3077 (-sort (-not #'<) '(5 2 1 0 6)) 3078 ⇒ (6 5 2 1 0) 3079 (-filter (-not (-partial #'< 4)) '(1 2 3 4 5 6 7 8)) 3080 ⇒ (1 2 3 4) 3081 3082 -- Function: -orfn (&rest preds) 3083 Return a predicate that returns the first non-‘nil’ result of 3084 PREDS. The returned predicate takes a variable number of 3085 arguments, passes them to each predicate in PREDS in turn until one 3086 of them returns non-‘nil’, and returns that non-‘nil’ result 3087 without calling the remaining PREDS. If all PREDS return ‘nil’, or 3088 if no PREDS are given, the returned predicate returns ‘nil’. 3089 3090 See also: ‘-andfn’ (*note -andfn::) and ‘-not’ (*note -not::). 3091 3092 (-filter (-orfn #'natnump #'booleanp) '(1 nil "a" -4 b c t)) 3093 ⇒ (1 nil t) 3094 (funcall (-orfn #'symbolp (-cut string-match-p "x" <>)) "axe") 3095 ⇒ 1 3096 (funcall (-orfn #'= #'+) 1 1) 3097 ⇒ t 3098 3099 -- Function: -andfn (&rest preds) 3100 Return a predicate that returns non-‘nil’ if all PREDS do so. The 3101 returned predicate P takes a variable number of arguments and 3102 passes them to each predicate in PREDS in turn. If any one of 3103 PREDS returns ‘nil’, P also returns ‘nil’ without calling the 3104 remaining PREDS. If all PREDS return non-‘nil’, P returns the last 3105 such value. If no PREDS are given, P always returns non-‘nil’. 3106 3107 See also: ‘-orfn’ (*note -orfn::) and ‘-not’ (*note -not::). 3108 3109 (-filter (-andfn #'numberp (-cut < <> 5)) '(a 1 b 6 c 2)) 3110 ⇒ (1 2) 3111 (mapcar (-andfn #'numberp #'1+) '(a 1 b 6)) 3112 ⇒ (nil 2 nil 7) 3113 (funcall (-andfn #'= #'+) 1 1) 3114 ⇒ 2 3115 3116 -- Function: -iteratefn (fn n) 3117 Return a function FN composed N times with itself. 3118 3119 FN is a unary function. If you need to use a function of higher 3120 arity, use ‘-applify’ (*note -applify::) first to turn it into a 3121 unary function. 3122 3123 With n = 0, this acts as identity function. 3124 3125 In types: (a -> a) -> Int -> a -> a. 3126 3127 This function satisfies the following law: 3128 3129 (funcall (-iteratefn fn n) init) = (-last-item (-iterate fn init 3130 (1+ n))). 3131 3132 (funcall (-iteratefn (lambda (x) (* x x)) 3) 2) 3133 ⇒ 256 3134 (funcall (-iteratefn '1+ 3) 1) 3135 ⇒ 4 3136 (funcall (-iteratefn 'cdr 3) '(1 2 3 4 5)) 3137 ⇒ (4 5) 3138 3139 -- Function: -fixfn (fn &optional equal-test halt-test) 3140 Return a function that computes the (least) fixpoint of FN. 3141 3142 FN must be a unary function. The returned lambda takes a single 3143 argument, X, the initial value for the fixpoint iteration. The 3144 iteration halts when either of the following conditions is 3145 satisfied: 3146 3147 1. Iteration converges to the fixpoint, with equality being tested 3148 using EQUAL-TEST. If EQUAL-TEST is not specified, ‘equal’ is used. 3149 For functions over the floating point numbers, it may be necessary 3150 to provide an appropriate approximate comparison test. 3151 3152 2. HALT-TEST returns a non-‘nil’ value. HALT-TEST defaults to a 3153 simple counter that returns ‘t’ after ‘-fixfn-max-iterations’, to 3154 guard against infinite iteration. Otherwise, HALT-TEST must be a 3155 function that accepts a single argument, the current value of X, 3156 and returns non-‘nil’ as long as iteration should continue. In 3157 this way, a more sophisticated convergence test may be supplied by 3158 the caller. 3159 3160 The return value of the lambda is either the fixpoint or, if 3161 iteration halted before converging, a cons with car ‘halted’ and 3162 cdr the final output from HALT-TEST. 3163 3164 In types: (a -> a) -> a -> a. 3165 3166 (funcall (-fixfn #'cos #'approx=) 0.7) 3167 ⇒ 0.7390851332151607 3168 (funcall (-fixfn (lambda (x) (expt (+ x 10) 0.25))) 2.0) 3169 ⇒ 1.8555845286409378 3170 (funcall (-fixfn #'sin #'approx=) 0.1) 3171 ⇒ (halted . t) 3172 3173 -- Function: -prodfn (&rest fns) 3174 Return a function that applies each of FNS to each of a list of 3175 arguments. 3176 3177 Takes a list of N functions and returns a function that takes a 3178 list of length N, applying Ith function to Ith element of the input 3179 list. Returns a list of length N. 3180 3181 In types (for N=2): ((a -> b), (c -> d)) -> (a, c) -> (b, d) 3182 3183 This function satisfies the following laws: 3184 3185 (-compose (-prodfn f g ...) (-prodfn f’ g’ ...)) = (-prodfn 3186 (-compose f f’) (-compose g g’) ...) 3187 3188 (-prodfn f g ...) = (-juxt (-compose f (-partial #’nth 0)) 3189 (-compose g (-partial #’nth 1)) ...) 3190 3191 (-compose (-prodfn f g ...) (-juxt f’ g’ ...)) = (-juxt (-compose f 3192 f’) (-compose g g’) ...) 3193 3194 (-compose (-partial #’nth n) (-prod f1 f2 ...)) = (-compose fn 3195 (-partial #’nth n)) 3196 3197 (funcall (-prodfn #'1+ #'1- #'number-to-string) '(1 2 3)) 3198 ⇒ (2 1 "3") 3199 (-map (-prodfn #'1- #'1+) '((1 2) (3 4) (5 6))) 3200 ⇒ ((0 3) (2 5) (4 7)) 3201 (apply #'+ (funcall (-prodfn #'length #'string-to-number) '((t) "5"))) 3202 ⇒ 6 3203 3204 3205 File: dash.info, Node: Development, Next: FDL, Prev: Functions, Up: Top 3206 3207 3 Development 3208 ************* 3209 3210 The Dash repository is hosted on GitHub at 3211 <https://github.com/magnars/dash.el>. 3212 3213 * Menu: 3214 3215 * Contribute:: How to contribute. 3216 * Contributors:: List of contributors. 3217 3218 3219 File: dash.info, Node: Contribute, Next: Contributors, Up: Development 3220 3221 3.1 Contribute 3222 ============== 3223 3224 Yes, please do. Pure functions in the list manipulation realm only, 3225 please. There’s a suite of examples/tests in ‘dev/examples.el’, so 3226 remember to add tests for your additions, or they may get broken later. 3227 3228 Run the tests with ‘make check’. Regenerate the docs with ‘make 3229 docs’. Contributors are encouraged to install these commands as a Git 3230 pre-commit hook, so that the tests are always running and the docs are 3231 always in sync: 3232 3233 $ cp dev/pre-commit.sh .git/hooks/pre-commit 3234 3235 Oh, and don’t edit ‘README.md’ or ‘dash.texi’ directly, as they are 3236 auto-generated. Instead, change their respective templates 3237 ‘readme-template.md’ or ‘dash-template.texi’. 3238 3239 To ensure that Dash can be distributed with GNU ELPA or Emacs, we 3240 require that all contributors assign copyright to the Free Software 3241 Foundation. For more on this, *note (emacs)Copyright Assignment::. 3242 3243 3244 File: dash.info, Node: Contributors, Prev: Contribute, Up: Development 3245 3246 3.2 Contributors 3247 ================ 3248 3249 • Matus Goljer (https://github.com/Fuco1) contributed lots of 3250 features and functions. 3251 • Takafumi Arakaki (https://github.com/tkf) contributed ‘-group-by’. 3252 • tali713 (https://github.com/tali713) is the author of ‘-applify’. 3253 • Víctor M. Valenzuela (https://github.com/vemv) contributed 3254 ‘-repeat’. 3255 • Nic Ferrier (https://github.com/nicferrier) contributed ‘-cons*’. 3256 • Wilfred Hughes (https://github.com/Wilfred) contributed ‘-slice’, 3257 ‘-first-item’, and ‘-last-item’. 3258 • Emanuel Evans (https://github.com/shosti) contributed ‘-if-let’, 3259 ‘-when-let’, and ‘-insert-at’. 3260 • Johan Andersson (https://github.com/rejeep) contributed ‘-sum’, 3261 ‘-product’, and ‘-same-items?’. 3262 • Christina Whyte (https://github.com/kurisuwhyte) contributed 3263 ‘-compose’. 3264 • Steve Lamb (https://github.com/steventlamb) contributed ‘-cycle’, 3265 ‘-pad’, ‘-annotate’, ‘-zip-fill’, and a variadic version of ‘-zip’. 3266 • Fredrik Bergroth (https://github.com/fbergroth) made the ‘-if-let’ 3267 family use ‘-let’ destructuring and improved the script for 3268 generating documentation. 3269 • Mark Oteiza (https://github.com/holomorph) contributed ‘-iota’ and 3270 the script to create an Info manual. 3271 • Vasilij Schneidermann (https://github.com/wasamasa) contributed 3272 ‘-some’. 3273 • William West (https://github.com/occidens) made ‘-fixfn’ more 3274 robust at handling floats. 3275 • Cam Saul (https://github.com/camsaul) contributed ‘-some->’, 3276 ‘-some->>’, and ‘-some-->’. 3277 • Basil L. Contovounesios (https://github.com/basil-conto) 3278 contributed ‘-common-prefix’, ‘-common-suffix’, and various other 3279 improvements. 3280 • Paul Pogonyshev (https://github.com/doublep) contributed ‘-each-r’ 3281 and ‘-each-r-while’. 3282 3283 Thanks! 3284 3285 New contributors are very welcome. *Note Contribute::. 3286 3287 3288 File: dash.info, Node: FDL, Next: GPL, Prev: Development, Up: Top 3289 3290 Appendix A GNU Free Documentation License 3291 ***************************************** 3292 3293 Version 1.3, 3 November 2008 3294 3295 Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. 3296 <https://fsf.org/> 3297 3298 Everyone is permitted to copy and distribute verbatim copies 3299 of this license document, but changing it is not allowed. 3300 3301 0. PREAMBLE 3302 3303 The purpose of this License is to make a manual, textbook, or other 3304 functional and useful document “free” in the sense of freedom: to 3305 assure everyone the effective freedom to copy and redistribute it, 3306 with or without modifying it, either commercially or 3307 noncommercially. Secondarily, this License preserves for the 3308 author and publisher a way to get credit for their work, while not 3309 being considered responsible for modifications made by others. 3310 3311 This License is a kind of “copyleft”, which means that derivative 3312 works of the document must themselves be free in the same sense. 3313 It complements the GNU General Public License, which is a copyleft 3314 license designed for free software. 3315 3316 We have designed this License in order to use it for manuals for 3317 free software, because free software needs free documentation: a 3318 free program should come with manuals providing the same freedoms 3319 that the software does. But this License is not limited to 3320 software manuals; it can be used for any textual work, regardless 3321 of subject matter or whether it is published as a printed book. We 3322 recommend this License principally for works whose purpose is 3323 instruction or reference. 3324 3325 1. APPLICABILITY AND DEFINITIONS 3326 3327 This License applies to any manual or other work, in any medium, 3328 that contains a notice placed by the copyright holder saying it can 3329 be distributed under the terms of this License. Such a notice 3330 grants a world-wide, royalty-free license, unlimited in duration, 3331 to use that work under the conditions stated herein. The 3332 “Document”, below, refers to any such manual or work. Any member 3333 of the public is a licensee, and is addressed as “you”. You accept 3334 the license if you copy, modify or distribute the work in a way 3335 requiring permission under copyright law. 3336 3337 A “Modified Version” of the Document means any work containing the 3338 Document or a portion of it, either copied verbatim, or with 3339 modifications and/or translated into another language. 3340 3341 A “Secondary Section” is a named appendix or a front-matter section 3342 of the Document that deals exclusively with the relationship of the 3343 publishers or authors of the Document to the Document’s overall 3344 subject (or to related matters) and contains nothing that could 3345 fall directly within that overall subject. (Thus, if the Document 3346 is in part a textbook of mathematics, a Secondary Section may not 3347 explain any mathematics.) The relationship could be a matter of 3348 historical connection with the subject or with related matters, or 3349 of legal, commercial, philosophical, ethical or political position 3350 regarding them. 3351 3352 The “Invariant Sections” are certain Secondary Sections whose 3353 titles are designated, as being those of Invariant Sections, in the 3354 notice that says that the Document is released under this License. 3355 If a section does not fit the above definition of Secondary then it 3356 is not allowed to be designated as Invariant. The Document may 3357 contain zero Invariant Sections. If the Document does not identify 3358 any Invariant Sections then there are none. 3359 3360 The “Cover Texts” are certain short passages of text that are 3361 listed, as Front-Cover Texts or Back-Cover Texts, in the notice 3362 that says that the Document is released under this License. A 3363 Front-Cover Text may be at most 5 words, and a Back-Cover Text may 3364 be at most 25 words. 3365 3366 A “Transparent” copy of the Document means a machine-readable copy, 3367 represented in a format whose specification is available to the 3368 general public, that is suitable for revising the document 3369 straightforwardly with generic text editors or (for images composed 3370 of pixels) generic paint programs or (for drawings) some widely 3371 available drawing editor, and that is suitable for input to text 3372 formatters or for automatic translation to a variety of formats 3373 suitable for input to text formatters. A copy made in an otherwise 3374 Transparent file format whose markup, or absence of markup, has 3375 been arranged to thwart or discourage subsequent modification by 3376 readers is not Transparent. An image format is not Transparent if 3377 used for any substantial amount of text. A copy that is not 3378 “Transparent” is called “Opaque”. 3379 3380 Examples of suitable formats for Transparent copies include plain 3381 ASCII without markup, Texinfo input format, LaTeX input format, 3382 SGML or XML using a publicly available DTD, and standard-conforming 3383 simple HTML, PostScript or PDF designed for human modification. 3384 Examples of transparent image formats include PNG, XCF and JPG. 3385 Opaque formats include proprietary formats that can be read and 3386 edited only by proprietary word processors, SGML or XML for which 3387 the DTD and/or processing tools are not generally available, and 3388 the machine-generated HTML, PostScript or PDF produced by some word 3389 processors for output purposes only. 3390 3391 The “Title Page” means, for a printed book, the title page itself, 3392 plus such following pages as are needed to hold, legibly, the 3393 material this License requires to appear in the title page. For 3394 works in formats which do not have any title page as such, “Title 3395 Page” means the text near the most prominent appearance of the 3396 work’s title, preceding the beginning of the body of the text. 3397 3398 The “publisher” means any person or entity that distributes copies 3399 of the Document to the public. 3400 3401 A section “Entitled XYZ” means a named subunit of the Document 3402 whose title either is precisely XYZ or contains XYZ in parentheses 3403 following text that translates XYZ in another language. (Here XYZ 3404 stands for a specific section name mentioned below, such as 3405 “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.) 3406 To “Preserve the Title” of such a section when you modify the 3407 Document means that it remains a section “Entitled XYZ” according 3408 to this definition. 3409 3410 The Document may include Warranty Disclaimers next to the notice 3411 which states that this License applies to the Document. These 3412 Warranty Disclaimers are considered to be included by reference in 3413 this License, but only as regards disclaiming warranties: any other 3414 implication that these Warranty Disclaimers may have is void and 3415 has no effect on the meaning of this License. 3416 3417 2. VERBATIM COPYING 3418 3419 You may copy and distribute the Document in any medium, either 3420 commercially or noncommercially, provided that this License, the 3421 copyright notices, and the license notice saying this License 3422 applies to the Document are reproduced in all copies, and that you 3423 add no other conditions whatsoever to those of this License. You 3424 may not use technical measures to obstruct or control the reading 3425 or further copying of the copies you make or distribute. However, 3426 you may accept compensation in exchange for copies. If you 3427 distribute a large enough number of copies you must also follow the 3428 conditions in section 3. 3429 3430 You may also lend copies, under the same conditions stated above, 3431 and you may publicly display copies. 3432 3433 3. COPYING IN QUANTITY 3434 3435 If you publish printed copies (or copies in media that commonly 3436 have printed covers) of the Document, numbering more than 100, and 3437 the Document’s license notice requires Cover Texts, you must 3438 enclose the copies in covers that carry, clearly and legibly, all 3439 these Cover Texts: Front-Cover Texts on the front cover, and 3440 Back-Cover Texts on the back cover. Both covers must also clearly 3441 and legibly identify you as the publisher of these copies. The 3442 front cover must present the full title with all words of the title 3443 equally prominent and visible. You may add other material on the 3444 covers in addition. Copying with changes limited to the covers, as 3445 long as they preserve the title of the Document and satisfy these 3446 conditions, can be treated as verbatim copying in other respects. 3447 3448 If the required texts for either cover are too voluminous to fit 3449 legibly, you should put the first ones listed (as many as fit 3450 reasonably) on the actual cover, and continue the rest onto 3451 adjacent pages. 3452 3453 If you publish or distribute Opaque copies of the Document 3454 numbering more than 100, you must either include a machine-readable 3455 Transparent copy along with each Opaque copy, or state in or with 3456 each Opaque copy a computer-network location from which the general 3457 network-using public has access to download using public-standard 3458 network protocols a complete Transparent copy of the Document, free 3459 of added material. If you use the latter option, you must take 3460 reasonably prudent steps, when you begin distribution of Opaque 3461 copies in quantity, to ensure that this Transparent copy will 3462 remain thus accessible at the stated location until at least one 3463 year after the last time you distribute an Opaque copy (directly or 3464 through your agents or retailers) of that edition to the public. 3465 3466 It is requested, but not required, that you contact the authors of 3467 the Document well before redistributing any large number of copies, 3468 to give them a chance to provide you with an updated version of the 3469 Document. 3470 3471 4. MODIFICATIONS 3472 3473 You may copy and distribute a Modified Version of the Document 3474 under the conditions of sections 2 and 3 above, provided that you 3475 release the Modified Version under precisely this License, with the 3476 Modified Version filling the role of the Document, thus licensing 3477 distribution and modification of the Modified Version to whoever 3478 possesses a copy of it. In addition, you must do these things in 3479 the Modified Version: 3480 3481 A. Use in the Title Page (and on the covers, if any) a title 3482 distinct from that of the Document, and from those of previous 3483 versions (which should, if there were any, be listed in the 3484 History section of the Document). You may use the same title 3485 as a previous version if the original publisher of that 3486 version gives permission. 3487 3488 B. List on the Title Page, as authors, one or more persons or 3489 entities responsible for authorship of the modifications in 3490 the Modified Version, together with at least five of the 3491 principal authors of the Document (all of its principal 3492 authors, if it has fewer than five), unless they release you 3493 from this requirement. 3494 3495 C. State on the Title page the name of the publisher of the 3496 Modified Version, as the publisher. 3497 3498 D. Preserve all the copyright notices of the Document. 3499 3500 E. Add an appropriate copyright notice for your modifications 3501 adjacent to the other copyright notices. 3502 3503 F. Include, immediately after the copyright notices, a license 3504 notice giving the public permission to use the Modified 3505 Version under the terms of this License, in the form shown in 3506 the Addendum below. 3507 3508 G. Preserve in that license notice the full lists of Invariant 3509 Sections and required Cover Texts given in the Document’s 3510 license notice. 3511 3512 H. Include an unaltered copy of this License. 3513 3514 I. Preserve the section Entitled “History”, Preserve its Title, 3515 and add to it an item stating at least the title, year, new 3516 authors, and publisher of the Modified Version as given on the 3517 Title Page. If there is no section Entitled “History” in the 3518 Document, create one stating the title, year, authors, and 3519 publisher of the Document as given on its Title Page, then add 3520 an item describing the Modified Version as stated in the 3521 previous sentence. 3522 3523 J. Preserve the network location, if any, given in the Document 3524 for public access to a Transparent copy of the Document, and 3525 likewise the network locations given in the Document for 3526 previous versions it was based on. These may be placed in the 3527 “History” section. You may omit a network location for a work 3528 that was published at least four years before the Document 3529 itself, or if the original publisher of the version it refers 3530 to gives permission. 3531 3532 K. For any section Entitled “Acknowledgements” or “Dedications”, 3533 Preserve the Title of the section, and preserve in the section 3534 all the substance and tone of each of the contributor 3535 acknowledgements and/or dedications given therein. 3536 3537 L. Preserve all the Invariant Sections of the Document, unaltered 3538 in their text and in their titles. Section numbers or the 3539 equivalent are not considered part of the section titles. 3540 3541 M. Delete any section Entitled “Endorsements”. Such a section 3542 may not be included in the Modified Version. 3543 3544 N. Do not retitle any existing section to be Entitled 3545 “Endorsements” or to conflict in title with any Invariant 3546 Section. 3547 3548 O. Preserve any Warranty Disclaimers. 3549 3550 If the Modified Version includes new front-matter sections or 3551 appendices that qualify as Secondary Sections and contain no 3552 material copied from the Document, you may at your option designate 3553 some or all of these sections as invariant. To do this, add their 3554 titles to the list of Invariant Sections in the Modified Version’s 3555 license notice. These titles must be distinct from any other 3556 section titles. 3557 3558 You may add a section Entitled “Endorsements”, provided it contains 3559 nothing but endorsements of your Modified Version by various 3560 parties—for example, statements of peer review or that the text has 3561 been approved by an organization as the authoritative definition of 3562 a standard. 3563 3564 You may add a passage of up to five words as a Front-Cover Text, 3565 and a passage of up to 25 words as a Back-Cover Text, to the end of 3566 the list of Cover Texts in the Modified Version. Only one passage 3567 of Front-Cover Text and one of Back-Cover Text may be added by (or 3568 through arrangements made by) any one entity. If the Document 3569 already includes a cover text for the same cover, previously added 3570 by you or by arrangement made by the same entity you are acting on 3571 behalf of, you may not add another; but you may replace the old 3572 one, on explicit permission from the previous publisher that added 3573 the old one. 3574 3575 The author(s) and publisher(s) of the Document do not by this 3576 License give permission to use their names for publicity for or to 3577 assert or imply endorsement of any Modified Version. 3578 3579 5. COMBINING DOCUMENTS 3580 3581 You may combine the Document with other documents released under 3582 this License, under the terms defined in section 4 above for 3583 modified versions, provided that you include in the combination all 3584 of the Invariant Sections of all of the original documents, 3585 unmodified, and list them all as Invariant Sections of your 3586 combined work in its license notice, and that you preserve all 3587 their Warranty Disclaimers. 3588 3589 The combined work need only contain one copy of this License, and 3590 multiple identical Invariant Sections may be replaced with a single 3591 copy. If there are multiple Invariant Sections with the same name 3592 but different contents, make the title of each such section unique 3593 by adding at the end of it, in parentheses, the name of the 3594 original author or publisher of that section if known, or else a 3595 unique number. Make the same adjustment to the section titles in 3596 the list of Invariant Sections in the license notice of the 3597 combined work. 3598 3599 In the combination, you must combine any sections Entitled 3600 “History” in the various original documents, forming one section 3601 Entitled “History”; likewise combine any sections Entitled 3602 “Acknowledgements”, and any sections Entitled “Dedications”. You 3603 must delete all sections Entitled “Endorsements.” 3604 3605 6. COLLECTIONS OF DOCUMENTS 3606 3607 You may make a collection consisting of the Document and other 3608 documents released under this License, and replace the individual 3609 copies of this License in the various documents with a single copy 3610 that is included in the collection, provided that you follow the 3611 rules of this License for verbatim copying of each of the documents 3612 in all other respects. 3613 3614 You may extract a single document from such a collection, and 3615 distribute it individually under this License, provided you insert 3616 a copy of this License into the extracted document, and follow this 3617 License in all other respects regarding verbatim copying of that 3618 document. 3619 3620 7. AGGREGATION WITH INDEPENDENT WORKS 3621 3622 A compilation of the Document or its derivatives with other 3623 separate and independent documents or works, in or on a volume of a 3624 storage or distribution medium, is called an “aggregate” if the 3625 copyright resulting from the compilation is not used to limit the 3626 legal rights of the compilation’s users beyond what the individual 3627 works permit. When the Document is included in an aggregate, this 3628 License does not apply to the other works in the aggregate which 3629 are not themselves derivative works of the Document. 3630 3631 If the Cover Text requirement of section 3 is applicable to these 3632 copies of the Document, then if the Document is less than one half 3633 of the entire aggregate, the Document’s Cover Texts may be placed 3634 on covers that bracket the Document within the aggregate, or the 3635 electronic equivalent of covers if the Document is in electronic 3636 form. Otherwise they must appear on printed covers that bracket 3637 the whole aggregate. 3638 3639 8. TRANSLATION 3640 3641 Translation is considered a kind of modification, so you may 3642 distribute translations of the Document under the terms of section 3643 4. Replacing Invariant Sections with translations requires special 3644 permission from their copyright holders, but you may include 3645 translations of some or all Invariant Sections in addition to the 3646 original versions of these Invariant Sections. You may include a 3647 translation of this License, and all the license notices in the 3648 Document, and any Warranty Disclaimers, provided that you also 3649 include the original English version of this License and the 3650 original versions of those notices and disclaimers. In case of a 3651 disagreement between the translation and the original version of 3652 this License or a notice or disclaimer, the original version will 3653 prevail. 3654 3655 If a section in the Document is Entitled “Acknowledgements”, 3656 “Dedications”, or “History”, the requirement (section 4) to 3657 Preserve its Title (section 1) will typically require changing the 3658 actual title. 3659 3660 9. TERMINATION 3661 3662 You may not copy, modify, sublicense, or distribute the Document 3663 except as expressly provided under this License. Any attempt 3664 otherwise to copy, modify, sublicense, or distribute it is void, 3665 and will automatically terminate your rights under this License. 3666 3667 However, if you cease all violation of this License, then your 3668 license from a particular copyright holder is reinstated (a) 3669 provisionally, unless and until the copyright holder explicitly and 3670 finally terminates your license, and (b) permanently, if the 3671 copyright holder fails to notify you of the violation by some 3672 reasonable means prior to 60 days after the cessation. 3673 3674 Moreover, your license from a particular copyright holder is 3675 reinstated permanently if the copyright holder notifies you of the 3676 violation by some reasonable means, this is the first time you have 3677 received notice of violation of this License (for any work) from 3678 that copyright holder, and you cure the violation prior to 30 days 3679 after your receipt of the notice. 3680 3681 Termination of your rights under this section does not terminate 3682 the licenses of parties who have received copies or rights from you 3683 under this License. If your rights have been terminated and not 3684 permanently reinstated, receipt of a copy of some or all of the 3685 same material does not give you any rights to use it. 3686 3687 10. FUTURE REVISIONS OF THIS LICENSE 3688 3689 The Free Software Foundation may publish new, revised versions of 3690 the GNU Free Documentation License from time to time. Such new 3691 versions will be similar in spirit to the present version, but may 3692 differ in detail to address new problems or concerns. See 3693 <https://www.gnu.org/licenses/>. 3694 3695 Each version of the License is given a distinguishing version 3696 number. If the Document specifies that a particular numbered 3697 version of this License “or any later version” applies to it, you 3698 have the option of following the terms and conditions either of 3699 that specified version or of any later version that has been 3700 published (not as a draft) by the Free Software Foundation. If the 3701 Document does not specify a version number of this License, you may 3702 choose any version ever published (not as a draft) by the Free 3703 Software Foundation. If the Document specifies that a proxy can 3704 decide which future versions of this License can be used, that 3705 proxy’s public statement of acceptance of a version permanently 3706 authorizes you to choose that version for the Document. 3707 3708 11. RELICENSING 3709 3710 “Massive Multiauthor Collaboration Site” (or “MMC Site”) means any 3711 World Wide Web server that publishes copyrightable works and also 3712 provides prominent facilities for anybody to edit those works. A 3713 public wiki that anybody can edit is an example of such a server. 3714 A “Massive Multiauthor Collaboration” (or “MMC”) contained in the 3715 site means any set of copyrightable works thus published on the MMC 3716 site. 3717 3718 “CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0 3719 license published by Creative Commons Corporation, a not-for-profit 3720 corporation with a principal place of business in San Francisco, 3721 California, as well as future copyleft versions of that license 3722 published by that same organization. 3723 3724 “Incorporate” means to publish or republish a Document, in whole or 3725 in part, as part of another Document. 3726 3727 An MMC is “eligible for relicensing” if it is licensed under this 3728 License, and if all works that were first published under this 3729 License somewhere other than this MMC, and subsequently 3730 incorporated in whole or in part into the MMC, (1) had no cover 3731 texts or invariant sections, and (2) were thus incorporated prior 3732 to November 1, 2008. 3733 3734 The operator of an MMC Site may republish an MMC contained in the 3735 site under CC-BY-SA on the same site at any time before August 1, 3736 2009, provided the MMC is eligible for relicensing. 3737 3738 ADDENDUM: How to use this License for your documents 3739 ==================================================== 3740 3741 To use this License in a document you have written, include a copy of 3742 the License in the document and put the following copyright and license 3743 notices just after the title page: 3744 3745 Copyright (C) YEAR YOUR NAME. 3746 Permission is granted to copy, distribute and/or modify this document 3747 under the terms of the GNU Free Documentation License, Version 1.3 3748 or any later version published by the Free Software Foundation; 3749 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover 3750 Texts. A copy of the license is included in the section entitled ``GNU 3751 Free Documentation License''. 3752 3753 If you have Invariant Sections, Front-Cover Texts and Back-Cover 3754 Texts, replace the “with...Texts.” line with this: 3755 3756 with the Invariant Sections being LIST THEIR TITLES, with 3757 the Front-Cover Texts being LIST, and with the Back-Cover Texts 3758 being LIST. 3759 3760 If you have Invariant Sections without Cover Texts, or some other 3761 combination of the three, merge those two alternatives to suit the 3762 situation. 3763 3764 If your document contains nontrivial examples of program code, we 3765 recommend releasing these examples in parallel under your choice of free 3766 software license, such as the GNU General Public License, to permit 3767 their use in free software. 3768 3769 3770 File: dash.info, Node: GPL, Next: Index, Prev: FDL, Up: Top 3771 3772 Appendix B GNU General Public License 3773 ************************************* 3774 3775 Version 3, 29 June 2007 3776 3777 Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/> 3778 3779 Everyone is permitted to copy and distribute verbatim copies of this 3780 license document, but changing it is not allowed. 3781 3782 Preamble 3783 ======== 3784 3785 The GNU General Public License is a free, copyleft license for software 3786 and other kinds of works. 3787 3788 The licenses for most software and other practical works are designed 3789 to take away your freedom to share and change the works. By contrast, 3790 the GNU General Public License is intended to guarantee your freedom to 3791 share and change all versions of a program—to make sure it remains free 3792 software for all its users. We, the Free Software Foundation, use the 3793 GNU General Public License for most of our software; it applies also to 3794 any other work released this way by its authors. You can apply it to 3795 your programs, too. 3796 3797 When we speak of free software, we are referring to freedom, not 3798 price. Our General Public Licenses are designed to make sure that you 3799 have the freedom to distribute copies of free software (and charge for 3800 them if you wish), that you receive source code or can get it if you 3801 want it, that you can change the software or use pieces of it in new 3802 free programs, and that you know you can do these things. 3803 3804 To protect your rights, we need to prevent others from denying you 3805 these rights or asking you to surrender the rights. Therefore, you have 3806 certain responsibilities if you distribute copies of the software, or if 3807 you modify it: responsibilities to respect the freedom of others. 3808 3809 For example, if you distribute copies of such a program, whether 3810 gratis or for a fee, you must pass on to the recipients the same 3811 freedoms that you received. You must make sure that they, too, receive 3812 or can get the source code. And you must show them these terms so they 3813 know their rights. 3814 3815 Developers that use the GNU GPL protect your rights with two steps: 3816 (1) assert copyright on the software, and (2) offer you this License 3817 giving you legal permission to copy, distribute and/or modify it. 3818 3819 For the developers’ and authors’ protection, the GPL clearly explains 3820 that there is no warranty for this free software. For both users’ and 3821 authors’ sake, the GPL requires that modified versions be marked as 3822 changed, so that their problems will not be attributed erroneously to 3823 authors of previous versions. 3824 3825 Some devices are designed to deny users access to install or run 3826 modified versions of the software inside them, although the manufacturer 3827 can do so. This is fundamentally incompatible with the aim of 3828 protecting users’ freedom to change the software. The systematic 3829 pattern of such abuse occurs in the area of products for individuals to 3830 use, which is precisely where it is most unacceptable. Therefore, we 3831 have designed this version of the GPL to prohibit the practice for those 3832 products. If such problems arise substantially in other domains, we 3833 stand ready to extend this provision to those domains in future versions 3834 of the GPL, as needed to protect the freedom of users. 3835 3836 Finally, every program is threatened constantly by software patents. 3837 States should not allow patents to restrict development and use of 3838 software on general-purpose computers, but in those that do, we wish to 3839 avoid the special danger that patents applied to a free program could 3840 make it effectively proprietary. To prevent this, the GPL assures that 3841 patents cannot be used to render the program non-free. 3842 3843 The precise terms and conditions for copying, distribution and 3844 modification follow. 3845 3846 TERMS AND CONDITIONS 3847 ==================== 3848 3849 0. Definitions. 3850 3851 “This License” refers to version 3 of the GNU General Public 3852 License. 3853 3854 “Copyright” also means copyright-like laws that apply to other 3855 kinds of works, such as semiconductor masks. 3856 3857 “The Program” refers to any copyrightable work licensed under this 3858 License. Each licensee is addressed as “you”. “Licensees” and 3859 “recipients” may be individuals or organizations. 3860 3861 To “modify” a work means to copy from or adapt all or part of the 3862 work in a fashion requiring copyright permission, other than the 3863 making of an exact copy. The resulting work is called a “modified 3864 version” of the earlier work or a work “based on” the earlier work. 3865 3866 A “covered work” means either the unmodified Program or a work 3867 based on the Program. 3868 3869 To “propagate” a work means to do anything with it that, without 3870 permission, would make you directly or secondarily liable for 3871 infringement under applicable copyright law, except executing it on 3872 a computer or modifying a private copy. Propagation includes 3873 copying, distribution (with or without modification), making 3874 available to the public, and in some countries other activities as 3875 well. 3876 3877 To “convey” a work means any kind of propagation that enables other 3878 parties to make or receive copies. Mere interaction with a user 3879 through a computer network, with no transfer of a copy, is not 3880 conveying. 3881 3882 An interactive user interface displays “Appropriate Legal Notices” 3883 to the extent that it includes a convenient and prominently visible 3884 feature that (1) displays an appropriate copyright notice, and (2) 3885 tells the user that there is no warranty for the work (except to 3886 the extent that warranties are provided), that licensees may convey 3887 the work under this License, and how to view a copy of this 3888 License. If the interface presents a list of user commands or 3889 options, such as a menu, a prominent item in the list meets this 3890 criterion. 3891 3892 1. Source Code. 3893 3894 The “source code” for a work means the preferred form of the work 3895 for making modifications to it. “Object code” means any non-source 3896 form of a work. 3897 3898 A “Standard Interface” means an interface that either is an 3899 official standard defined by a recognized standards body, or, in 3900 the case of interfaces specified for a particular programming 3901 language, one that is widely used among developers working in that 3902 language. 3903 3904 The “System Libraries” of an executable work include anything, 3905 other than the work as a whole, that (a) is included in the normal 3906 form of packaging a Major Component, but which is not part of that 3907 Major Component, and (b) serves only to enable use of the work with 3908 that Major Component, or to implement a Standard Interface for 3909 which an implementation is available to the public in source code 3910 form. A “Major Component”, in this context, means a major 3911 essential component (kernel, window system, and so on) of the 3912 specific operating system (if any) on which the executable work 3913 runs, or a compiler used to produce the work, or an object code 3914 interpreter used to run it. 3915 3916 The “Corresponding Source” for a work in object code form means all 3917 the source code needed to generate, install, and (for an executable 3918 work) run the object code and to modify the work, including scripts 3919 to control those activities. However, it does not include the 3920 work’s System Libraries, or general-purpose tools or generally 3921 available free programs which are used unmodified in performing 3922 those activities but which are not part of the work. For example, 3923 Corresponding Source includes interface definition files associated 3924 with source files for the work, and the source code for shared 3925 libraries and dynamically linked subprograms that the work is 3926 specifically designed to require, such as by intimate data 3927 communication or control flow between those subprograms and other 3928 parts of the work. 3929 3930 The Corresponding Source need not include anything that users can 3931 regenerate automatically from other parts of the Corresponding 3932 Source. 3933 3934 The Corresponding Source for a work in source code form is that 3935 same work. 3936 3937 2. Basic Permissions. 3938 3939 All rights granted under this License are granted for the term of 3940 copyright on the Program, and are irrevocable provided the stated 3941 conditions are met. This License explicitly affirms your unlimited 3942 permission to run the unmodified Program. The output from running 3943 a covered work is covered by this License only if the output, given 3944 its content, constitutes a covered work. This License acknowledges 3945 your rights of fair use or other equivalent, as provided by 3946 copyright law. 3947 3948 You may make, run and propagate covered works that you do not 3949 convey, without conditions so long as your license otherwise 3950 remains in force. You may convey covered works to others for the 3951 sole purpose of having them make modifications exclusively for you, 3952 or provide you with facilities for running those works, provided 3953 that you comply with the terms of this License in conveying all 3954 material for which you do not control copyright. Those thus making 3955 or running the covered works for you must do so exclusively on your 3956 behalf, under your direction and control, on terms that prohibit 3957 them from making any copies of your copyrighted material outside 3958 their relationship with you. 3959 3960 Conveying under any other circumstances is permitted solely under 3961 the conditions stated below. Sublicensing is not allowed; section 3962 10 makes it unnecessary. 3963 3964 3. Protecting Users’ Legal Rights From Anti-Circumvention Law. 3965 3966 No covered work shall be deemed part of an effective technological 3967 measure under any applicable law fulfilling obligations under 3968 article 11 of the WIPO copyright treaty adopted on 20 December 3969 1996, or similar laws prohibiting or restricting circumvention of 3970 such measures. 3971 3972 When you convey a covered work, you waive any legal power to forbid 3973 circumvention of technological measures to the extent such 3974 circumvention is effected by exercising rights under this License 3975 with respect to the covered work, and you disclaim any intention to 3976 limit operation or modification of the work as a means of 3977 enforcing, against the work’s users, your or third parties’ legal 3978 rights to forbid circumvention of technological measures. 3979 3980 4. Conveying Verbatim Copies. 3981 3982 You may convey verbatim copies of the Program’s source code as you 3983 receive it, in any medium, provided that you conspicuously and 3984 appropriately publish on each copy an appropriate copyright notice; 3985 keep intact all notices stating that this License and any 3986 non-permissive terms added in accord with section 7 apply to the 3987 code; keep intact all notices of the absence of any warranty; and 3988 give all recipients a copy of this License along with the Program. 3989 3990 You may charge any price or no price for each copy that you convey, 3991 and you may offer support or warranty protection for a fee. 3992 3993 5. Conveying Modified Source Versions. 3994 3995 You may convey a work based on the Program, or the modifications to 3996 produce it from the Program, in the form of source code under the 3997 terms of section 4, provided that you also meet all of these 3998 conditions: 3999 4000 a. The work must carry prominent notices stating that you 4001 modified it, and giving a relevant date. 4002 4003 b. The work must carry prominent notices stating that it is 4004 released under this License and any conditions added under 4005 section 7. This requirement modifies the requirement in 4006 section 4 to “keep intact all notices”. 4007 4008 c. You must license the entire work, as a whole, under this 4009 License to anyone who comes into possession of a copy. This 4010 License will therefore apply, along with any applicable 4011 section 7 additional terms, to the whole of the work, and all 4012 its parts, regardless of how they are packaged. This License 4013 gives no permission to license the work in any other way, but 4014 it does not invalidate such permission if you have separately 4015 received it. 4016 4017 d. If the work has interactive user interfaces, each must display 4018 Appropriate Legal Notices; however, if the Program has 4019 interactive interfaces that do not display Appropriate Legal 4020 Notices, your work need not make them do so. 4021 4022 A compilation of a covered work with other separate and independent 4023 works, which are not by their nature extensions of the covered 4024 work, and which are not combined with it such as to form a larger 4025 program, in or on a volume of a storage or distribution medium, is 4026 called an “aggregate” if the compilation and its resulting 4027 copyright are not used to limit the access or legal rights of the 4028 compilation’s users beyond what the individual works permit. 4029 Inclusion of a covered work in an aggregate does not cause this 4030 License to apply to the other parts of the aggregate. 4031 4032 6. Conveying Non-Source Forms. 4033 4034 You may convey a covered work in object code form under the terms 4035 of sections 4 and 5, provided that you also convey the 4036 machine-readable Corresponding Source under the terms of this 4037 License, in one of these ways: 4038 4039 a. Convey the object code in, or embodied in, a physical product 4040 (including a physical distribution medium), accompanied by the 4041 Corresponding Source fixed on a durable physical medium 4042 customarily used for software interchange. 4043 4044 b. Convey the object code in, or embodied in, a physical product 4045 (including a physical distribution medium), accompanied by a 4046 written offer, valid for at least three years and valid for as 4047 long as you offer spare parts or customer support for that 4048 product model, to give anyone who possesses the object code 4049 either (1) a copy of the Corresponding Source for all the 4050 software in the product that is covered by this License, on a 4051 durable physical medium customarily used for software 4052 interchange, for a price no more than your reasonable cost of 4053 physically performing this conveying of source, or (2) access 4054 to copy the Corresponding Source from a network server at no 4055 charge. 4056 4057 c. Convey individual copies of the object code with a copy of the 4058 written offer to provide the Corresponding Source. This 4059 alternative is allowed only occasionally and noncommercially, 4060 and only if you received the object code with such an offer, 4061 in accord with subsection 6b. 4062 4063 d. Convey the object code by offering access from a designated 4064 place (gratis or for a charge), and offer equivalent access to 4065 the Corresponding Source in the same way through the same 4066 place at no further charge. You need not require recipients 4067 to copy the Corresponding Source along with the object code. 4068 If the place to copy the object code is a network server, the 4069 Corresponding Source may be on a different server (operated by 4070 you or a third party) that supports equivalent copying 4071 facilities, provided you maintain clear directions next to the 4072 object code saying where to find the Corresponding Source. 4073 Regardless of what server hosts the Corresponding Source, you 4074 remain obligated to ensure that it is available for as long as 4075 needed to satisfy these requirements. 4076 4077 e. Convey the object code using peer-to-peer transmission, 4078 provided you inform other peers where the object code and 4079 Corresponding Source of the work are being offered to the 4080 general public at no charge under subsection 6d. 4081 4082 A separable portion of the object code, whose source code is 4083 excluded from the Corresponding Source as a System Library, need 4084 not be included in conveying the object code work. 4085 4086 A “User Product” is either (1) a “consumer product”, which means 4087 any tangible personal property which is normally used for personal, 4088 family, or household purposes, or (2) anything designed or sold for 4089 incorporation into a dwelling. In determining whether a product is 4090 a consumer product, doubtful cases shall be resolved in favor of 4091 coverage. For a particular product received by a particular user, 4092 “normally used” refers to a typical or common use of that class of 4093 product, regardless of the status of the particular user or of the 4094 way in which the particular user actually uses, or expects or is 4095 expected to use, the product. A product is a consumer product 4096 regardless of whether the product has substantial commercial, 4097 industrial or non-consumer uses, unless such uses represent the 4098 only significant mode of use of the product. 4099 4100 “Installation Information” for a User Product means any methods, 4101 procedures, authorization keys, or other information required to 4102 install and execute modified versions of a covered work in that 4103 User Product from a modified version of its Corresponding Source. 4104 The information must suffice to ensure that the continued 4105 functioning of the modified object code is in no case prevented or 4106 interfered with solely because modification has been made. 4107 4108 If you convey an object code work under this section in, or with, 4109 or specifically for use in, a User Product, and the conveying 4110 occurs as part of a transaction in which the right of possession 4111 and use of the User Product is transferred to the recipient in 4112 perpetuity or for a fixed term (regardless of how the transaction 4113 is characterized), the Corresponding Source conveyed under this 4114 section must be accompanied by the Installation Information. But 4115 this requirement does not apply if neither you nor any third party 4116 retains the ability to install modified object code on the User 4117 Product (for example, the work has been installed in ROM). 4118 4119 The requirement to provide Installation Information does not 4120 include a requirement to continue to provide support service, 4121 warranty, or updates for a work that has been modified or installed 4122 by the recipient, or for the User Product in which it has been 4123 modified or installed. Access to a network may be denied when the 4124 modification itself materially and adversely affects the operation 4125 of the network or violates the rules and protocols for 4126 communication across the network. 4127 4128 Corresponding Source conveyed, and Installation Information 4129 provided, in accord with this section must be in a format that is 4130 publicly documented (and with an implementation available to the 4131 public in source code form), and must require no special password 4132 or key for unpacking, reading or copying. 4133 4134 7. Additional Terms. 4135 4136 “Additional permissions” are terms that supplement the terms of 4137 this License by making exceptions from one or more of its 4138 conditions. Additional permissions that are applicable to the 4139 entire Program shall be treated as though they were included in 4140 this License, to the extent that they are valid under applicable 4141 law. If additional permissions apply only to part of the Program, 4142 that part may be used separately under those permissions, but the 4143 entire Program remains governed by this License without regard to 4144 the additional permissions. 4145 4146 When you convey a copy of a covered work, you may at your option 4147 remove any additional permissions from that copy, or from any part 4148 of it. (Additional permissions may be written to require their own 4149 removal in certain cases when you modify the work.) You may place 4150 additional permissions on material, added by you to a covered work, 4151 for which you have or can give appropriate copyright permission. 4152 4153 Notwithstanding any other provision of this License, for material 4154 you add to a covered work, you may (if authorized by the copyright 4155 holders of that material) supplement the terms of this License with 4156 terms: 4157 4158 a. Disclaiming warranty or limiting liability differently from 4159 the terms of sections 15 and 16 of this License; or 4160 4161 b. Requiring preservation of specified reasonable legal notices 4162 or author attributions in that material or in the Appropriate 4163 Legal Notices displayed by works containing it; or 4164 4165 c. Prohibiting misrepresentation of the origin of that material, 4166 or requiring that modified versions of such material be marked 4167 in reasonable ways as different from the original version; or 4168 4169 d. Limiting the use for publicity purposes of names of licensors 4170 or authors of the material; or 4171 4172 e. Declining to grant rights under trademark law for use of some 4173 trade names, trademarks, or service marks; or 4174 4175 f. Requiring indemnification of licensors and authors of that 4176 material by anyone who conveys the material (or modified 4177 versions of it) with contractual assumptions of liability to 4178 the recipient, for any liability that these contractual 4179 assumptions directly impose on those licensors and authors. 4180 4181 All other non-permissive additional terms are considered “further 4182 restrictions” within the meaning of section 10. If the Program as 4183 you received it, or any part of it, contains a notice stating that 4184 it is governed by this License along with a term that is a further 4185 restriction, you may remove that term. If a license document 4186 contains a further restriction but permits relicensing or conveying 4187 under this License, you may add to a covered work material governed 4188 by the terms of that license document, provided that the further 4189 restriction does not survive such relicensing or conveying. 4190 4191 If you add terms to a covered work in accord with this section, you 4192 must place, in the relevant source files, a statement of the 4193 additional terms that apply to those files, or a notice indicating 4194 where to find the applicable terms. 4195 4196 Additional terms, permissive or non-permissive, may be stated in 4197 the form of a separately written license, or stated as exceptions; 4198 the above requirements apply either way. 4199 4200 8. Termination. 4201 4202 You may not propagate or modify a covered work except as expressly 4203 provided under this License. Any attempt otherwise to propagate or 4204 modify it is void, and will automatically terminate your rights 4205 under this License (including any patent licenses granted under the 4206 third paragraph of section 11). 4207 4208 However, if you cease all violation of this License, then your 4209 license from a particular copyright holder is reinstated (a) 4210 provisionally, unless and until the copyright holder explicitly and 4211 finally terminates your license, and (b) permanently, if the 4212 copyright holder fails to notify you of the violation by some 4213 reasonable means prior to 60 days after the cessation. 4214 4215 Moreover, your license from a particular copyright holder is 4216 reinstated permanently if the copyright holder notifies you of the 4217 violation by some reasonable means, this is the first time you have 4218 received notice of violation of this License (for any work) from 4219 that copyright holder, and you cure the violation prior to 30 days 4220 after your receipt of the notice. 4221 4222 Termination of your rights under this section does not terminate 4223 the licenses of parties who have received copies or rights from you 4224 under this License. If your rights have been terminated and not 4225 permanently reinstated, you do not qualify to receive new licenses 4226 for the same material under section 10. 4227 4228 9. Acceptance Not Required for Having Copies. 4229 4230 You are not required to accept this License in order to receive or 4231 run a copy of the Program. Ancillary propagation of a covered work 4232 occurring solely as a consequence of using peer-to-peer 4233 transmission to receive a copy likewise does not require 4234 acceptance. However, nothing other than this License grants you 4235 permission to propagate or modify any covered work. These actions 4236 infringe copyright if you do not accept this License. Therefore, 4237 by modifying or propagating a covered work, you indicate your 4238 acceptance of this License to do so. 4239 4240 10. Automatic Licensing of Downstream Recipients. 4241 4242 Each time you convey a covered work, the recipient automatically 4243 receives a license from the original licensors, to run, modify and 4244 propagate that work, subject to this License. You are not 4245 responsible for enforcing compliance by third parties with this 4246 License. 4247 4248 An “entity transaction” is a transaction transferring control of an 4249 organization, or substantially all assets of one, or subdividing an 4250 organization, or merging organizations. If propagation of a 4251 covered work results from an entity transaction, each party to that 4252 transaction who receives a copy of the work also receives whatever 4253 licenses to the work the party’s predecessor in interest had or 4254 could give under the previous paragraph, plus a right to possession 4255 of the Corresponding Source of the work from the predecessor in 4256 interest, if the predecessor has it or can get it with reasonable 4257 efforts. 4258 4259 You may not impose any further restrictions on the exercise of the 4260 rights granted or affirmed under this License. For example, you 4261 may not impose a license fee, royalty, or other charge for exercise 4262 of rights granted under this License, and you may not initiate 4263 litigation (including a cross-claim or counterclaim in a lawsuit) 4264 alleging that any patent claim is infringed by making, using, 4265 selling, offering for sale, or importing the Program or any portion 4266 of it. 4267 4268 11. Patents. 4269 4270 A “contributor” is a copyright holder who authorizes use under this 4271 License of the Program or a work on which the Program is based. 4272 The work thus licensed is called the contributor’s “contributor 4273 version”. 4274 4275 A contributor’s “essential patent claims” are all patent claims 4276 owned or controlled by the contributor, whether already acquired or 4277 hereafter acquired, that would be infringed by some manner, 4278 permitted by this License, of making, using, or selling its 4279 contributor version, but do not include claims that would be 4280 infringed only as a consequence of further modification of the 4281 contributor version. For purposes of this definition, “control” 4282 includes the right to grant patent sublicenses in a manner 4283 consistent with the requirements of this License. 4284 4285 Each contributor grants you a non-exclusive, worldwide, 4286 royalty-free patent license under the contributor’s essential 4287 patent claims, to make, use, sell, offer for sale, import and 4288 otherwise run, modify and propagate the contents of its contributor 4289 version. 4290 4291 In the following three paragraphs, a “patent license” is any 4292 express agreement or commitment, however denominated, not to 4293 enforce a patent (such as an express permission to practice a 4294 patent or covenant not to sue for patent infringement). To “grant” 4295 such a patent license to a party means to make such an agreement or 4296 commitment not to enforce a patent against the party. 4297 4298 If you convey a covered work, knowingly relying on a patent 4299 license, and the Corresponding Source of the work is not available 4300 for anyone to copy, free of charge and under the terms of this 4301 License, through a publicly available network server or other 4302 readily accessible means, then you must either (1) cause the 4303 Corresponding Source to be so available, or (2) arrange to deprive 4304 yourself of the benefit of the patent license for this particular 4305 work, or (3) arrange, in a manner consistent with the requirements 4306 of this License, to extend the patent license to downstream 4307 recipients. “Knowingly relying” means you have actual knowledge 4308 that, but for the patent license, your conveying the covered work 4309 in a country, or your recipient’s use of the covered work in a 4310 country, would infringe one or more identifiable patents in that 4311 country that you have reason to believe are valid. 4312 4313 If, pursuant to or in connection with a single transaction or 4314 arrangement, you convey, or propagate by procuring conveyance of, a 4315 covered work, and grant a patent license to some of the parties 4316 receiving the covered work authorizing them to use, propagate, 4317 modify or convey a specific copy of the covered work, then the 4318 patent license you grant is automatically extended to all 4319 recipients of the covered work and works based on it. 4320 4321 A patent license is “discriminatory” if it does not include within 4322 the scope of its coverage, prohibits the exercise of, or is 4323 conditioned on the non-exercise of one or more of the rights that 4324 are specifically granted under this License. You may not convey a 4325 covered work if you are a party to an arrangement with a third 4326 party that is in the business of distributing software, under which 4327 you make payment to the third party based on the extent of your 4328 activity of conveying the work, and under which the third party 4329 grants, to any of the parties who would receive the covered work 4330 from you, a discriminatory patent license (a) in connection with 4331 copies of the covered work conveyed by you (or copies made from 4332 those copies), or (b) primarily for and in connection with specific 4333 products or compilations that contain the covered work, unless you 4334 entered into that arrangement, or that patent license was granted, 4335 prior to 28 March 2007. 4336 4337 Nothing in this License shall be construed as excluding or limiting 4338 any implied license or other defenses to infringement that may 4339 otherwise be available to you under applicable patent law. 4340 4341 12. No Surrender of Others’ Freedom. 4342 4343 If conditions are imposed on you (whether by court order, agreement 4344 or otherwise) that contradict the conditions of this License, they 4345 do not excuse you from the conditions of this License. If you 4346 cannot convey a covered work so as to satisfy simultaneously your 4347 obligations under this License and any other pertinent obligations, 4348 then as a consequence you may not convey it at all. For example, 4349 if you agree to terms that obligate you to collect a royalty for 4350 further conveying from those to whom you convey the Program, the 4351 only way you could satisfy both those terms and this License would 4352 be to refrain entirely from conveying the Program. 4353 4354 13. Use with the GNU Affero General Public License. 4355 4356 Notwithstanding any other provision of this License, you have 4357 permission to link or combine any covered work with a work licensed 4358 under version 3 of the GNU Affero General Public License into a 4359 single combined work, and to convey the resulting work. The terms 4360 of this License will continue to apply to the part which is the 4361 covered work, but the special requirements of the GNU Affero 4362 General Public License, section 13, concerning interaction through 4363 a network will apply to the combination as such. 4364 4365 14. Revised Versions of this License. 4366 4367 The Free Software Foundation may publish revised and/or new 4368 versions of the GNU General Public License from time to time. Such 4369 new versions will be similar in spirit to the present version, but 4370 may differ in detail to address new problems or concerns. 4371 4372 Each version is given a distinguishing version number. If the 4373 Program specifies that a certain numbered version of the GNU 4374 General Public License “or any later version” applies to it, you 4375 have the option of following the terms and conditions either of 4376 that numbered version or of any later version published by the Free 4377 Software Foundation. If the Program does not specify a version 4378 number of the GNU General Public License, you may choose any 4379 version ever published by the Free Software Foundation. 4380 4381 If the Program specifies that a proxy can decide which future 4382 versions of the GNU General Public License can be used, that 4383 proxy’s public statement of acceptance of a version permanently 4384 authorizes you to choose that version for the Program. 4385 4386 Later license versions may give you additional or different 4387 permissions. However, no additional obligations are imposed on any 4388 author or copyright holder as a result of your choosing to follow a 4389 later version. 4390 4391 15. Disclaimer of Warranty. 4392 4393 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 4394 APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE 4395 COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” 4396 WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, 4397 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 4398 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE 4399 RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. 4400 SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL 4401 NECESSARY SERVICING, REPAIR OR CORRECTION. 4402 4403 16. Limitation of Liability. 4404 4405 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 4406 WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES 4407 AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR 4408 DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 4409 CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE 4410 THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA 4411 BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 4412 PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 4413 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF 4414 THE POSSIBILITY OF SUCH DAMAGES. 4415 4416 17. Interpretation of Sections 15 and 16. 4417 4418 If the disclaimer of warranty and limitation of liability provided 4419 above cannot be given local legal effect according to their terms, 4420 reviewing courts shall apply local law that most closely 4421 approximates an absolute waiver of all civil liability in 4422 connection with the Program, unless a warranty or assumption of 4423 liability accompanies a copy of the Program in return for a fee. 4424 4425 END OF TERMS AND CONDITIONS 4426 =========================== 4427 4428 How to Apply These Terms to Your New Programs 4429 ============================================= 4430 4431 If you develop a new program, and you want it to be of the greatest 4432 possible use to the public, the best way to achieve this is to make it 4433 free software which everyone can redistribute and change under these 4434 terms. 4435 4436 To do so, attach the following notices to the program. It is safest 4437 to attach them to the start of each source file to most effectively 4438 state the exclusion of warranty; and each file should have at least the 4439 “copyright” line and a pointer to where the full notice is found. 4440 4441 ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES. 4442 Copyright (C) YEAR NAME OF AUTHOR 4443 4444 This program is free software: you can redistribute it and/or modify 4445 it under the terms of the GNU General Public License as published by 4446 the Free Software Foundation, either version 3 of the License, or (at 4447 your option) any later version. 4448 4449 This program is distributed in the hope that it will be useful, but 4450 WITHOUT ANY WARRANTY; without even the implied warranty of 4451 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 4452 General Public License for more details. 4453 4454 You should have received a copy of the GNU General Public License 4455 along with this program. If not, see <https://www.gnu.org/licenses/>. 4456 4457 Also add information on how to contact you by electronic and paper 4458 mail. 4459 4460 If the program does terminal interaction, make it output a short 4461 notice like this when it starts in an interactive mode: 4462 4463 PROGRAM Copyright (C) YEAR NAME OF AUTHOR 4464 This program comes with ABSOLUTELY NO WARRANTY; for details type ‘show w’. 4465 This is free software, and you are welcome to redistribute it 4466 under certain conditions; type ‘show c’ for details. 4467 4468 The hypothetical commands ‘show w’ and ‘show c’ should show the 4469 appropriate parts of the General Public License. Of course, your 4470 program’s commands might be different; for a GUI interface, you would 4471 use an “about box”. 4472 4473 You should also get your employer (if you work as a programmer) or 4474 school, if any, to sign a “copyright disclaimer” for the program, if 4475 necessary. For more information on this, and how to apply and follow 4476 the GNU GPL, see <https://www.gnu.org/licenses/>. 4477 4478 The GNU General Public License does not permit incorporating your 4479 program into proprietary programs. If your program is a subroutine 4480 library, you may consider it more useful to permit linking proprietary 4481 applications with the library. If this is what you want to do, use the 4482 GNU Lesser General Public License instead of this License. But first, 4483 please read <https://www.gnu.org/licenses/why-not-lgpl.html>. 4484 4485 4486 File: dash.info, Node: Index, Prev: GPL, Up: Top 4487 4488 Index 4489 ***** 4490 4491 4492 * Menu: 4493 4494 * !cdr: Destructive operations. 4495 (line 16) 4496 * !cons: Destructive operations. 4497 (line 8) 4498 * -->: Threading macros. (line 35) 4499 * ->: Threading macros. (line 9) 4500 * ->>: Threading macros. (line 22) 4501 * -all?: Predicates. (line 53) 4502 * -andfn: Function combinators. 4503 (line 184) 4504 * -annotate: Maps. (line 86) 4505 * -any?: Predicates. (line 41) 4506 * -applify: Function combinators. 4507 (line 63) 4508 * -as->: Threading macros. (line 49) 4509 * -butlast: Other list operations. 4510 (line 405) 4511 * -clone: Tree operations. (line 123) 4512 * -common-prefix: Reductions. (line 242) 4513 * -common-suffix: Reductions. (line 252) 4514 * -compose: Function combinators. 4515 (line 49) 4516 * -concat: List to list. (line 23) 4517 * -cons*: Other list operations. 4518 (line 19) 4519 * -cons-pair?: Predicates. (line 154) 4520 * -const: Function combinators. 4521 (line 128) 4522 * -contains?: Predicates. (line 100) 4523 * -copy: Maps. (line 151) 4524 * -count: Reductions. (line 172) 4525 * -cut: Function combinators. 4526 (line 140) 4527 * -cycle: Unfolding. (line 55) 4528 * -difference: Set operations. (line 22) 4529 * -distinct: Set operations. (line 73) 4530 * -dotimes: Side effects. (line 80) 4531 * -doto: Threading macros. (line 99) 4532 * -drop: Sublist selection. (line 149) 4533 * -drop-last: Sublist selection. (line 163) 4534 * -drop-while: Sublist selection. (line 194) 4535 * -each: Side effects. (line 8) 4536 * -each-indexed: Side effects. (line 38) 4537 * -each-r: Side effects. (line 52) 4538 * -each-r-while: Side effects. (line 65) 4539 * -each-while: Side effects. (line 24) 4540 * -elem-index: Indexing. (line 9) 4541 * -elem-indices: Indexing. (line 23) 4542 * -every: Predicates. (line 23) 4543 * -fifth-item: Other list operations. 4544 (line 380) 4545 * -filter: Sublist selection. (line 8) 4546 * -find-index: Indexing. (line 35) 4547 * -find-indices: Indexing. (line 73) 4548 * -find-last-index: Indexing. (line 54) 4549 * -first: Other list operations. 4550 (line 300) 4551 * -first-item: Other list operations. 4552 (line 328) 4553 * -fix: Other list operations. 4554 (line 445) 4555 * -fixfn: Function combinators. 4556 (line 224) 4557 * -flatten: List to list. (line 38) 4558 * -flatten-n: List to list. (line 60) 4559 * -flip: Function combinators. 4560 (line 95) 4561 * -fourth-item: Other list operations. 4562 (line 367) 4563 * -frequencies: Reductions. (line 310) 4564 * -grade-down: Indexing. (line 103) 4565 * -grade-up: Indexing. (line 93) 4566 * -group-by: Partitioning. (line 205) 4567 * -if-let: Binding. (line 34) 4568 * -if-let*: Binding. (line 45) 4569 * -inits: Reductions. (line 222) 4570 * -insert-at: List to list. (line 114) 4571 * -interleave: Other list operations. 4572 (line 56) 4573 * -interpose: Other list operations. 4574 (line 46) 4575 * -intersection: Set operations. (line 36) 4576 * -iota: Other list operations. 4577 (line 67) 4578 * -is-infix?: Predicates. (line 140) 4579 * -is-prefix?: Predicates. (line 116) 4580 * -is-suffix?: Predicates. (line 128) 4581 * -iterate: Unfolding. (line 9) 4582 * -iteratefn: Function combinators. 4583 (line 201) 4584 * -juxt: Function combinators. 4585 (line 37) 4586 * -keep: List to list. (line 8) 4587 * -lambda: Binding. (line 247) 4588 * -last: Other list operations. 4589 (line 318) 4590 * -last-item: Other list operations. 4591 (line 393) 4592 * -let: Binding. (line 61) 4593 * -let*: Binding. (line 227) 4594 * -list: Other list operations. 4595 (line 428) 4596 * -map: Maps. (line 10) 4597 * -map-first: Maps. (line 38) 4598 * -map-indexed: Maps. (line 68) 4599 * -map-last: Maps. (line 53) 4600 * -map-when: Maps. (line 22) 4601 * -mapcat: Maps. (line 140) 4602 * -max: Reductions. (line 286) 4603 * -max-by: Reductions. (line 296) 4604 * -min: Reductions. (line 262) 4605 * -min-by: Reductions. (line 272) 4606 * -non-nil: Sublist selection. (line 95) 4607 * -none?: Predicates. (line 73) 4608 * -not: Function combinators. 4609 (line 153) 4610 * -on: Function combinators. 4611 (line 75) 4612 * -only-some?: Predicates. (line 85) 4613 * -orfn: Function combinators. 4614 (line 167) 4615 * -pad: Other list operations. 4616 (line 241) 4617 * -partial: Function combinators. 4618 (line 8) 4619 * -partition: Partitioning. (line 90) 4620 * -partition-after-item: Partitioning. (line 195) 4621 * -partition-after-pred: Partitioning. (line 162) 4622 * -partition-all: Partitioning. (line 102) 4623 * -partition-all-in-steps: Partitioning. (line 126) 4624 * -partition-before-item: Partitioning. (line 185) 4625 * -partition-before-pred: Partitioning. (line 174) 4626 * -partition-by: Partitioning. (line 138) 4627 * -partition-by-header: Partitioning. (line 149) 4628 * -partition-in-steps: Partitioning. (line 113) 4629 * -permutations: Set operations. (line 60) 4630 * -powerset: Set operations. (line 50) 4631 * -prodfn: Function combinators. 4632 (line 258) 4633 * -product: Reductions. (line 201) 4634 * -reduce: Reductions. (line 53) 4635 * -reduce-from: Reductions. (line 8) 4636 * -reduce-r: Reductions. (line 72) 4637 * -reduce-r-from: Reductions. (line 26) 4638 * -reductions: Reductions. (line 136) 4639 * -reductions-from: Reductions. (line 100) 4640 * -reductions-r: Reductions. (line 154) 4641 * -reductions-r-from: Reductions. (line 118) 4642 * -remove: Sublist selection. (line 26) 4643 * -remove-at: List to list. (line 151) 4644 * -remove-at-indices: List to list. (line 170) 4645 * -remove-first: Sublist selection. (line 44) 4646 * -remove-item: Sublist selection. (line 84) 4647 * -remove-last: Sublist selection. (line 65) 4648 * -repeat: Unfolding. (line 44) 4649 * -replace: List to list. (line 72) 4650 * -replace-at: List to list. (line 125) 4651 * -replace-first: List to list. (line 86) 4652 * -replace-last: List to list. (line 100) 4653 * -rotate: Other list operations. 4654 (line 8) 4655 * -rotate-args: Function combinators. 4656 (line 112) 4657 * -rpartial: Function combinators. 4658 (line 22) 4659 * -running-product: Reductions. (line 211) 4660 * -running-sum: Reductions. (line 190) 4661 * -same-items?: Set operations. (line 88) 4662 * -second-item: Other list operations. 4663 (line 341) 4664 * -select-by-indices: Sublist selection. (line 211) 4665 * -select-column: Sublist selection. (line 241) 4666 * -select-columns: Sublist selection. (line 222) 4667 * -separate: Partitioning. (line 75) 4668 * -setq: Binding. (line 270) 4669 * -slice: Sublist selection. (line 105) 4670 * -snoc: Other list operations. 4671 (line 32) 4672 * -some: Predicates. (line 8) 4673 * -some-->: Threading macros. (line 86) 4674 * -some->: Threading macros. (line 62) 4675 * -some->>: Threading macros. (line 74) 4676 * -sort: Other list operations. 4677 (line 415) 4678 * -splice: Maps. (line 102) 4679 * -splice-list: Maps. (line 127) 4680 * -split-at: Partitioning. (line 8) 4681 * -split-on: Partitioning. (line 40) 4682 * -split-when: Partitioning. (line 58) 4683 * -split-with: Partitioning. (line 23) 4684 * -sum: Reductions. (line 180) 4685 * -table: Other list operations. 4686 (line 256) 4687 * -table-flat: Other list operations. 4688 (line 275) 4689 * -tails: Reductions. (line 232) 4690 * -take: Sublist selection. (line 121) 4691 * -take-last: Sublist selection. (line 135) 4692 * -take-while: Sublist selection. (line 177) 4693 * -third-item: Other list operations. 4694 (line 354) 4695 * -tree-map: Tree operations. (line 28) 4696 * -tree-map-nodes: Tree operations. (line 39) 4697 * -tree-mapreduce: Tree operations. (line 85) 4698 * -tree-mapreduce-from: Tree operations. (line 104) 4699 * -tree-reduce: Tree operations. (line 53) 4700 * -tree-reduce-from: Tree operations. (line 70) 4701 * -tree-seq: Tree operations. (line 8) 4702 * -unfold: Unfolding. (line 25) 4703 * -union: Set operations. (line 8) 4704 * -unzip: Other list operations. 4705 (line 215) 4706 * -unzip-lists: Other list operations. 4707 (line 196) 4708 * -update-at: List to list. (line 137) 4709 * -when-let: Binding. (line 9) 4710 * -when-let*: Binding. (line 21) 4711 * -zip: Other list operations. 4712 (line 150) 4713 * -zip-fill: Other list operations. 4714 (line 176) 4715 * -zip-lists: Other list operations. 4716 (line 114) 4717 * -zip-lists-fill: Other list operations. 4718 (line 135) 4719 * -zip-pair: Other list operations. 4720 (line 98) 4721 * -zip-with: Other list operations. 4722 (line 80) 4723 * dash-fontify-mode: Fontification of special variables. 4724 (line 6) 4725 * dash-register-info-lookup: Info symbol lookup. (line 6) 4726 * global-dash-fontify-mode: Fontification of special variables. 4727 (line 12) 4728 4729 4730 4731 Tag Table: 4732 Node: Top742 4733 Node: Installation2397 4734 Node: Using in a package3159 4735 Node: Fontification of special variables3504 4736 Node: Info symbol lookup4294 4737 Node: Functions4877 4738 Node: Maps6361 4739 Ref: -map6658 4740 Ref: -map-when7031 4741 Ref: -map-first7605 4742 Ref: -map-last8200 4743 Ref: -map-indexed8790 4744 Ref: -annotate9476 4745 Ref: -splice10080 4746 Ref: -splice-list11155 4747 Ref: -mapcat11614 4748 Ref: -copy11987 4749 Node: Sublist selection12175 4750 Ref: -filter12368 4751 Ref: -remove12921 4752 Ref: -remove-first13470 4753 Ref: -remove-last14318 4754 Ref: -remove-item15048 4755 Ref: -non-nil15448 4756 Ref: -slice15730 4757 Ref: -take16259 4758 Ref: -take-last16677 4759 Ref: -drop17114 4760 Ref: -drop-last17561 4761 Ref: -take-while17993 4762 Ref: -drop-while18620 4763 Ref: -select-by-indices19253 4764 Ref: -select-columns19764 4765 Ref: -select-column20467 4766 Node: List to list20930 4767 Ref: -keep21122 4768 Ref: -concat21698 4769 Ref: -flatten22226 4770 Ref: -flatten-n22988 4771 Ref: -replace23372 4772 Ref: -replace-first23833 4773 Ref: -replace-last24328 4774 Ref: -insert-at24816 4775 Ref: -replace-at25141 4776 Ref: -update-at25528 4777 Ref: -remove-at26069 4778 Ref: -remove-at-indices26696 4779 Node: Reductions27386 4780 Ref: -reduce-from27582 4781 Ref: -reduce-r-from28306 4782 Ref: -reduce29569 4783 Ref: -reduce-r30320 4784 Ref: -reductions-from31598 4785 Ref: -reductions-r-from32404 4786 Ref: -reductions33234 4787 Ref: -reductions-r33945 4788 Ref: -count34690 4789 Ref: -sum34920 4790 Ref: -running-sum35108 4791 Ref: -product35429 4792 Ref: -running-product35637 4793 Ref: -inits35978 4794 Ref: -tails36223 4795 Ref: -common-prefix36468 4796 Ref: -common-suffix36762 4797 Ref: -min37056 4798 Ref: -min-by37282 4799 Ref: -max37803 4800 Ref: -max-by38028 4801 Ref: -frequencies38554 4802 Node: Unfolding39169 4803 Ref: -iterate39410 4804 Ref: -unfold39857 4805 Ref: -repeat40662 4806 Ref: -cycle40946 4807 Node: Predicates41343 4808 Ref: -some41520 4809 Ref: -every41949 4810 Ref: -any?42663 4811 Ref: -all?43012 4812 Ref: -none?43754 4813 Ref: -only-some?44074 4814 Ref: -contains?44619 4815 Ref: -is-prefix?45125 4816 Ref: -is-suffix?45457 4817 Ref: -is-infix?45789 4818 Ref: -cons-pair?46149 4819 Node: Partitioning46480 4820 Ref: -split-at46668 4821 Ref: -split-with47332 4822 Ref: -split-on47972 4823 Ref: -split-when48643 4824 Ref: -separate49286 4825 Ref: -partition49820 4826 Ref: -partition-all50269 4827 Ref: -partition-in-steps50694 4828 Ref: -partition-all-in-steps51240 4829 Ref: -partition-by51754 4830 Ref: -partition-by-header52132 4831 Ref: -partition-after-pred52733 4832 Ref: -partition-before-pred53186 4833 Ref: -partition-before-item53571 4834 Ref: -partition-after-item53878 4835 Ref: -group-by54180 4836 Node: Indexing54613 4837 Ref: -elem-index54815 4838 Ref: -elem-indices55302 4839 Ref: -find-index55761 4840 Ref: -find-last-index56430 4841 Ref: -find-indices57081 4842 Ref: -grade-up57843 4843 Ref: -grade-down58250 4844 Node: Set operations58664 4845 Ref: -union58847 4846 Ref: -difference59277 4847 Ref: -intersection59705 4848 Ref: -powerset60134 4849 Ref: -permutations60411 4850 Ref: -distinct60849 4851 Ref: -same-items?61243 4852 Node: Other list operations61852 4853 Ref: -rotate62077 4854 Ref: -cons*62430 4855 Ref: -snoc62852 4856 Ref: -interpose63264 4857 Ref: -interleave63558 4858 Ref: -iota63924 4859 Ref: -zip-with64407 4860 Ref: -zip-pair65215 4861 Ref: -zip-lists65781 4862 Ref: -zip-lists-fill66579 4863 Ref: -zip67289 4864 Ref: -zip-fill68316 4865 Ref: -unzip-lists69230 4866 Ref: -unzip69853 4867 Ref: -pad70846 4868 Ref: -table71331 4869 Ref: -table-flat72117 4870 Ref: -first73122 4871 Ref: -last73655 4872 Ref: -first-item74001 4873 Ref: -second-item74413 4874 Ref: -third-item74830 4875 Ref: -fourth-item75205 4876 Ref: -fifth-item75583 4877 Ref: -last-item75958 4878 Ref: -butlast76319 4879 Ref: -sort76564 4880 Ref: -list77058 4881 Ref: -fix77627 4882 Node: Tree operations78116 4883 Ref: -tree-seq78312 4884 Ref: -tree-map79173 4885 Ref: -tree-map-nodes79613 4886 Ref: -tree-reduce80477 4887 Ref: -tree-reduce-from81359 4888 Ref: -tree-mapreduce81959 4889 Ref: -tree-mapreduce-from82818 4890 Ref: -clone84103 4891 Node: Threading macros84441 4892 Ref: ->84666 4893 Ref: ->>85154 4894 Ref: -->85657 4895 Ref: -as->86214 4896 Ref: -some->86668 4897 Ref: -some->>87053 4898 Ref: -some-->87500 4899 Ref: -doto88067 4900 Node: Binding88620 4901 Ref: -when-let88827 4902 Ref: -when-let*89288 4903 Ref: -if-let89817 4904 Ref: -if-let*90183 4905 Ref: -let90806 4906 Ref: -let*96896 4907 Ref: -lambda97833 4908 Ref: -setq98639 4909 Node: Side effects99440 4910 Ref: -each99634 4911 Ref: -each-while100161 4912 Ref: -each-indexed100781 4913 Ref: -each-r101373 4914 Ref: -each-r-while101815 4915 Ref: -dotimes102459 4916 Node: Destructive operations103012 4917 Ref: !cons103230 4918 Ref: !cdr103434 4919 Node: Function combinators103627 4920 Ref: -partial103831 4921 Ref: -rpartial104349 4922 Ref: -juxt104997 4923 Ref: -compose105449 4924 Ref: -applify106056 4925 Ref: -on106486 4926 Ref: -flip107258 4927 Ref: -rotate-args107782 4928 Ref: -const108411 4929 Ref: -cut108753 4930 Ref: -not109233 4931 Ref: -orfn109777 4932 Ref: -andfn110570 4933 Ref: -iteratefn111357 4934 Ref: -fixfn112059 4935 Ref: -prodfn113633 4936 Node: Development114784 4937 Node: Contribute115073 4938 Node: Contributors116085 4939 Node: FDL118178 4940 Node: GPL143498 4941 Node: Index181247 4942 4943 End Tag Table 4944 4945 4946 Local Variables: 4947 coding: utf-8 4948 End: