masklinn í dag viðrar vel til loftárása | En Haskell, ça donne un truc du genre:
Code :
growing [] = [] growing [x] = [[x]] growing (x1:x2:xs) | x1 <= x2 = let (ys, zs) = growSpan (x1:x2:xs) in ys : growing zs | otherwise = [x1] : growing (x2:xs) growSpan xs = _growSpan xs [] where _growSpan [x] serie = (reverse (x:serie), []) _growSpan (x1:x2:xs) serie | x1 <= x2 = _growSpan (x2:xs) (x1:serie) | otherwise = (reverse (x1:serie), x2:xs)
|
et à l'appel:
*Main> growing [2,6,4,2,6,8,0,0,4] [[2,6],[4],[2,6,8],[0,0,4]] |
Ca a l'air d'être bon.
Message édité par masklinn le 31-10-2008 à 19:25:40 ---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
|