treelist-util
(require treelist-util) | package: treelist-util |
Treelist operations matching racket/list that aren’t in racket/treelist.
procedure
(treelist-index-where tl pred)
→ (or/c exact-nonnegative-integer? #f) tl : treelist? pred : (-> any/c any/c)
> (define items (treelist 1 "a" 'apple)) > (treelist-index-where items number?) 0
> (treelist-index-where items string?) 1
> (treelist-index-where items symbol?) 2
> (treelist-index-where items void?) #f
procedure
(treelist-indexes-of tl v [eql?])
→ (treelist/c exact-nonnegative-integer?) tl : treelist? v : any/c eql? : (-> any/c any/c any/c) = equal?
procedure
(treelist-indexes-where tl pred)
→ (treelist/c exact-nonnegative-integer?) tl : treelist? pred : (-> any/c any/c)
procedure
(treelist-split tl pos) →
treelist? treelist? tl : treelist? pos : exact-nonnegative-integer?
procedure
(treelist-takef tl pred) → treelist?
tl : treelist? pred : (-> any/c any/c)
procedure
(treelist-dropf tl pred) → treelist?
tl : treelist? pred : (-> any/c any/c)
> (treelist-splitf (treelist 2 4 5 8) even?)
(treelist 2 4)
(treelist 5 8)
> (treelist-splitf (treelist 2 4 5 8) odd?)
(treelist)
(treelist 2 4 5 8)
> (treelist-splitf (treelist 2 4 6 8) even?)
(treelist 2 4 6 8)
(treelist)
> (treelist-splitf (treelist 2 4 6 8) odd?)
(treelist)
(treelist 2 4 6 8)
procedure
(treelist-take-right tl pos) → treelist?
tl : treelist? pos : exact-nonnegative-integer?
procedure
(treelist-drop-right tl pos) → treelist?
tl : treelist? pos : exact-nonnegative-integer?
procedure
(treelist-split-right tl pos) →
treelist? treelist? tl : treelist? pos : exact-nonnegative-integer?
procedure
(treelist-takef-right tl pred) → treelist?
tl : treelist? pred : (-> any/c any/c)
procedure
(treelist-dropf-right tl pred) → treelist?
tl : treelist? pred : (-> any/c any/c)
procedure
(treelist-splitf-right tl pred) → treelist?
tl : treelist? pred : (-> any/c any/c)
procedure
(treelist-prefix? pre tl [eql?]) → treelist?
pre : treelist? tl : treelist? eql? : (-> any/c any/c any/c) = equal?
procedure
(treelist-take-common-prefix l r [eql?]) → treelist?
l : treelist? r : treelist? eql? : (-> any/c any/c any/c) = equal?
procedure
(treelist-drop-common-prefix l r [eql?]) →
treelist? treelist? l : treelist? r : treelist? eql? : (-> any/c any/c any/c) = equal?
procedure
(treelist-split-common-prefix l r [eql?])
→
treelist? treelist? treelist? l : treelist? r : treelist? eql? : (-> any/c any/c any/c) = equal?
procedure
(treelist-add-between tl v [ #:before-first before-first #:before-last before-last #:after-last after-last] #:splice? splice?) → treelist? tl : treelist? v : any/c before-first : treelist? = empty-treelist before-last : any/c = v after-last : treelist? = empty-treelist splice? : #false
procedure
(treelist-check-duplicates tl [ eql?] #:key extract-key [ #:default failure-result]) → any/c tl : treelist? eql? : (-> any/c any/c any/c) = equal? extract-key : (λ (x) x) failure-result : failure-result/c = (λ () #false)
procedure
(treelist-remove-duplicates tl [ eql?] #:key extract-key) → treelist? tl : treelist? eql? : (-> any/c any/c any/c) = equal? extract-key : (λ (x) x)
procedure
(treelist-filter-map proc tl ...+) → treelist?
proc : procedure? tl : treelist?
procedure
(treelist-count proc tl ...+) → treelist?
proc : procedure? tl : treelist?
procedure
(treelist-partition pred tl) →
treelist? treelist? pred : (-> any/c any/c) tl : treelist?
procedure
(treelist-range end) → treelist?
end : real? (treelist-range start end [step]) → treelist? start : real? end : real? step : real? = 1
procedure
(treelist-inclusive-range start end [step]) → treelist?
start : real? end : real? step : real? = 1
procedure
(treelist-append-map proc tl ...+) → treelist?
proc : procedure? tl : treelist?
procedure
(treelist-filter-not pred tl) → treelist?
pred : (-> any/c any/c) tl : treelist?
procedure
(treelist-argmin proc tl) → any/c
proc : (-> any/c real?) tl : treelist?
procedure
(treelist-argmax proc tl) → any/c
proc : (-> any/c real?) tl : treelist?
procedure
(treelist-group-by key tl [eql?]) → (treelist/c treelist?)
key : (-> any/c any/c) tl : treelist? eql? : (-> any/c any/c any/c) = equal?
procedure
(treelist-cartesian-product tl ...) → (treelist/c treelist?)
tl : treelist?
procedure
(treelist-cartesian-product* tls) → (treelist/c treelist?)
tls : (treelist/c treelist?)
> (treelist-cartesian-product (treelist 1 2 3) (treelist 'a 'b 'c))
(treelist
(treelist 1 'a)
(treelist 1 'b)
(treelist 1 'c)
(treelist 2 'a)
(treelist 2 'b)
(treelist 2 'c)
(treelist 3 'a)
(treelist 3 'b)
(treelist 3 'c))
> (treelist-cartesian-product* (treelist (treelist 1 2 3) (treelist 'a 'b 'c)))
(treelist
(treelist 1 'a)
(treelist 1 'b)
(treelist 1 'c)
(treelist 2 'a)
(treelist 2 'b)
(treelist 2 'c)
(treelist 3 'a)
(treelist 3 'b)
(treelist 3 'c))
> (treelist-cartesian-product (treelist 4 5 6) (treelist 'd 'e 'f) (treelist #t #f))
(treelist
(treelist 4 'd #t)
(treelist 4 'd #f)
(treelist 4 'e #t)
(treelist 4 'e #f)
(treelist 4 'f #t)
(treelist 4 'f #f)
(treelist 5 'd #t)
(treelist 5 'd #f)
(treelist 5 'e #t)
(treelist 5 'e #f)
(treelist 5 'f #t)
(treelist 5 'f #f)
(treelist 6 'd #t)
(treelist 6 'd #f)
(treelist 6 'e #t)
(treelist 6 'e #f)
(treelist 6 'f #t)
(treelist 6 'f #f))
> (treelist-cartesian-product* (treelist (treelist 4 5 6) (treelist 'd 'e 'f) (treelist #t #f)))
(treelist
(treelist 4 'd #t)
(treelist 4 'd #f)
(treelist 4 'e #t)
(treelist 4 'e #f)
(treelist 4 'f #t)
(treelist 4 'f #f)
(treelist 5 'd #t)
(treelist 5 'd #f)
(treelist 5 'e #t)
(treelist 5 'e #f)
(treelist 5 'f #t)
(treelist 5 'f #f)
(treelist 6 'd #t)
(treelist 6 'd #f)
(treelist 6 'e #t)
(treelist 6 'e #f)
(treelist 6 'f #t)
(treelist 6 'f #f))