On 4/21/22 12:30 PM, Bradley Lucier wrote:
> I agree that this case would be simplified with empty arrays with the
> right semantics. Here's a routine I came up with:
>
> (define (array-with-column array col vals)
> (let ((columns
> (array->list
> (array-curry
> (array-permute array '#(1 0))
> 1))))
> (apply array-stack
> 1
> (append (take col columns)
> (specialized-array-reshape vals (array-domain (car
> columns)))
> (drop (+ col 1) columns)))))
>
Should have tested, try this:
(define (array-with-column array col vals)
(let ((columns
(array->list
(array-curry
(array-permute array (index-first 2 1))
1))))
(array-stack
1
(append (take columns col)
(list (specialized-array-reshape vals (array-domain (car
columns))))
(drop columns (+ col 1))))))