public
Description: This is a space for projects that maybe did or didn't start at a Dojo session and the participants continued developing.
Homepage: http://groups.google.com/group/dojo_sp
Clone URL: git://github.com/dojosp/participant-s-projects.git
100755 20 lines (16 sloc) 0.479 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module TresNmaisUm where
 
proximo :: Int -> Int
proximo x | even x = x `div` 2
          | otherwise = 3 * x + 1
 
ciclo 1 = 0
ciclo n = 1 + ciclo (proximo n)
 
maiorCicloEntre i j | i == j = ciclo i
                    | i < j = max (ciclo j) (maiorCicloEntre i (j-1))
                    | otherwise = maiorCicloEntre j i
 
maiorCicloEntre' s =
    let
        dupla = span (/= ' ') s
        i' = fst dupla
        j' = snd dupla
    in
      maiorCicloEntre (read i') (read j')