Comment

Comment by ivanjermakov

I had no experience with array languages and decided to give it a try. It took me 4 hours to write FizzBuzz using only Uiua docs for help:

  # create an array of number 1-100
  ns ← ∵(+1)⇡[100]
  # make a copy of it in a string form "1"-"100"
  nsStr ← ∵(□$"_") ns
  # every i % 3 == 0 is replaced with "Fizz", everything else is ""
  f ← ∵(□▽∶ "Fizz" =0◿3) ns
  # every i % 5 == 0 is replaced with "Buzz", everything else is ""
  b ← ∵(□▽∶ "Buzz" =0◿5) ns
  # every i % 3 == 0 && i % 5 == 0 is replaced with  "FizzBuzz", everything else is ""
  fb ← ∵(□▽∶ "FizzBuzz" × =0◿5∶ =0◿3 .) ns

  # combine them into a 2D array
  gs ← [nsStr f b fb]

  # run a columnwise map
  # |  pick the greatest string of each column
  # |  |
  ⍉ ≡ (⊡⊢⇌⌂.) ⍉gs
Inability to use maximum function with arrays of different sizes is a bummer, I had to workaround it with grade and pick.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton