Changeset 4866 for src/Pugs/Internals.hs

Show
Ignore:
Timestamp:
06/20/05 07:11:28 (4 years ago)
Author:
mugwump
svk:copy_cache_prev:
6641
Message:

Implement 3-arg split (text-based), update test - still one outstanding test failure...

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Internals.hs

    r4803 r4866  
    5858    internalError, 
    5959    split, 
     60    split_n, 
    6061    breakOnGlue, 
    6162    afterPrefix, 
     
    152153     Nothing -> [str] 
    153154 
     155split_n :: (Eq a) => [a] -> [a] -> Int -> [[a]] 
     156split_n []  _ n  = internalError "splitting by an empty list" 
     157split_n sep str n 
     158   | n == 1 = [str] 
     159   | otherwise = 
     160   case breakOnGlue sep str of 
     161       Just (before, after) -> before : split_n sep after (n-1) 
     162       Nothing -> [str] 
     163 
    154164-- returns Nothing if the glue isn't there 
    155165breakOnGlue :: (Eq a) => [a] -> [a] -> Maybe ([a], [a])