treelist-util
treelist*
build-treelist
treelist-andmap
treelist-ormap
treelist-foldl
treelist-foldr
treelist-remove
treelist-remq
treelist-remv
treelist-remw
treelist-remf
treelist-remove*
treelist-remq*
treelist-remv*
treelist-remw*
treelist-second
treelist-third
treelist-fourth
treelist-fifth
treelist-sixth
treelist-seventh
treelist-eighth
treelist-ninth
treelist-tenth
treelist-eleventh
treelist-twelfth
treelist-thirteenth
treelist-fourteenth
treelist-fifteenth
treelist-update
treelist-index-where
treelist-indexes-of
treelist-indexes-where
treelist-split
treelist-takef
treelist-dropf
treelist-splitf
treelist-take-right
treelist-drop-right
treelist-split-right
treelist-takef-right
treelist-dropf-right
treelist-splitf-right
treelist-prefix?
treelist-take-common-prefix
treelist-drop-common-prefix
treelist-split-common-prefix
treelist-add-between
treelist-check-duplicates
treelist-remove-duplicates
treelist-filter-map
treelist-count
treelist-partition
treelist-range
treelist-inclusive-range
treelist-append-map
treelist-filter-not
treelist-argmin
treelist-argmax
treelist-group-by
treelist-cartesian-product
treelist-cartesian-product*
8.16.0.1

treelist-util🔗ℹ

Alex Knauth

 (require treelist-util) package: treelist-util

Treelist operations matching racket/list that aren’t in racket/treelist.

procedure

(treelist* v ... tl)  treelist?

  v : any/c
  tl : treelist?

procedure

(build-treelist n proc)  treelist?

  n : exact-nonnegative-integer?
  proc : (-> exact-nonnegative-integer? any/c)

procedure

(treelist-andmap proc tl ...+)  any/c

  proc : procedure?
  tl : treelist?

procedure

(treelist-ormap proc tl ...+)  any/c

  proc : procedure?
  tl : treelist?

procedure

(treelist-foldl proc init tl ...+)  any/c

  proc : procedure?
  init : any/c
  tl : treelist?

procedure

(treelist-foldr proc init tl ...+)  any/c

  proc : procedure?
  init : any/c
  tl : treelist?

procedure

(treelist-remove v tl [eql?])  treelist?

  v : any/c
  tl : treelist?
  eql? : (-> any/c any/c any/c) = equal?

procedure

(treelist-remq v tl)  treelist?

  v : any/c
  tl : treelist?

procedure

(treelist-remv v tl)  treelist?

  v : any/c
  tl : treelist?

procedure

(treelist-remw v tl)  treelist?

  v : any/c
  tl : treelist?

procedure

(treelist-remf pred tl)  treelist?

  pred : (-> any/c any/c)
  tl : treelist?

procedure

(treelist-remove* vs tl [eql?])  treelist?

  vs : treelist?
  tl : treelist?
  eql? : (-> any/c any/c any/c) = equal?

procedure

(treelist-remq* vs tl)  treelist?

  vs : treelist?
  tl : treelist?

procedure

(treelist-remv* vs tl)  treelist?

  vs : treelist?
  tl : treelist?

procedure

(treelist-remw* vs tl)  treelist?

  vs : treelist?
  tl : treelist?

procedure

(treelist-second tl)  any/c

  tl : treelist?

procedure

(treelist-third tl)  any/c

  tl : treelist?

procedure

(treelist-fourth tl)  any/c

  tl : treelist?

procedure

(treelist-fifth tl)  any/c

  tl : treelist?

procedure

(treelist-sixth tl)  any/c

  tl : treelist?

procedure

(treelist-seventh tl)  any/c

  tl : treelist?

procedure

(treelist-eighth tl)  any/c

  tl : treelist?

procedure

(treelist-ninth tl)  any/c

  tl : treelist?

procedure

(treelist-tenth tl)  any/c

  tl : treelist?

procedure

(treelist-eleventh tl)  any/c

  tl : treelist?

procedure

(treelist-twelfth tl)  any/c

  tl : treelist?

procedure

(treelist-thirteenth tl)  any/c

  tl : treelist?

procedure

(treelist-fourteenth tl)  any/c

  tl : treelist?

procedure

(treelist-fifteenth tl)  any/c

  tl : treelist?

procedure

(treelist-update tl pos updater)  treelist?

  tl : treelist?
  pos : exact-nonnegative-integer?
  updater : (-> any/c any/c)
Operations similar to their counterparts from racket/list.

procedure

(treelist-index-where tl pred)

  (or/c exact-nonnegative-integer? #f)
  tl : treelist?
  pred : (-> any/c any/c)
Returns the index of the first element in tl where applying pred to the element produces a true value. If no such element is found, the result is #f.

Examples:
> (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)
Operations similar to their counterparts from racket/list.

procedure

(treelist-splitf tl pred)  
treelist? treelist?
  tl : treelist?
  pred : (-> any/c any/c)
Splits tl into 2 treelists returned as values. The first treelist contains elements taken successivly from tl as long as they satisfy pred. The second treelist the rest of the elements of tl, from the first element not satisfying pred and onward.

Examples:
> (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?
Operations similar to their counterparts from racket/list.

procedure

(treelist-cartesian-product tl ...)  (treelist/c treelist?)

  tl : treelist?

procedure

(treelist-cartesian-product* tls)  (treelist/c treelist?)

  tls : (treelist/c treelist?)
Computes the n-ary cartesian product of the given treelists.

Examples:
> (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))