[racket] Interesting article

From: Noel Welsh (noelwelsh at gmail.com)
Date: Thu Aug 12 09:42:09 EDT 2010

I agree with most of his gripes. Addressing his points about vectors,
I have a fairly extensive library of vectors functions on github

  http://github.com/noelwelsh/numeric

It has the same API for vector, evector [extensible vector], and
f64vector. It could easily be extended to flvector but I haven't yet
had the need/time. (Nor the time to properly package it.) I regularly
write numeric algorithms (e.g. discrete cosine transform, which I
wrote yesterday) in a functional system using this library.

The code is written using a compile-time unit system, which is well
...err... something.

API is below in case anyone is interested.

N.

(define-comprehensions
  (import 'vector
          'in-vector
          make-vector
          vector?
          vector-ref
          vector-set!
          vector-length)
  (export for/vector
          for/fold/vector
          _
          in-vector-reverse))

;;; Constructors

(define-constructors
  (import make-vector
          for/vector
          in-vector
          vector-length)
  (export vector-ones
          vector-zeros
          vector-copy
          vector-reverse))

;;; Predicates

(define-predicates
  (import in-vector vector-length)
  (export vector-null? vector-=))

;;; Selectors

(define-selectors
  (import for/vector for/fold/vector in-vector vector-ref
vector-length list->vector)
  (export vector-select
          vector-last
          vector-find vector-findi
          vector-find-first vector-find-firsti
          vector-slice))

;;; Mutators

(define-mutators
  (import vector-ref vector-set!)
  (export vector-add1! vector-sub1!))

;;; Iterators

(define-iterators
  (import for/fold/vector for/vector
          in-vector
          vector-length)
  (export vector-map vector-mapi
          vector-fold vector-foldi))

;;; General Functions

(define-functions
  (import for/vector
          in-vector
          vector-set!
          vector-ref
          vector-length
          vector-find-firsti)
  (export vector* vector+ vector/ vector-
          vector*s vector/s vector+s vector-s
          vector-sum vector-product
          vector-dot
          vector-normalise
          vector-max vector-maxi vector-min vector-mini
          vector-adjoin vector-append
          vector-remove vector-remove-first vector-removei))


Posted on the users mailing list.