<commit_before>module Q07 where

data NestedList a = Elem a | List [NestedList a]

flatten (Elem x)  = [x]
flatten (List y) = foldr (++) [] $ map flatten y<commit_msg>Improve Haskell 99 Problem 7<commit_after>module Q07 where

data NestedList a = Elem a | List [NestedList a]

flatten :: NestedList a -> [a]
flatten x =
  let
    flatten' :: NestedList a -> [a] -> [a]    
    flatten' (Elem x)     acc = x:acc
    flatten' (List [] )   acc = acc
    flatten' (List (p:q)) acc = flatten' p (flatten' (List q) acc)
  in
    flatten' x []
{'fraction_non_alphanumeric': 0.13805970149253732, 'fraction_numerical': 0.013059701492537313, 'mean_word_length': 3.037593984962406, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5140535', 'n_tokens_mistral': 213, 'n_tokens_neox': 204, 'n_words': 70}