4 ms·
That is a function that takes a starting parameter and returns a pair with the length of the sequence as the first element and the starting value as the second
by chas 13y ago
That is a function that takes a starting parameter and returns a pair with the length of the sequence as the first element and the starting value as the second element. This is mapped over a list of integers from 1 to max_a0 to find the length of the sequence starting with each integer.
Maximum finds the largest component of a list and compares on the first element of a pair first, so the pair with the longest sequence length as its first element and the starting value that produced that sequence length as it's second element will be returned by `maximum $ map (\a0 -> (collatzLen a0, a0)) [1..max_a0]`.
This function could also be expressed as `collatzLen >>= (,)`, if you were into that sort of thing.