diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-12-26 21:39:37 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-12-26 21:39:37 -0500 |
| commit | 44ed8888851bce05cf2aa181ed258e0a550499d0 (patch) | |
| tree | 26d4d71d62cb882bd8421475ea1827b8ceedf404 /commentary/problems.md | |
| parent | 847cba5681f7692f78a9f66e04c0ef84f88d0197 (diff) | |
Mention ⌾(<˘) for reshaping first axis only
Diffstat (limited to 'commentary/problems.md')
| -rw-r--r-- | commentary/problems.md | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/commentary/problems.md b/commentary/problems.md index 451041b9..fc5b160b 100644 --- a/commentary/problems.md +++ b/commentary/problems.md @@ -97,7 +97,7 @@ So it seems a bit strange to rely on it for core language features like `/⁼`. It's an awkward inconsistency. Prefixes and Suffixes have to have a nested result, but Windows doesn't have to be flat; it's just that making it nested ignores the fact that it does have an array structure. ### Deshape and Reshape can't ignore trailing axes -If you want to repeat 3 major cells until there are 7 of them, or combine the first 4 axes of a rank-6 array, what's your best option? Nothing's too good: you could compute a full shape for Reshape, enclose cells and merge afterwards, use Select to reshape one axis to multiple, or use `∾˝` to merge two axes (with possible empty-array issues). This is particularly dangerous with computed-length reshapes like `2‿∘⥊…`, since the idea of splitting off a length-2 axis from an array's first axis is generally useful, but this version has an implicit Deshape first. J's Reshape analogue (`$`) only ever applies to the first axis. This also seems to be giving up a lot. +If you want to repeat 3 major cells until there are 7 of them, or combine the first 4 axes of a rank-6 array, what's your best option? Nothing's too good: you could compute a full shape for Reshape, enclose cells and merge afterwards (for example `7⊸⥊⌾(<˘)`), use Select to reshape one axis to multiple, or use `∾˝` to merge two axes (with possible empty-array issues). This is particularly dangerous with computed-length reshapes like `2‿∘⥊…`, since the idea of splitting off a length-2 axis from an array's first axis is generally useful, but this version has an implicit Deshape first. J's Reshape analogue (`$`) only ever applies to the first axis. This also seems to be giving up a lot. ### At which scope does a block function belong? As a general principle, a programmer should make choices in one part of a program that constrain other parts of the program most tightly. This is a weak principle, but often it doesn't conflict with any other preferences and can be followed for free. For example it's usually best to define a variable in the smallest possible scope, so the reader knows it isn't used outside that scope. The same principle applies to blocks, but there is another conflicting principle: placing the block in a broader scope guarantees it won't access the variables in narrower ones. There's no position that will tell the reader, for example, that a function only uses variables local to itself and that it's only used within one particular scope. |
