im trying to find the largest prime factor of a big number, I know that's the smallest factor is indeed prime, but how about the largest. should I really find all the prime numbers that divide it. or there is an easy way.
@AlexDan every prime factor, including the smallest, is necessarily prime. to find the largest you generally have to find all factors. there is no easy way for the general case: all modern encryption relies on there being no easy way.
@DeadMG In the rare cases where you actually need that, you use a while. But in most cases, you would use for comprehensions in the form for (x <- list) or something (no Scala expert here).
@CheersandhthAlf Integer factorization can be done easily with a quantum algorithm. Of course, that hardly counts as "modern", more like "super-futuristic"
for comprehensions do more than a foreach, though. Do you know what a list comprehension is in Haskell? Scala's for comprehensions are more general, because they work for any monad.
In mathematics and computer science, currying is the technique of transforming a function that takes multiple arguments (or an n-tuple of arguments) in such a way that it can be called as a chain of functions each with a single argument (partial application). It was discovered by Moses Schönfinkel and later re-discovered by Haskell Curry. Because of this, some say it would be more correct to name it schönfinkeling.
Uncurrying (also known as counter-currying) is the dual transformation to currying, and can be seen as a form of defunctionalization. It takes a function f(x) which returns a...