5 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? |
True if l is a prefix of r.
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) | |||||||||||||||||||||
|
Returns the first duplicate item in lst. More precisely, it
returns the first x such that there was a previous
y where (same? (extract-key x) (extract-key y)).
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 a> #t) (#<syntax:10:0 d> #t) (#<syntax:10:0 c> #t) (#<syntax:10:0 b> #t)) |