Skip to content

Instantly share code, notes, and snippets.

@westerp
Created May 11, 2018 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westerp/befe5bb8c0649ff3a88ecc6cbec4663f to your computer and use it in GitHub Desktop.
Save westerp/befe5bb8c0649ff3a88ecc6cbec4663f to your computer and use it in GitHub Desktop.
Suggested solution to: Create a function which gets a list as parameter and creates a list in which only the original list's atoms exist in reversed order. example : list: (a (b c) d e)) output: (e d a)
(defun reverse-filter-atoms (l)
(funcall
((lambda (f)
((lambda (g) (funcall g g))
(lambda (g)
(funcall f (lambda (&rest args) (apply (funcall g g) args))))))
(lambda (fa)
(lambda (l k)
(if (endp l)
(funcall k l)
(funcall fa
(cdr l)
(lambda (r)
(funcall k
(if (atom (car l))
(cons (car l) r)
r))))))))
l
(lambda (l)
(funcall
((lambda (f)
((lambda (g) (funcall g g))
(lambda (g)
(funcall f (lambda (&rest args) (apply (funcall g g) args))))))
(lambda (r)
(lambda (l acc)
(if (endp l)
acc
(funcall r (cdr l) (cons (car l) acc))))))
l
'()))))
@WillNess
Copy link

Now that's simple!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment