Permalink
Browse files

First commit.

  • Loading branch information...
0 parents commit 53d33e9bc69f70cbf722e1329525bbd60b28d04b @Raynes committed Nov 18, 2011
Showing with 63 additions and 0 deletions.
  1. +5 −0 .gitignore
  2. +27 −0 README.md
  3. +5 −0 project.clj
  4. +13 −0 src/leiningen/findarg.clj
  5. +13 −0 src/leiningen/findfn.clj
@@ -0,0 +1,5 @@
+pom.xml
+*jar
+/lib/
+/classes/
+.lein-deps-sum
@@ -0,0 +1,27 @@
+# lein-findfn
+
+This is a little Leiningen plugin for finding functions/macros that do what you want to do.
+
+`lein findfn` takes a set of input values and an expected output value and then looks for functions in clojure.core, clojure.set, and clojure.string that, when called with those input values, return the output value you want.
+
+`lein findarg` is similar, but it looks up a function to pass to a higher order function to get what you want. This is best demonstrated with an example:
+
+```
+$ lein findarg map % [1 2 3] [2 3 4]
+clojure.core/unchecked-inc
+clojure.core/inc
+```
+
+In the above examples, % is the mysterious function that you're looking for.
+
+P.S.: This isn't necessarily guarenteed to work properly. ;)
+
+## Usage
+
+ lein plugin install lein-findfn 0.1.0
+
+## License
+
+Copyright (C) 2011 Anthony Grimes, Alan Malloy, Joshua Cole
+
+Distributed under the Eclipse Public License, the same as Clojure.
@@ -0,0 +1,5 @@
+(defproject lein-findfn "0.1.0"
+ :description "Find things."
+ :dependencies [[clojure "1.2.1"]
+ [findfn "0.1.1"]]
+ :eval-in-leiningen true)
@@ -0,0 +1,13 @@
+(ns leiningen.findarg
+ (:use [clojure.string :only [join]]
+ findfn.core))
+
+(defn findarg
+ "Find a function to pass to a higher order function to get a specific output value.
+
+Example: lein find-arg map % [1 2 3] [2 3 4]"
+ [& args]
+ (if-let [names (seq (apply find-arg (read-arg-string (join " " args))))]
+ (doseq [x names]
+ (prn x))
+ (println "Nothing was found.")))
@@ -0,0 +1,13 @@
+(ns leiningen.findfn
+ (:use findfn.core
+ [clojure.string :only [join]]))
+
+(defn findfn
+ "Find a var
+
+Pass the inputs followed by the expected output."
+ [& args]
+ (if-let [names (seq (apply find-fn (read-arg-string (join " " args))))]
+ (doseq [x names]
+ (prn x))
+ (println "Nothing was found.")))

0 comments on commit 53d33e9

Please sign in to comment.