Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
[[tags: egg]] == slib-arraymap [[toc:]] === Description A port of the [[http://people.csail.mit.edu/jaffer/SLIB|SLIB]] applicative routines for arrays library. For SLIB documentation see [[http://people.csail.mit.edu/jaffer/slib/Array-Mapping.html#Array-Mapping|arraymap]]. === Documentation ===== Usage <enscript language=scheme> (import slib-arraymap) </enscript> ===== array-map! <procedure>(array-map! ARR0 FUNC [ARR1 ...])</procedure> {{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</procedure> {{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 ...])</procedure> {{PROC}} is applied to each tuple of elements of {{ARR0, ...}} in row-major order. The value returned is unspecified. ===== array-fold <procedure>(array-fold PROC SEED [ARR0 ...]) -> *</procedure> {{PROC}} is applied to the {{SEED}} & each tuple of elements of {{ARR0 ...}} in row-major order. The value returned is the result of the repeated application of {{PROC}} to {{SEED}}. ; {{PROC}} : {{(* [* ...] -> *)}} ; {{SEEDi+1 <- (PROC SEEDi [ARR0i ...])}} ; {{SEED}} : {{*}} ; initial value ; {{ARR0 ...}} : {{array ...}} ; arrays to fold ===== array-indexes <procedure>(array-indexes ARR) -> array</procedure> 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)</procedure> 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 <enscript language=scheme> (define (array-index-map! ra fun) (array-index-for-each ra (lambda is (apply array-set! ra (apply fun is) is)))) </enscript> ===== array-index-map! <procedure>(array-index-map! ARR PROC)</procedure> 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 <enscript language=scheme> (define (array-indexes array) (let ((ra (apply make-array '#() (array-dimensions array)))) (array-index-map! ra (lambda x x)) ra)) </enscript> Another example: <enscript language=scheme> (define (apl:index-generator n) (let ((v (make-vector n 1))) (array-index-map! v (lambda (i) i)) v)) </enscript> ===== array:copy! <procedure>(array:copy! DST SRC)</procedure> 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</procedure> Returns a fresh copy of the vector or array source. The order of copying is unspecified. === Notes * {{array-fold}} & {{array-copy}} are not part of the the SLIB library. === Author Aubrey Jaffer === Maintainer [[/users/kon-lovett|Kon Lovett]] === Repository This egg is hosted on the CHICKEN Subversion repository: [[https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/slib-arraymap|https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/slib-arraymap]] If you want to check out the source code repository of this egg and you are not familiar with Subversion, see [[/egg-svn-checkout|this page]]. === Requirements [[srfi-63]] === Version history ; 1.1.0 : Add {{array-fold}}. ; 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.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you multiply 9 by 1?