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))