Skip to content

Instantly share code, notes, and snippets.

@tonini
Last active December 26, 2015 10:29
Show Gist options
  • Save tonini/7137144 to your computer and use it in GitHub Desktop.
Save tonini/7137144 to your computer and use it in GitHub Desktop.
(defun elixir-mix-flatten (alist)
(cond ((null alist) nil)
((atom alist) (list alist))
(t (append (elixir-mix-flatten (car alist))
(elixir-mix-flatten (cdr alist))))))
(ert-deftest test-flatten-of-list ()
(should (equal (elixir-mix-flatten '(1 2 (3 4) 5))
'(1 2 3 4 5)))
(should (equal (elixir-mix-flatten '(1 2 ("wood" "fire" (3)) 4 5))
'(1 2 "wood" "fire" 3 4 5))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment