FizzBuzz #124
gilch
started this conversation in
Show and tell
FizzBuzz
#124
Replies: 1 comment
-
No-macros, no-variables version: (print : :* (map max
(map str (range 1 101))
(map operator..concat
(itertools..cycle `(,"" ,"" ,"Fizz"))
(itertools..cycle `(,"" ,"" ,"" ,"" ,"Buzz"))))
sep #"\n") Quite concise, but the empty strings still feel repeated. We can fix that with e.g. `(,@(operator..mul 4 `(,"")) ,"Buzz")) but this hardly seems worth the overhead, mostly because it takes a lot of characters to spell out Some judicious injects can go a long way: `(,@.#"4*['']" ,"Buzz")) The "Buzz" cycle is a little shorter like this, but the "Fizz" cycle isn't. I called this a "no-macro" version, but that's only if we don't count the built-in reader syntax for making tuples. You can spell these out though, e.g.: ((lambda (: :* xs) xs) "" "" "Fizz") |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Lissp might be easier to pick up for some with some simple examples. Here's a FizzBuzz.
FizzBuzz is a bit harder than it looks. The obvious way like this seems so inelegant. I've seen golfed solutions that were much more compact, but probably no more readable. Perhaps something in between would be more optimal. Anyone care to try?
Beta Was this translation helpful? Give feedback.
All reactions