empty intervals Alex Shinn (21 Apr 2022 11:02 UTC)
Re: empty intervals Bradley Lucier (21 Apr 2022 16:30 UTC)
Re: empty intervals Bradley Lucier (21 Apr 2022 16:37 UTC)
Re: empty intervals Per Bothner (21 Apr 2022 19:23 UTC)
Re: empty intervals Bradley Lucier (21 Apr 2022 21:59 UTC)
Re: empty intervals Per Bothner (21 Apr 2022 22:11 UTC)
Re: empty intervals Bradley Lucier (23 Apr 2022 17:56 UTC)
Re: empty intervals Per Bothner (23 Apr 2022 19:44 UTC)
Re: empty intervals Alex Shinn (24 Apr 2022 05:03 UTC)
Re: empty intervals John Cowan (21 Apr 2022 22:56 UTC)
Re: empty intervals Alex Shinn (22 Apr 2022 09:03 UTC)

Re: empty intervals Bradley Lucier 21 Apr 2022 16:37 UTC

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))))))