Bitten apple

I happen to be one of the people who think Scala’s PartialFunction is pretty cool. I was missing it in Clojure, so I went ahead, and created this project. The README describes the motivation for the project, currently implemented functionality, and possible future directions. I have tried to keep the document as descriptive and as understandable as possible.

The current implementation is fairly straightforward. It essentially performs the following transformations:

(partial-fn [x y z]
            [4 5 _] 4
            [1 2 :a] 9)

; becomes

(fn [x y z]
  (match [x y z]
         [4 5 _] 4
         [1 2 :a] 9))

; becomes

{:fun        (fn [x y z]
               (match [x y z]
                      [4 5 _] 4
                      [1 2 :a] 9))

 :in-domain? (fn [x y z]
               (match [x y z]
                      [4 5 _] true
                      [1 2 :a] true
                      :else false))}
                      

Of course there is a bit more involved, but this is the crux of it.

It only took a few hours to implement this, but a type system and a greater prowess with Lisp macros would have helped me get there even faster.

Fork away!