Advertisement
Brunplunsu

Conway_sequence

Apr 24th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. conway      :: Integer -> [Integer]
  2. conway 1    = [1]
  3. conway x    = conway_start_line $ conway (x-1) --ghost x
  4.     where
  5.         conway_count            :: Integer -> Integer -> [Integer] -> [Integer]
  6.         conway_count num c []   = [c,num]
  7.         conway_count num c (n:ns)   -- Numero da trovare, count, (primo:altri)
  8.                 | num == n      = conway_count num (c+1) ns
  9.                 | otherwise     = c : (num : (conway_count n 1 ns))
  10.         --
  11.         conway_start_line       :: [Integer] -> [Integer]
  12.         conway_start_line (n:ns)= conway_count n 1 ns   --Avvia la sequenza
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement