Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

To translate that as literally as possible into Dyalog

  fizzbuzz ← {
    {(⍵ 'buzz' 'fizz' 'fizzbuzz')[1+2⊥0=3 5∘.|⍵]}¨⍵
  }
called as

  fizzbuzz ⍳100
or just

  {(⍵ 'buzz' 'fizz' 'fizzbuzz')[1+2⊥0=3 5∘.|⍵]}¨⍳100
with unnecessary parens

  {(⍵ 'buzz' 'fizz' 'fizzbuzz')[1+(2⊥(0=((3 5)∘.|⍵)))]}¨⍳100


Since you are using ¨, ⍵ is a scalar, so you don't need the ∘.

Translated back to J

  ((;'Buzz';'Fizz';'FizzBuzz'"_){~2#.0=3 5|])"0>:i.100
The boxed list in J feels a bit cumbersome compared to mixed arrays in APL.


Fair enough. Like most APL I wrote it backwards until it worked.


Works out-of-the box in GNU APL as well, if someone wants to try it with a free version of APL.


To that end, my K version can be tweaked slightly to work with oK, an open-source interpreter based on k6:

    {(x;"Buzz";"Fizz";"FizzBuzz")@2 2/~3 5!\:x}'1+!20
k6 swapped the argument order of "mod" and made change of base into an overload of "/", rather than a named builtin. See it in action here:

http://johnearnest.github.io/ok/index.html?run=%20%7B%28x%3B...




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: