Flat ranges (f 3 2 => 0 1 2 0 1), same as ,/!':
{(!+/x)-&(0 :':+\x)!x}
Or if you have an occurrence count primitive:
oc:{i-(i:<<x)x?x}
oc@&:
Reverse flat ranges (f 3 2 => 2 1 0 1 0), same as ,/|'!':
{(&a!x)-1+!*|a:+\x}
Some views from the APL perspective:
Roger Hui's "On Average": https://t.co/GN6Cqyt1hv
"Division by zero in APL: assign return value 0 or 1?" https://t.co/IdQ2UEYVI8
"In fact the opposite is true: these features are designed to give safe robust defaults for numerically unsophisticated programmers, in addition to supporting sophisticated numerical libraries by experts."
Ideally, k's design would minimise the need for the user to explicitly handle special cases (situations such as "if empty, x, else y").
k is already good at this, in part because it tracks the type and structure of empty lists.
How are primitive functions (such as 'count') like, or unlike, dictionaries?
For example:
- both can be indexed and inverse-indexed into
- primitives have an infinite domain
- primitive domain can be a general list
- dictionary indexing is rank-sensitive
📖Exciting News! 📖 You can now read (for free!) a paper written by Aaron Hsu🎓@arcfide and Rodrigo Girão Serrão for ARRAY 23 (in Orlando🌴this month.)
Download "U-Net CNN in APL: Exploring Zero-Framework, Zero-Library Machine Learning" at https://t.co/hBWrxFMzeo