GenuineSounds icon

Untitled

GenuineSounds | PRO | 06/23/16 10:22:50 AM UTC | 0 ⭐ | 460 👁️ | Never ⏰ | []
Lua |

1.6 KB

|

None

|

0 👍

/

0 👎

-- One liner
var fizzbuzz = [                                         -- create named set fizzbuzz
    [1..100]                                             -- create set of integers 1 through 100 (exclusively)
            .map(Integer::toString)                      -- map each entry to the string of the integer
            .replace(                                    -- replace duplicate entries of set
        [1..100|3]                                       -- create set of integers 1 through 100 (exclusively) incrementing by 3
                .map("fizz")                             -- map each entry to the string "fizz"
                .join(                                   -- join (set, function)
            [1..100|5]                                   -- create set of integers 1 through 100 (exclusively) incrementing by 5
                    .map("buzz"),                        -- map each entry to the string "buzz"
                    (entry1, entry2) -> entry1 + entry2  -- lambda takes two two parameters and returns single object
        )                                                -- join complete for fizz and buzz sets, sent to replace function
    )                                                    -- replace complete
];                                                       -- assignment complete
 
-- Better Visibility.
var fizzbuzz = [];
 
var temp = [1..100].map(Integer::toString);
var fizz = [1..100|3].map("fizz");
var buzz = [1..100|5].map("buzz");
func rpl = (e1, e2) -> e2;
func acc = (e1, e2) -> e1 + e2;
var fzbz = fizz.join(buzz, acc);
fizzbuzz = temp.join(fzbz, rpl);

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎