]> gitweb.factorcode.org Git - factor.git/commitdiff
arrays.shaped: adding get words.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 5 Nov 2020 17:50:42 +0000 (09:50 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 5 Nov 2020 17:52:08 +0000 (09:52 -0800)
extra/arrays/shaped/shaped.factor

index 65fed31794a431f4cede303be1c12d53e818cc01..a4f554cb8b1c9559d2dbfb96c539448b97dbda82 100644 (file)
@@ -213,9 +213,15 @@ ERROR: shaped-bounds-error seq shape ;
 : calculate-column-major-index ( seq shape -- i )
     1 [ * ] accumulate nip vdot ;
 
+: get-shaped-row-major ( seq shaped -- elt )
+    shaped-bounds-check [ shape calculate-row-major-index ] [ underlying>> ] bi nth ;
+
 : set-shaped-row-major ( obj seq shaped -- )
     shaped-bounds-check [ shape calculate-row-major-index ] [ underlying>> ] bi set-nth ;
 
+: get-shaped-column-major ( seq shaped -- elt )
+    shaped-bounds-check [ shape calculate-column-major-index ] [ underlying>> ] bi nth ;
+
 : set-shaped-column-major ( obj seq shaped -- )
     shaped-bounds-check [ shape calculate-column-major-index ] [ underlying>> ] bi set-nth ;