Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 27 lines (18 sloc) 0.716 kb
7f5befe @technomancy Call it 1.0.0; create readme.
authored
1 # serializable fn
2
3 This simple little tweak lets you create functions which show nice
4 representations when printed rather than just their compiled class.
5
6 Which is nicer, be honest:
7
8 ;; raw Clojure behaviour
9 user> (fn [x] (inc (inc x)))
10 #<user$eval__1750$fn__1751 user$eval__1750$fn__1751@927e4be>
11
12 ;; with serializable-fn
06a699c @technomancy Release 1.1.2.
authored
13 user> (require '[serializable.fn :as s])
7f5befe @technomancy Call it 1.0.0; create readme.
authored
14
06a699c @technomancy Release 1.1.2.
authored
15 user> (def dinc (s/fn [x] (inc (inc x))))
7f5befe @technomancy Call it 1.0.0; create readme.
authored
16 (fn [x] (inc (inc x)))
17 user> ((eval (read-string (pr-str dinc))) 0)
18 2
19 user> ^ niiiiiiiiiiiiice!
20
21 ## License
22
06a699c @technomancy Release 1.1.2.
authored
23 Copyright © 2010-2012 Seajure, The Seattle Clojure group and contributors
7f5befe @technomancy Call it 1.0.0; create readme.
authored
24
7c9bc85 @technomancy Release dual-licensed 1.1.4.
authored
25 Distributed under the Eclipse Public License 1.0 as well as the Apache
26 License 2.0.
Something went wrong with that request. Please try again.