99-problems in Java 8, Scala, and Haskell
github.com
github.com
I haven't worked with Java in quite a while, but I imagine that it still requires a lot of boilerplate and set up for trivial things in other languages. I'm sure if C were also included it would be the most verbose.
package com.shekhargulati.ninetynine_problems._02_arithmetic;
import java.util.stream.LongStream;
/**
* (**) Determine whether a given integer number is prime.
*/
public class P31 {
public static boolean isPrime(long number) {
return !LongStream.rangeClosed(2, Math.round(Math.sqrt(number))).anyMatch(n -> number % n == 0);
}
} $ find ./java8 -name \*.java | xargs wc -c | tail -1
123903 total
$ find ./scala -name \*.scala | xargs wc -c | tail -1
80516 total
$ find ./haskell -name \*.hs | xargs wc -c | tail -1
11234 totalFor example, take a look at problem 2.07 from the original 99-problems for [Prolog][1] and compare it to the [Java][2] solution in the linked repo. In Prolog, you're defining relations, so with GCD defined, you can compute the GCD (g) given two integers a and b, but you can also compute possible values for b, given a and g, for example. The Java solution doesn't allow for anything like that.
So, given the README information, I expected to see the implementations in different language platforms utilize some prolog-esque logic programming library (like core.logic for Clojure), but that isn't the case.
[1]: https://sites.google.com/site/prologsite/prolog-problems/2 [2]: https://github.com/shekhargulati/99-problems/blob/master/jav...
Besides AssertJ being easier to use and IMO more elegant than Hamcrest, JUnit 5 will be removin `assertThat`.
I contemplated filing a bug/request but its more of a conversation point than an issue.
I think you misread that bug report.
>Closing this issue since there are no plans to include direct dependencies on third-party assertion libraries within JUnit 5.The OP shows examples assertions using JUnit 4 and hamcrest assertThat. The OP could use the builtin assert for all I care but I sort of got the gist they were trying to show the canonical approach. This is not to critique but rather to inform.
There is something rather magical about solving almost any problem in a single line of code.
If it's any consolation, that was the first thing I thought as well. I even thought the problems would make some joke reference to the song.
However, it seems as if Werner Hett at the Berner Fachhochschule came up with this independently of Jay-Z.