On this page:
6.1 Producers
build-list
append
make-list
range
6.2 Transformers
cdr
list-tail
map
filter
remove
remq
remv
remw
remove*
remq*
remv*
remw*
cddr
cdddr
cddddr
rest
list-update
list-set
indexes-of
indexes-where
take
takef
dropf
filter-map
filter-not
remf
remf*
6.3 Consumers
pair?
null?
car
length
list-ref
reverse
foldl
foldr
findf
assoc
assw
assv
assq
assf
cadr
caddr
cadddr
cons?
empty?
index-of
index-where
argmin
argmax

6 List Operations🔗

 (require qi/list) package: qi-lib

This module defines functional list operations analogous to those in racket/base and racket/list, except that these forms support flows in higher-order function positions and leverage the stream fusion / deforestation optimization to avoid constructing intermediate representations along the way to computing the result.

The forms in this module extend the syntax of the core Qi language. This extended syntax is given below:

  floe = (map floe)
  | (filter floe)
  | (filter-map floe)
  | (foldl floe expr)
  | (foldr floe expr)
  | (range expr)
  | (range expr expr)
  | (range expr expr expr)
  | (take expr)
  | (filter-not floe)
  | (list-tail expr)
  | (drop expr)
  | rest
  | cdr
  | cddr
  | cdddr
  | cddddr
  | cdddddr
  | car
  | cadr
  | caddr
  | cadddr
  | (list-ref expr)
  | length
  | empty?
  | null?

The operations are categorized based on their role in the deforested pipeline.

6.1 Producers🔗

syntax

(build-list n proc)

 
  n : exact-nonnegative-integer?
  proc : (-> exact-nonnegative-integer? any/c)
Deforestable version of build-list from racket/base.

syntax

append

Currently the lists provided as arguments are passed first and only after them the lists from the upstream flow are added. Therefore the (possibly non-list) tail must be a flowed-in value if any lists are coming from upstream.

syntax

(append lst ...)

 
  lst : list?
Deforestable version of append from racket/base.

syntax

(make-list k v)

 
  k : exact-nonnegative-integer?
  v : any/c
Deforestable version of make-list from racket/list.

syntax

(range end)

(range start end)
(range start end step)
 
  start : real?
  end : real?
  step : real?
Deforestable version of range from racket/list.

By default start is 0 and step is 1.

6.2 Transformers🔗

syntax

cdr

Deforestable version of cdr from racket/base.

syntax

(list-tail pos)

(drop pos)
 
  pos : exact-nonnegative-integer?
Deforestable version of list-tail/drop from racket/base.

syntax

(map proc)

 
  proc : (-> any/c any/c)
Deforestable version of map from racket/base. Note that, unlike the Racket version, this accepts only one argument. For the "zip"-like behavior with multiple list inputs, see .

syntax

(filter pred)

 
  pred : (-> any/c any/c)
Deforestable version of filter from racket/base.

syntax

(remove v)

(remove v proc)
 
  v : any/c
  proc : (-> any/c any/c)
Deforestable version of remove from racket/base.

syntax

(remq v)

 
  v : any/c
Deforestable version of remq from racket/base.

syntax

(remv v)

 
  v : any/c
Deforestable version of remv from racket/base.

syntax

(remw v)

 
  v : any/c
Deforestable version of remw from racket/base.

syntax

(remove* v)

(remove* v proc)
 
  v : any/c
  proc : (-> any/c any/c)
Deforestable version of remove* from racket/base.

syntax

(remq* v)

 
  v : any/c
Deforestable version of remq* from racket/base.

syntax

(remv* v)

 
  v : any/c
Deforestable version of remv* from racket/base.

syntax

(remw* v)

 
  v : any/c
Deforestable version of remw* from racket/base.

syntax

cddr

Deforestable version of cddr from racket/base.

syntax

cdddr

Deforestable version of cdddr from racket/base.

syntax

cddddr

Deforestable version of cddddr from racket/base.

syntax

rest

Deforestable version of rest from racket/list.

syntax

(list-update pos updater)

 
  pos : exact-nonnegative-integer?
  updater : (-> any/c any/c)
Deforestable version of list-update from racket/list.

syntax

(list-set pos value)

 
  pos : exact-nonnegative-integer?
  value : any/c
Deforestable version of list-set from racket/list.

syntax

(indexes-of v is-equal?)

(indexes-of v)
 
  v : any/c
  is-equal? : (-> any/c any/c)
Deforestable version of indexes-of from racket/list.

syntax

(indexes-where proc)

 
  proc : (-> any/c any/c)
Deforestable version of indexes-where from racket/list.

syntax

(take pos)

 
  pos : exact-nonnegative-integer?
Deforestable version of take from racket/list.

syntax

(takef pred)

 
  pred : (-> any/c any/c)
Deforestable version of takef from racket/list.

syntax

(dropf pred)

 
  pred : (-> any/c any/c)
Deforestable version of dropf from racket/list.

syntax

(filter-map proc)

 
  proc : (-> any/c any/c)
Deforestable version of filter-map from racket/list.

syntax

(filter-not pred)

 
  pred : (-> any/c any/c)
Deforestable version of filter-not from racket/list.

syntax

(remf pred)

 
  pred : (-> any/c any/c)
Deforestable version of remf from racket/list.

syntax

(remf* pred)

 
  pred : (-> any/c any/c)
Deforestable version of remf* from racket/list.

6.3 Consumers🔗

syntax

pair?

Deforestable version of pair? from racket/base.

syntax

null?

Deforestable version of null? from racket/base.

syntax

car

Deforestable version of car from racket/base.

syntax

length

Deforestable version of length from racket/base.

syntax

(list-ref pos)

 
  pos : exact-nonnegative-integer?
Deforestable version of list-ref from racket/base.

syntax

reverse

Deforestable version of reverse from racket/base.

syntax

(foldl proc init)

 
  proc : (-> any/c any/c any/c any/c)
  init : any/c
Deforestable version of foldl from racket/base.

syntax

(foldr proc init)

 
  proc : (-> any/c any/c any/c any/c)
  init : any/c
Deforestable version of foldr from racket/base.

syntax

(findf proc)

 
  proc : (-> any/c any/c)
Deforestable version of findf from racket/base.

syntax

(assoc v)

(assoc v is-equal?)
 
  v : any/c
  is-equal? : (-> any/c any/c)
Deforestable version of assoc from racket/base.

syntax

(assw v)

 
  v : any/c
Deforestable version of assw from racket/base.

syntax

(assv v)

 
  v : any/c
Deforestable version of assv from racket/base.

syntax

(assq v)

 
  v : any/c
Deforestable version of assq from racket/base.

syntax

(assf proc)

 
  v : (-> any/c any/c)
Deforestable version of assf from racket/base.

syntax

cadr

Deforestable version of cadr from racket/base.

syntax

caddr

Deforestable version of caddr from racket/base.

syntax

cadddr

Deforestable version of cadddr from racket/base.

syntax

cons?

Deforestable version of cons? from racket/list.

syntax

empty?

Deforestable version of empty? from racket/list.

syntax

(index-of v)

(index-of v is-equal?)
 
  v : any/c
  is-equal? : (-> any/c any/c)
Deforestable version of index-of from racket/list.

syntax

(index-where proc)

 
  proc : (-> any/c any/c)
Deforestable version of index-where from racket/list.

syntax

(argmin proc)

 
  proc : (-> any/c real?)
Deforestable version of argmin from racket/list.

syntax

(argmax proc)

 
  proc : (-> any/c real?)
Deforestable version of argmax from racket/list.