 
 (defun -flatten (l)
   "Takes a nested list L and returns its contents as a single, flat list."
-  (if (listp l)
+  (if (and (listp l) (listp (cdr l)))
       (-mapcat '-flatten l)
     (list l)))
 

  `(apply 'append (--map ,form ,list)))

(defun -mapcat (fn list)
  "Returns the result of applying concat to the result of applying map to FN and LIST.
Thus function FN should return a collection."
  (--mapcat (funcall fn it) list))

(defmacro --first (form list)
  "Anaphoric form of `-first'."


To get the first item in the list no questions asked, use `car'."
  (--first (funcall pred it) list))

(defmacro --last (form list)
  "Anaphoric form of `-last'."
  (let ((n (make-symbol "needle")))
    `(let (,n)
       (--each ,list
         (when ,form (setq ,n it)))
       ,n)))

(defun -last (pred list)
  "Return the last x in LIST where (PRED x) is non-nil, else nil."
  (--last (funcall pred it) list))

(defmacro --count (pred list)
  "Anaphoric form of `-count'."
  (let ((r (make-symbol "result")))
    `(let ((,r 0))
       (--each ,list (when ,pred (setq ,r (1+ ,r))))
       ,r)))

(defun -count (pred list)
  "Counts the number of items in LIST where (PRED item) is non-nil."
  (--count (funcall pred it) list))

(defun ---truthy? (val)
  (not (null val)))
