From e2b07a5fd0bbaad232c717fb90a31d6c61d72bd4 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 14 Jul 2022 20:06:50 -0400 Subject: Try to include previous variable definitions in REPL links --- docs/doc/fold.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/doc/fold.html') diff --git a/docs/doc/fold.html b/docs/doc/fold.html index 5b024ff4..d59caf97 100644 --- a/docs/doc/fold.html +++ b/docs/doc/fold.html @@ -195,7 +195,7 @@ ⟨ 9 7 12 ⟩

The Insert (˝) modifier will do this for you. And because it works on the leading axis of the argument, Insert can be applied to axes other than the first with Rank. Sum each row (second axis) with Cells (˘), for example.

-↗️
    +˝˘ tab
+↗️
    +˝˘ tab
 ⟨ 2 3 6 5 12 ⟩
 

This case is tricky, because +´˘ tab yields the same result but is actually unsound—if tab contains arrays then they will be merged together at the end. Remember: if you want to reduce along one axis of an array and get an array of results out, you should use Insert (possibly adding Each to work on elements instead of cells; see APL2 reduction below).

@@ -243,7 +243,7 @@

As a historical note, Insert is named after J's adverb /, which comes from SHARP APL's , reduce-down. In the original APL, only arithmetic reductions were defined, and nested arrays didn't exist—arrays were either all characters or all numbers. SHARP extended them by splitting the array into cells as we've shown. However, there's another interpretation, which is what you'll find in mainstream APLs today…

APL2 reduction?

The function ⍪⌿ in Dyalog APL gives very different results from BQN's ˝. Instead of combining the cells like we see above, APL applies the function on pairs of elements much like Fold. The difference is that, because reduction happens only along one axis but an array might have other axes, there can be multiple values in the result, so that it will always be an array like the argument. BQN can perform this operation as well: ⍪⌿ is written ¨˝ in BQN (but please use <˘ instead).

-↗️
    tab
+↗️
    tab
 ┌─       
 ╵ 1 0 1  
   0 1 2  
-- 
cgit v1.2.3