On this page:
6.1 Producers
range
6.2 Transformers
filter
map
filter-map
take
6.3 Consumers
foldl
foldr
car
cadr
caddr
cadddr
list-ref
length
empty?
null?

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

(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

(filter pred)

 
  pred : (-> any/c any/c)
Deforestable version of filter 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-map proc)

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

syntax

(take pos)

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

6.3 Consumers🔗

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

car

Deforestable version of car 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

(list-ref pos)

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

syntax

length

Deforestable version of length from racket/base.

syntax

empty?

Deforestable version of empty? from racket/list.

syntax

null?

Deforestable version of null? from racket/base.