(.:) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
(.:) f g = \x y -> f (g x y)
which e.g. allows you to define the absolute distance function dist :: (Num a) => a -> a -> a
dist = abs .: (-)
A fun challenge is figuring out why the definition of (.:) is equivalent to (.:) = fmap . fmap
! data Color = Red | Green | Blue | Yellow | Orange | Purple
deriving (Enum, Bounded, Show)
and then (e.g. in ghci) you can do >> [minBound .. maxBound] :: [Color]
[Red,Green,Blue,Yellow,Orange,Purple]
I often define the useful function enumerate :: (Enum a, Bounded a) => [a]
enumerate = [minBound .. maxBound]
for exactly this purpose. exp(-r * T)
and a stream of payments C1, C2, ... CN at times T1, T2, ... TN is worth C1 * exp(-r * T1) + C2 * exp(-r * T2) + ... + CN * exp(-r * TN)
In particular, N can be infinite, so that the value of a never-ending stream of payments is C1 * exp(-r * T1) + C2 * exp(-r * T2) + ...
which can sum to a finite value. For example, if all the C's are constant, and T1 = 1 year, T2 = 2 years etc, then the present value is C * exp(-r) + C * exp(-2r) + C * exp(-3r) + ...
= C * (exp(-r) + exp(-2r) + exp(-3r) + ...)
= C * exp(-r) / (1 - exp(-r))
so, for example, if C = $1,000 and r = 4%, then the value of this infinite stream of payments is about $24,500 - so if you had to lend more than $24,500 for a 4% consol paying $1,000 you would be getting a bad deal. log(a + b) = log(a) log(b)
is a rule I'm familiar with!
A good example is finding arithmetic sequences of length K in the prime numbers (for example, the sequence 3, 5, 7 is an arithmetic sequence of length 3, as is 17, 23, 29). It can be shown that random sets that have a density similar to the primes (i.e. the chance that N is in the set is proportional to 1 / log(N)) have arbitrarily long arithmetic sequences - as, in fact, do the prime numbers.