Exercism Comparisons
Last week I told you about YS on Rosetta Code
and yesterday I told you about YS on Exercism
.
Today I'm going to show you how to compare solutions to the same Rosetta Code task using all the Exercism languages!
The Gist🔗
There are lots of ways to implement the FizzBuzz problem in YS, but here's one:
!YS-v0
defn main(n=100):
each x (1 .. n): !:say
or? _ x:
str ((x % 3).! &&& 'Fizz'):
((x % 5).! &&& 'Buzz')
This is the way it's implemented on Rosetta Code
.
Let's try it out:
$ ys fizzbuzz.ys 16
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
What if we wanted to compare this solution to the solutions in all of the Exercism languages?
Without further ado, here's a Gist that shows just that:
https://gist.github.com/ingydotnet/9ece4af186c6a6dcfd589c446dab9b38
.
Compare FizzBuzz in YS to FizzBuzz in 60 other languages.
The coolest part?
That webpage was generated and posted as a GitHub Gist by a YS program!