{"id":305298,"date":"2020-06-13T21:00:39","date_gmt":"2020-06-13T21:00:39","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=305298"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=305298","title":{"rendered":"Functional FizzBuzz \u043d\u0430 Scala"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/506570\/\">\n<p>FizzBuzz \u044d\u0442\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u043a\u0430, \u0448\u0443\u0442\u043b\u0438\u0432\u043e \u0438\u043b\u0438 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0437\u0430\u0434\u0430\u0432\u0430\u0435\u043c\u0430\u044f \u043d\u0430 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\u0445, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u0436\u0435 \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438\u0433\u0440\u044b. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0430\u0436\u0435 \u0448\u0435\u0434\u0435\u0432\u0440\u044b \u0432\u0440\u043e\u0434\u0435 <a href=\"https:\/\/github.com\/EnterpriseQualityCoding\/FizzBuzzEnterpriseEdition\" rel=\"nofollow\">FizzBuzzEnterpriseEdition<\/a>.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u044f\u0442\u043d\u0438\u0447\u043d\u044b\u0439, \u0430 \u0441\u043a\u043e\u0440\u0435\u0435 \u0441\u0443\u0431\u0431\u043e\u0442\u043d\u0438\u0439: FizzBuzz \u043d\u0430 Scala, functional style.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2 id=\"zadacha\">\u0417\u0430\u0434\u0430\u0447\u0430<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0447\u0438\u0441\u0435\u043b \u043e\u0442 1 \u0434\u043e 100 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u043d\u0430 \u044d\u043a\u0440\u0430\u043d <\/p>\n<p>  <\/p>\n<ul>\n<li>Fizz, \u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 3;<\/li>\n<li>Buzz, \u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 5;<\/li>\n<li>FizzBuzz, \u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u0438 \u043d\u0430 3 \u0438 \u043d\u0430 5;<\/li>\n<li>\u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0430\u043c\u043e \u0447\u0438\u0441\u043b\u043e.<\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"reshenie\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<blockquote><p>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0435 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0448\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/p><\/blockquote>\n<p>  <\/p>\n<h3 id=\"nachnem-s-delimosti\">\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0434\u0435\u043b\u0438\u043c\u043e\u0441\u0442\u0438<\/h3>\n<p>  <\/p>\n<pre><code class=\"scala\">def divisibleBy(n: Int, d: Int): Boolean = n % d == 0  divisibleBy(10, 5) \/\/ =&gt; true<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0435\u0442, \u044d\u0442\u043e \u043d\u0430\u0441 \u043d\u0435 \u0443\u0441\u0442\u0440\u043e\u0438\u0442 \u2014 \u0432\u0435\u0434\u044c \u0434\u0435\u043b\u0438\u043c\u043e\u0441\u0442\u044c \u044d\u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u0435\u043b \u0442\u0438\u043f\u0430 <code>Int<\/code>, \u043e\u043f\u0438\u0448\u0435\u043c \u0434\u0435\u043b\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u043e\u0431\u0449\u0435\u043c \u0432\u0438\u0434\u0435, \u0430 \u0437\u0430 \u043e\u0434\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0435 \u0438\u043d\u0444\u0438\u043a\u0441\u043d\u044b\u043c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c (\u0422\u0443\u0442 \u0438 \u0434\u0430\u043b\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/typelevel.org\/cats\/\" rel=\"nofollow\">cats<\/a>):<\/p>\n<p>  <\/p>\n<pre><code class=\"scala\">import cats.implicits._ import cats.Eq  implicit class DivisionSyntax[T](val value: T) extends AnyVal {   def divisibleBy(n: T)(implicit I: Integral[T], ev: Eq[T]): Boolean = {     import I._     (value % n) === zero   }   def divisibleByInt(n: Int)(implicit I: Integral[T], ev: Eq[T]): Boolean =     divisibleBy(I.fromInt(n)) }  10 divisibleBy 5 \/\/ =&gt; true BigInt(10) divisibleBy BigInt(3) \/\/ =&gt; false BigInt(10) divisibleByInt 3 \/\/ =&gt; false<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/scalac.io\/typeclasses-in-scala\/\" rel=\"nofollow\">type class<\/a> &quot;<code>Integral<\/code>&quot; \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0439 \u043e\u0442 \u0442\u0438\u043f\u0430 &quot;<code>T<\/code>&quot; \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438 \u0438\u043c\u0435\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 &quot;<code>zero<\/code>&quot;<\/li>\n<li>type class &quot;<code>Eq<\/code>&quot; \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0439 \u043e\u0442 \u0442\u0438\u043f\u0430 &quot;<code>T<\/code>&quot; \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b (\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &quot;<code>===<\/code>&quot; \u044d\u0442\u043e \u0435\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441)<\/li>\n<li>\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 &quot;<code>T<\/code>&quot; \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/docs.scala-lang.org\/overviews\/core\/value-classes.html\" rel=\"nofollow\">extension methods &amp; value classes<\/a>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0440\u0430\u043d\u0442\u0430\u0439\u043c-\u043e\u0432\u0435\u0440\u0445\u0435\u0434\u0430 (\u0436\u0434\u0435\u043c dotty, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0435\u0441\u0435\u0442 \u043d\u0430\u043c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u044d\u043a\u0441\u0442\u0435\u043d\u0448\u0435\u043d \u043c\u0435\u0442\u043e\u0434\u043e\u0432)<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0421\u0442\u0440\u043e\u0433\u043e \u0433\u043e\u0432\u043e\u0440\u044f \u043c\u0435\u0442\u043e\u0434 <code>divisibleByInt<\/code> \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0442\u0443\u0442 \u043d\u0443\u0436\u0435\u043d, \u043d\u043e \u043e\u043d \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430\u043c \u043f\u043e\u0437\u0436\u0435, \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044b \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 3 \u0438 5.<\/p>\n<p>  <\/p>\n<h3 id=\"fizzbuzz\">FizzBuzz<\/h3>\n<p>  <\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d, \u043d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c &quot;Fizz&quot;, &quot;Buzz&quot;, &quot;FizzBuzz&quot; \u043b\u0438\u0431\u043e \u0441\u0430\u043c\u043e \u0447\u0438\u0441\u043b\u043e. \u0422\u0443\u0442 \u0435\u0441\u0442\u044c \u043e\u0431\u0449\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u2014 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 <code>Option<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u043d\u0435\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"scala\">def useIf[T](value: T, condition: Boolean) = if (condition) Some(value) else None<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 &quot;<code>divisibleBy(10, 5)<\/code>&quot; \u0438 &quot;<code>10 divisibleBy 5<\/code>&quot; \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f, \u043d\u043e \u043a\u0430\u043a-\u0442\u043e \u043d\u0435\u043a\u0440\u0430\u0441\u0438\u0432\u043e. \u041c\u044b \u0432\u0435\u0434\u044c \u0445\u043e\u0442\u0438\u043c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u043d\u043e \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, DSL! \u041f\u043e-\u0441\u0443\u0442\u0438, \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430 \u0438 \u0435\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 DSL \u0440\u0430\u0437\u043d\u043e\u0433\u043e \u0440\u043e\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043e\u0442\u0434\u0435\u043b\u044f\u0435\u043c &quot;\u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c&quot; \u043e\u0442 &quot;\u0447\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c&quot;, &quot;<code>10 % 5 == 0<\/code>&quot; \u043e\u0442 &quot;<code>10 divisibleBy 5<\/code>&quot;.<\/p>\n<p>  <\/p>\n<pre><code class=\"scala\">implicit class WhenSyntax[T](val value: T) extends AnyVal {   def when(condition: Boolean): Option[T] = if (condition) Some(value) else None }  &quot;Fizz&quot; when (6 divisibleBy 3) \/\/ =&gt; Some(&quot;Fizz&quot;) &quot;Buzz&quot; when (6 divisibleBy 5) \/\/ =&gt; None<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u043c\u0435\u0441\u0442\u0435! \u041c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>orElse<\/code> \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0431\u044b 3 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u0430 \u0438\u0437 4, \u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u044b\u0432\u0435\u0441\u0442\u0438 &quot;FizzBuzz&quot; \u044d\u0442\u043e \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c <code>Some(&quot;Fizz&quot;) ? Some(&quot;Buzz&quot;) =&gt; Some(&quot;FizzBuzz&quot;)<\/code>. \u041f\u0440\u043e\u0441\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c, \u043d\u043e \u043a\u0430\u043a \u0441\u043b\u043e\u0436\u0438\u0442\u044c <code>Option[String]<\/code>? \u0422\u0443\u0442 \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 <del>\u043c\u043e\u043d\u0430\u0434\u044b<\/del> <a href=\"https:\/\/typelevel.org\/cats\/typeclasses\/monoid.html\" rel=\"nofollow\">\u043c\u043e\u043d\u043e\u0438\u0434\u044b<\/a>, cats \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0432\u0441\u0435 \u043d\u0443\u0436\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u044b \u0438 \u0434\u0430\u0436\u0435 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441:<\/p>\n<p>  <\/p>\n<pre><code class=\"scala\">  def fizzBuzz[T: Integral: Eq: Show](number: T): String =     (&quot;Fizz&quot; when (number divisibleByInt 3)) |+|     (&quot;Buzz&quot; when (number divisibleByInt 5)) getOrElse     number.show<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0443\u0442 type class <code>Show<\/code> \u0434\u0430\u0435\u0442 \u0442\u0438\u043f\u0443 <code>T<\/code> \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0432 \u0441\u0442\u0440\u043e\u043a\u0443, <code>|+|<\/code> \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043c\u043e\u043d\u043e\u0438\u0434\u0430 \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 <code>getOrElse<\/code> \u0437\u0430\u0434\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0412\u0441\u0435 \u0432 \u043e\u0431\u0449\u0435\u043c \u0432\u0438\u0434\u0435 \u0438 \u0434\u043b\u044f \u043b\u044e\u0431\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0438 \u043e\u0442 \u0441\u0442\u0440\u043e\u043a &quot;Fizz&quot; &amp; &quot;Buzz&quot; \u0430\u0431\u0441\u0442\u0440\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u043d\u043e \u044d\u0442\u043e \u043b\u0438\u0448\u043d\u0435\u0435 \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434.<\/p>\n<p>  <\/p>\n<h3 id=\"konec\">\u041a\u043e\u043d\u0435\u0446<\/h3>\n<p>  <\/p>\n<p>\u0412\u0441\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e <code>(1 to 100) map fizzBuzz[Int]<\/code> \u0438 \u043a\u0443\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u041d\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0434\u0440\u0443\u0433\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f&#8230;<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/506570\/\"> https:\/\/habr.com\/ru\/post\/506570\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/506570\/\">\n<p>FizzBuzz \u044d\u0442\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u043a\u0430, \u0448\u0443\u0442\u043b\u0438\u0432\u043e \u0438\u043b\u0438 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0437\u0430\u0434\u0430\u0432\u0430\u0435\u043c\u0430\u044f \u043d\u0430 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\u0445, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u0436\u0435 \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438\u0433\u0440\u044b. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0430\u0436\u0435 \u0448\u0435\u0434\u0435\u0432\u0440\u044b \u0432\u0440\u043e\u0434\u0435 <a href=\"https:\/\/github.com\/EnterpriseQualityCoding\/FizzBuzzEnterpriseEdition\" rel=\"nofollow\">FizzBuzzEnterpriseEdition<\/a>.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u044f\u0442\u043d\u0438\u0447\u043d\u044b\u0439, \u0430 \u0441\u043a\u043e\u0440\u0435\u0435 \u0441\u0443\u0431\u0431\u043e\u0442\u043d\u0438\u0439: FizzBuzz \u043d\u0430 Scala, functional style.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-305298","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/305298","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=305298"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/305298\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=305298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=305298"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=305298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}