[racket] Is there a functional "array-set" for math/array?
If it already exists, I couldn't find it. There isn't a functional
'vector-set' either, and when I asked about it on IRC I was told that it
wasn't an easy fix to add an efficient implementation.
On Mon, Jul 14, 2014 at 7:19 PM, Alexander D. Knauth <alexander at knauth.org>
wrote:
> Is there a functional "array-set" for math/array?
>
> And if there isn’t, then would this be a good definition for it?:
> (: array-set : (All (a) [(Array a) In-Indexes a -> (Array a)]))
> (define (array-set arr update-pos val)
> ((inst build-array a)
> (array-shape arr)
> (lambda ([pos : Indexes])
> (cond [(equal? pos update-pos) val]
> [else (array-ref arr pos)]))))
>
>
>
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140715/87a70bf0/attachment.html>