11 Lists
(require unstable/list) |
This library is unstable; compatibility will not be maintained. See Unstable for more information.
(list-prefix? l r) → boolean? |
l : list? |
r : list? |
Example: |
> (list-prefix? '(1 2) '(1 2 3 4 5)) |
#t |
The subsequent bindings were added by Sam Tobin-Hochstadt.
| ||||||||
l : list? | ||||||||
f : procedure? |
Example: |
> (filter-multiple (list 1 2 3 4 5) even? odd?) |
'(2 4) |
'(1 3 5) |
Example: |
> (extend '(1 2 3) '(a) 'b) |
'(a b b) |
The subsequent bindings were added by Ryan Culpepper.
| |||||||||||||||||||||
lst : list? | |||||||||||||||||||||
extract-key : (-> any/c any/c) = (lambda (x) x) | |||||||||||||||||||||
|
The same? argument can either be an equivalence predicate such as equal? or eqv? or a dictionary. In the latter case, the elements of the list are mapped to #t in the dictionary until an element is discovered that is already mapped to a true value. The procedures equal?, eqv?, and eq? automatically use a dictionary for speed.
Examples: | ||
> (check-duplicate '(1 2 3 4)) | ||
#f | ||
> (check-duplicate '(1 2 3 2 1)) | ||
2 | ||
> (check-duplicate '((a 1) (b 2) (a 3)) #:key car) | ||
'(a 3) | ||
> (define id-t (make-free-id-table)) | ||
| ||
#<syntax:10:0 a> | ||
> (dict-map id-t list) | ||
'((#<syntax:10:0 d> #t) (#<syntax:10:0 a> #t) (#<syntax:10:0 c> #t) (#<syntax:10:0 b> #t)) |
The subsequent bindings were added by Carl Eastlund.
| ||||||||||
n : natural-number/c | ||||||||||
f : (-> A ... (values B_1 ... B_n)) | ||||||||||
lst : (listof A) |
Example: | |||||
| |||||
'(2 3 4) | |||||
'(1 2 3) | |||||
'(0 1 2) |
The subsequent bindings were added by David Van Horn.
(remf pred lst) → list? |
pred : procedure? |
lst : list? |
Example: |
> (remf negative? '(1 -2 3 4 -5)) |
'(1 3 4 -5) |