You are looking at historical revision 38396 of this page. It may differ significantly from its current revision.

slib-arraymap

Description

A port of the SLIB applicative routines for arrays library. For SLIB documentation see arraymap.

Documentation

Usage
(import slib-arraymap)
array-map!
[procedure] (array-map! ARR0 FUNC [ARR1 ...])

ARR1 ... must have the same number of dimensions as ARR0 and have a range for each index which includes the range for the corresponding index in ARR0. {FUNC}} is applied to each tuple of elements of ARR1 ... and the result is stored as the corresponding element in ARR0. The value returned is unspecified. The order of application is unspecified.

array-map
[procedure] (array-map PROTO FUNC [ARR1 ARR2 ...]) -> array

ARR2 ... must have the same number of dimensions as ARR1 and have a range for each index which includes the range for the corresponding index in ARR1. proc is applied to each tuple of elements of ARR1 ARR2 ... and the result is stored as the corresponding element in a new array of type prototype. The new array is returned. The order of application is unspecified.

array-for-each
[procedure] (array-for-each PROC [ARR0 ...])

PROC is applied to each tuple of elements of ARR0 ... in row-major order. The value returned is unspecified.

array-indexes
[procedure] (array-indexes ARR) -> array

Returns an array of lists of indexes for ARR such that, if LI is a list of indexes for which ARR is defined, (equal? LI (apply array-ref (array-indexes ARR) LI)).

array-index-for-each
[procedure] (array-index-for-each ARR PROC)

Applies proc to the indices of each element of array in turn. The value returned and the order of application are unspecified.

One can implement array-index-map! as

(define (array-index-map! ra fun)
  (array-index-for-each
    ra
    (lambda is (apply array-set! ra (apply fun is) is))))
array-index-map!
[procedure] (array-index-map! ARR PROC)

Applies proc to the indices of each element of array in turn, storing the result in the corresponding element. The value returned and the order of application are unspecified.

One can implement array-indexes as

(define (array-indexes array)
  (let ((ra (apply make-array '#() (array-dimensions array))))
    (array-index-map! ra (lambda x x))
    ra))

Another example:

(define (apl:index-generator n)
  (let ((v (make-vector n 1)))
    (array-index-map! v (lambda (i) i))
    v))
array:copy!
[procedure] (array:copy! DST SRC)

Copies every element from vector or array SRC to the corresponding element of DST. DST must have the same rank as SRC, and be at least as large in each dimension. The order of copying is unspecified.

array-copy
[procedure] (array-copy SRC) -> array

Returns a fresh copy of the vector or array source. The order of copying is unspecified.

Author

Aubrey Jaffer

Maintainer

Kon Lovett

Requirements

srfi-63

Version history

1.0.0
C5 release.

License

Copyright (C) 1993, 2003 Aubrey Jaffer

Permission to copy this software, to modify it, to redistribute it, to distribute modified versions, and to use it for any purpose is granted, subject to the following restrictions and understandings.

1. Any copy made of this software must include this copyright notice in full.

2. I have made no warranty or representation that the operation of this software will be error-free, and I am under no obligation to provide any services, by way of maintenance, update, or otherwise.

3. In conjunction with products arising from the use of this material, there shall be no use of my name in any advertising, promotional, or sales literature without prior written consent in each case.