Next: , Previous: , Up: dynamic arrays   [Index]


40.4 Folding over dynamic-arrays

The following syntactic bindings are exported by the library (vicare containers dynamic-arrays). The syntactic bindings whose name is prefixed with $ are unsafe operations: they do not validate their arguments before accessing them.

Function: dynamic-array-fold-left kons knil arry
Function: $dynamic-array-fold-left kons knil arry

Analogous to fold-left for lists. Fold the procedure kons over the objects from arry, starting from the front.

(define D
  (dynamic-array 0 1 2 3 4 5))

(dynamic-array-fold-left
    (lambda (knil obj)
      (cons obj knil))
  '() D)
⇒ (5 4 3 2 1 0)
Function: dynamic-array-fold-right kons knil arry
Function: $dynamic-array-fold-right kons knil arry

Analogous to fold-right for lists. Fold the procedure kons over the objects from arry, starting from the rear.

(define D
  (dynamic-array 0 1 2 3 4 5))

(dynamic-array-fold-right
    (lambda (obj knil)
      (cons obj knil))
  '() D)
⇒ (0 1 2 3 4 5)