Guest User

Untitled

a guest
Jan 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. /*
  2. Silly example - close over s (say a string) returning an instance
  3. of an anonymous type that acts like a ClojureScript collection
  4.  
  5. (defn make-conjable [s]
  6. (reify
  7. ICollection
  8. (-conj [_ c] (str s c))))
  9. */
  10.  
  11. function make_conjable(s) {
  12. // check if the anonymous type is already memoized
  13. if (cljs.core.truth_(cljs.core.undefined_QMARK_.call(null, cljs.user.t4240))) {
  14. // define type
  15. cljs.user.t4240 = (function (s, make_conjable) {
  16. this.s = s;
  17. this.make_conjable = make_conjable;
  18. });
  19. cljs.user.t4240.prototype.cljs$core$ICollection$ = true;
  20. cljs.user.t4240.prototype.cljs$core$ICollection$_conj = (function (_, c) {
  21. var this__4241 = this;
  22. return cljs.core.str.call(null, this__4241.s, c);
  23. });
  24. } else {
  25. }
  26. // instantiate w/ closed over locals
  27. return (new cljs.user.t4240(s, make_conjable));
  28. }
Add Comment
Please, Sign In to add comment