Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(def factorial
(comp
(partial apply apply)
(juxt
(comp
(partial apply comp)
(juxt
(comp
(partial apply partial)
(juxt (constantly apply) (constantly apply)))
(comp
(partial apply juxt)
(juxt
(comp
(partial apply comp)
(juxt (constantly first) (constantly list)))
(comp
(partial apply juxt)
(juxt
(comp
(partial apply comp)
(juxt (constantly first) (constantly list)))
(comp
(partial apply constantly)
(juxt (comp first list)))))))))
(juxt
(comp
(partial apply comp)
(juxt
(comp
(partial apply partial)
(juxt (constantly apply) (constantly apply)))
(comp
(partial apply juxt)
(juxt
(comp
(partial apply comp)
(juxt
(comp
(partial apply partial)
(juxt (constantly apply) (constantly apply)))
(comp
(partial apply juxt)
(juxt
(comp
(partial apply comp)
(juxt
(comp
(partial apply partial)
(juxt (constantly apply) (constantly hash-map)))
(comp
(partial apply juxt)
(juxt
(comp
(partial apply constantly)
(juxt (constantly true)))
(comp
(partial apply comp)
(juxt
(comp
(partial apply partial)
(juxt (constantly apply) (constantly constantly)))
(comp
(partial apply juxt)
(juxt
(comp
(partial apply constantly)
(juxt (constantly 1)))))))
(comp
(partial apply constantly)
(juxt (constantly false)))
(comp
(partial apply comp)
(juxt
(comp
(partial apply partial)
(juxt (constantly apply) (constantly comp)))
(comp
(partial apply juxt)
(juxt
(comp
(partial apply comp)
(juxt
(comp
(partial apply partial)
(juxt (constantly apply) (constantly partial)))
(comp
(partial apply juxt)
(juxt
(comp
(partial apply constantly)
(juxt (constantly apply)))
(comp
(partial apply constantly)
(juxt (constantly *)))))))
(comp
(partial apply comp)
(juxt
(comp
(partial apply partial)
(juxt (constantly apply) (constantly juxt)))
(comp
(partial apply juxt)
(juxt
(comp
(partial apply comp)
(juxt
(comp
(partial apply partial)
(juxt
(constantly apply)
(constantly constantly)))
(comp
(partial apply juxt)
(juxt
(comp
(partial apply comp)
(juxt
(constantly last)
(constantly list)))))))
(comp
(partial apply comp)
(juxt
(comp
(partial apply partial)
(juxt (constantly apply) (constantly comp)))
(comp
(partial apply juxt)
(juxt
(comp
(partial apply comp)
(juxt
(comp
(partial apply partial)
(juxt
(constantly apply)
(constantly partial)))
(comp
(partial apply juxt)
(juxt
(comp
(partial apply constantly)
(juxt (constantly apply)))
(comp
(partial apply comp)
(juxt
(constantly first)
(constantly list)))))))
(comp
(partial apply comp)
(juxt
(comp
(partial apply partial)
(juxt
(constantly apply)
(constantly juxt)))
(comp
(partial apply juxt)
(juxt
(comp
(partial apply comp)
(juxt
(comp
(partial apply partial)
(juxt
(constantly apply)
(constantly constantly)))
(comp
(partial apply juxt)
(juxt
(comp
(partial apply comp)
(juxt
(constantly first)
(constantly list)))))))
(comp
(partial apply comp)
(juxt
(comp
(partial apply partial)
(juxt
(constantly apply)
(constantly comp)))
(comp
(partial apply juxt)
(juxt
(comp
(partial apply comp)
(juxt
(comp
(partial apply partial)
(juxt
(constantly apply)
(constantly partial)))
(comp
(partial apply juxt)
(juxt
(comp
(partial apply constantly)
(juxt (constantly apply)))
(comp
(partial apply constantly)
(juxt (constantly dec)))))))
(comp
(partial apply comp)
(juxt
(comp
(partial apply partial)
(juxt
(constantly apply)
(constantly juxt)))
(comp
(partial apply juxt)
(juxt
(comp
(partial apply comp)
(juxt
(comp
(partial apply partial)
(juxt
(constantly apply)
(constantly constantly)))
(comp
(partial apply juxt)
(juxt
(comp
(partial apply comp)
(juxt
(constantly last)
(constantly
list)))))))))))))))))))))))))))))))))))
(comp
(partial apply juxt)
(juxt
(comp
(partial apply comp)
(juxt
(comp
(partial apply partial)
(juxt (constantly apply) (constantly zero?)))
(comp
(partial apply juxt)
(juxt
(comp
(partial apply comp)
(juxt (constantly last) (constantly list)))))))))))))
(comp (partial apply constantly) (juxt (constantly ())))))))))))
; user=> (factorial 7)
; 5040
@gfredericks

This comment has been minimized.

Copy link
Owner Author

commented May 11, 2011

Compiled from the code below, which is itself rather verbose because I haven't yet implemented

  1. recursion 2) map literals 3) if-statements
(fn [n]
  (let [f (fn [g n]
            (((hash-map true (constantly 1)
                        false (fn [] (* n (g g (dec n)))))
                (zero? n))))]
        (f f n)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.