Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Silly example - close over s (say a string) returning an instance
- of an anonymous type that acts like a ClojureScript collection
- (defn make-conjable [s]
- (reify
- ICollection
- (-conj [_ c] (str s c))))
- */
- function make_conjable(s) {
- // check if the anonymous type is already memoized
- if (cljs.core.truth_(cljs.core.undefined_QMARK_.call(null, cljs.user.t4240))) {
- // define type
- cljs.user.t4240 = (function (s, make_conjable) {
- this.s = s;
- this.make_conjable = make_conjable;
- });
- cljs.user.t4240.prototype.cljs$core$ICollection$ = true;
- cljs.user.t4240.prototype.cljs$core$ICollection$_conj = (function (_, c) {
- var this__4241 = this;
- return cljs.core.str.call(null, this__4241.s, c);
- });
- } else {
- }
- // instantiate w/ closed over locals
- return (new cljs.user.t4240(s, make_conjable));
- }
Add Comment
Please, Sign In to add comment