Advertisement
GenuineSounds

Untitled

Jun 23rd, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.60 KB | None | 0 0
  1. -- One liner
  2. var fizzbuzz = [                                         -- create named set fizzbuzz
  3.     [1..100]                                             -- create set of integers 1 through 100 (exclusively)
  4.             .map(Integer::toString)                      -- map each entry to the string of the integer
  5.             .replace(                                    -- replace duplicate entries of set
  6.         [1..100|3]                                       -- create set of integers 1 through 100 (exclusively) incrementing by 3
  7.                 .map("fizz")                             -- map each entry to the string "fizz"
  8.                 .join(                                   -- join (set, function)
  9.             [1..100|5]                                   -- create set of integers 1 through 100 (exclusively) incrementing by 5
  10.                     .map("buzz"),                        -- map each entry to the string "buzz"
  11.                     (entry1, entry2) -> entry1 + entry2  -- lambda takes two two parameters and returns single object
  12.         )                                                -- join complete for fizz and buzz sets, sent to replace function
  13.     )                                                    -- replace complete
  14. ];                                                       -- assignment complete
  15.  
  16. -- Better Visibility.
  17. var fizzbuzz = [];
  18.  
  19. var temp = [1..100].map(Integer::toString);
  20. var fizz = [1..100|3].map("fizz");
  21. var buzz = [1..100|5].map("buzz");
  22. func rpl = (e1, e2) -> e2;
  23. func acc = (e1, e2) -> e1 + e2;
  24. var fzbz = fizz.join(buzz, acc);
  25. fizzbuzz = temp.join(fzbz, rpl);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement