3 ms·
How about this, this will compute more than pairs <pre><code> let dict = Data.Set.fromList["apple", "pie", "bread", "applepie", "piebread"] let fn q = concat
by zohebv 15y ago
How about this, this will compute more than pairs
<pre><code>
let dict = Data.Set.fromList["apple", "pie", "bread", "applepie", "piebread"]
let fn q = concat.Data.List.map (\(x,y) -> if (member x dict) then if y == "" then [[x]] else Data.List.map (x:) (fn y) else [] ) $ tail $ zip (inits q) (tails q)
fn "applepiebread"
[["apple","pie","bread"],["apple","piebread"],["applepie","bread"]]
</code></pre>