Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. (defn foo [a context]
  2. (-> a
  3. inc
  4. (#(bar % context))))
  5.  
  6. (defn bar [a context]
  7. (cond (= context 1) (* a 2)
  8. (= context 2) (/ a 2)))
  9.  
  10. (ns main)
  11.  
  12. (defn foo [a]
  13. (-> inc
  14. ('bar (ns-map *ns*))))
  15.  
  16. (ns context-1
  17. (use main))
  18.  
  19. (defn bar [a]
  20. (* a 2))
  21.  
  22. (ns context-2
  23. (use main))
  24.  
  25. (defn bar [a]
  26. (/ a 2))
  27.  
  28. (defn context-1-foo [a]
  29. (let [base-ns *ns*]
  30. (in-ns 'context-1)
  31. (let [result (foo a)]
  32. (in-ns (ns-name base-ns))
  33. result)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement