racket/collects/math/private/array/mutable-array.rkt
Neil Toronto b8efd58aca Array changes in response to user feedback (and my personal neuroses)
* `list->array' now accepts an optional shape argument, and always returns
  an immutable array

* `vector->array' now accepts an optional shape argument, and always
  returns a mutable array

* Removed `make-mutable-array' because `vector->array' does its job now (I
  never liked the name anyway)

* Renamed `unsafe-mutable-array' to `unsafe-vector->array'

* Added optional type annotation to `array' macro to match `mutable-array'

* Reworded error messages in array broadcasting functions

* Made minor array doc fixes
2012-12-17 15:54:29 -07:00

36 lines
1.0 KiB
Racket

#lang racket/base
(require typed/untyped-utils
typed/racket/base
(for-syntax racket/base syntax/parse)
"array-syntax.rkt"
(except-in "typed-mutable-array.rkt"
vector->array))
(require/untyped-contract
(begin (require "typed-mutable-array.rkt"))
"typed-mutable-array.rkt"
[vector->array (All (A) (case-> ((Vectorof A) -> (Mutable-Array A))
((Vectorof Integer) (Vectorof A) -> (Mutable-Array A))))])
(provide
;; Mutable-Array
Mutable-Array
mutable-array?
mutable-array-data
vector->array
unsafe-vector->array
mutable-array-copy
mutable-array
;; Conversion
array->mutable-array
flat-vector->matrix)
(define-syntax (mutable-array stx)
(syntax-parse stx #:literals (:)
[(_ e:expr)
(syntax/loc stx (array/syntax mutable-array vector unsafe-vector->array e))]
[(_ e:expr : T:expr)
(syntax/loc stx (array/syntax mutable-array (inst vector T) unsafe-vector->array e))]
[_:id (raise-syntax-error 'mutable-array "not allowed as an expression" stx)]))