~singpolyma/cheogram

ref: d715d7de017b5e5c34a2958a9a58a953d34c00e8 cheogram/UniquePrefix.hs -rw-r--r-- 369 bytes
d715d7deStephen Paul Weber Fetch any OOB URL from route and cache in jingle store 1 year, 11 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
module UniquePrefix where

import Data.List
import qualified Data.Set as S
import qualified Data.Text as T

uniquePrefix txts = helper [] $ map (S.fromList . tail . T.inits) txts

helper done (prefixes:otherPrefixes) =
	(foldl' S.difference prefixes (done ++ otherPrefixes)) : helper (prefixes:done) otherPrefixes
helper _ [] = []

--ALT: https://pastebin.com/hFKdZw2g