Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,2 @@
⎕IO0
(L,'Fizz' 'Buzz' 'FizzBuzz')[¯1+(L×W=0)+W(100×~0=W)+W+/1 2×0=3 5|L1+100]

View file

@ -0,0 +1 @@
A[I]1+I(0A)/A('FIZZBUZZ' 'FIZZ 'BUZZ' 0)[2¨×(3 5)|¨1+100]

View file

@ -0,0 +1 @@
{ 'Fizz' 'Buzz' 'FizzBuzz'[ +/1 2×0=3 5|] }¨1+100

View file

@ -0,0 +1 @@
{(FizzBuzz Fizz Buzz,)[(0=15 3 5|)1]}¨100

View file

@ -0,0 +1,40 @@
sv fizzbuzz n; t;d
[1] ⍝⍝ Solve the popular 'fizzbuzz' problem in APL.
[2] ⍝⍝ \param n - highest number to compute (≥0)
[3] ⍝⍝ \returns sv - a vector of strings representing the fizzbuzz solution for n
[4] ⍝⍝ (note we return a string vector to avoid a mixed-type result; remove the
[5] ⍝⍝ ⍕ function from the (⍕t[⍵]) term to see the difference).
[6] ⍝⍝⍝⍝
[7] tn ⍝ the sequence 1..n itself which we'll pick from
[8] ⍝ ... or the words 'fizz', 'buzz', 'fizzbuzz' depending on
[9] ⍝ ... divisibility by 3 and/or 5
[10] ⍝⎕←t ⍝ (Uncomment to see during call)
[11]
[12] d1+(+ {((0=3|)) (2×(0=5|))} n)
[13] ⍝ || || | | | ↓↓
[14] ⍝ || || | | | n: generate range (1..n)
[15] ⍝ || || | ↓.....................↓ ↓↓
[16] ⍝ || || | A dfn (lambda) taking its right arg (⍵, n here) to compute two boolean
[17] ⍝ || || | vectors(v12): divisibility by 3 and 5, respectively, for each of n
[18] ⍝ || || ↓
[19] ⍝ || || ⊃: Disclose ('lift-up' and pad w/zeros) the 'ragged' matrix of vectors (v12)
[20] ⍝ || || holding divisibility by 3 and 5 of each n
[21] ⍝ || ↓↓
[22] ⍝ || +⌿: Sum (v12) row-wise to count divisibility (0=neither 3 nor 5, 1=3, 2=3 and 5)
[23] ⍝ ↓↓
[24] ⍝ 1+: Add one to (v12) to make them 1-based for indexing below:
[25] ⍝⎕←d
[26]
[27] sv { ((t[]) 'Fizz' 'Buzz' 'FizzBuzz') [d[]]}¨ n
[28] ⍝ | | | | | |
[29] ⍝ | | | ↓....↓ |
[30] ⍝ | |................................↓ idx |
[31] ⍝ | ( lookup output vector ) |
[32] ⍝ ↓...........................................↓
[33] ⍝ A dfn (lambda) taking as its right arg (⍵) n and using the 'each' (¨)
[34] ⍝ operator to apply the lambda to each (idx) of n.
[35]
[36] ⍝⍝ USAGE
[37] ⍝⍝ ⎕ ← ,fizzbuzz 15
[38] ⍝ 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz