apl: at @ replace+apply (+10 tests, 211/211)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
This commit is contained in:
@@ -1108,3 +1108,47 @@
|
||||
(make-array
|
||||
(append frame-shape (get (first results) :shape))
|
||||
(flatten (map (fn (r) (get r :ravel)) results))))))))))))
|
||||
|
||||
(define
|
||||
apl-at-replace
|
||||
(fn
|
||||
(vals idxs arr)
|
||||
(let
|
||||
((vals-ravel (get vals :ravel))
|
||||
(idxs-ravel (get idxs :ravel))
|
||||
(arr-ravel (get arr :ravel))
|
||||
(arr-shape (get arr :shape))
|
||||
(vals-scalar? (= (len (get vals :shape)) 0)))
|
||||
(make-array
|
||||
arr-shape
|
||||
(map
|
||||
(fn
|
||||
(i)
|
||||
(let
|
||||
((pos (index-of idxs-ravel (+ i apl-io))))
|
||||
(if
|
||||
pos
|
||||
(if vals-scalar? (first vals-ravel) (nth vals-ravel pos))
|
||||
(nth arr-ravel i))))
|
||||
(range 0 (len arr-ravel)))))))
|
||||
|
||||
(define
|
||||
apl-at-apply
|
||||
(fn
|
||||
(f idxs arr)
|
||||
(let
|
||||
((idxs-ravel (get idxs :ravel))
|
||||
(arr-ravel (get arr :ravel))
|
||||
(arr-shape (get arr :shape)))
|
||||
(make-array
|
||||
arr-shape
|
||||
(map
|
||||
(fn
|
||||
(i)
|
||||
(let
|
||||
((pos (index-of idxs-ravel (+ i apl-io))))
|
||||
(if
|
||||
pos
|
||||
(disclose (f (apl-scalar (nth arr-ravel i))))
|
||||
(nth arr-ravel i))))
|
||||
(range 0 (len arr-ravel)))))))
|
||||
|
||||
Reference in New Issue
Block a user