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)
syntax
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
(make-list k v)
k : exact-nonnegative-integer?
v : any/c
By default start is 0 and step is 1.
6.2 Transformers
syntax
syntax
(list-tail pos)
(drop pos)
pos : exact-nonnegative-integer?
syntax
(map proc)
proc : (-> any/c any/c)
syntax
(filter pred)
pred : (-> any/c any/c)
syntax
(remq v)
v : any/c
syntax
(remv v)
v : any/c
syntax
(remw v)
v : any/c
syntax
(remq* v)
v : any/c
syntax
(remv* v)
v : any/c
syntax
(remw* v)
v : any/c
syntax
syntax
syntax
syntax
syntax
(list-update pos updater)
pos : exact-nonnegative-integer?
updater : (-> any/c any/c)
syntax
(list-set pos value)
pos : exact-nonnegative-integer?
value : any/c
syntax
(indexes-of v is-equal?)
(indexes-of v)
v : any/c
is-equal? : (-> any/c any/c)
syntax
(indexes-where proc)
proc : (-> any/c any/c)
syntax
(take pos)
pos : exact-nonnegative-integer?
syntax
(takef pred)
pred : (-> any/c any/c)
syntax
(dropf pred)
pred : (-> any/c any/c)
syntax
(filter-map proc)
proc : (-> any/c any/c)
syntax
(filter-not pred)
pred : (-> any/c any/c)
syntax
(remf pred)
pred : (-> any/c any/c)
syntax
(remf* pred)
pred : (-> any/c any/c)
6.3 Consumers
syntax
syntax
syntax
syntax
syntax
(list-ref pos)
pos : exact-nonnegative-integer?
syntax
syntax
(foldl proc init)
proc : (-> any/c any/c any/c any/c)
init : any/c
syntax
(foldr proc init)
proc : (-> any/c any/c any/c any/c)
init : any/c
syntax
(findf proc)
proc : (-> any/c any/c)
syntax
(assw v)
v : any/c
syntax
(assv v)
v : any/c
syntax
(assq v)
v : any/c
syntax
(assf proc)
v : (-> any/c any/c)
syntax
syntax
syntax
syntax
syntax
syntax
(index-where proc)
proc : (-> any/c any/c)