I love small challenges as a way to learn a language. I spotted this one in the #rstats hashtag on Mastodon
“square each digit of an integer (return integer), eg 9113 becomes 81119”
and I just had to try it in APL.
First, extract each of the digits using format
{⍎¨⍕⍵}9113 9 1 1 3 then …
Breaking down fizzbuzz in (Dyalog) APL
The one-liner solution: {∊(3↑(0=3 5|⍵)∪1)/'Fizz' 'Buzz' ⍵}¨⍳20
The explanation:
For each value in [1, 2, ..., 20], find the boolean mask of “is this divisible by 3 or 5?” (vectorized).
{0=3 5|⍵}¨⍳20
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐ │0 0│0 …