Expand a vector into the arguments of a function
You can just use apply again: (apply addnums args)
You can just use apply again: (apply addnums args)
If I understand you correctly, ns-unmap should do what you want: user=> foo java.lang.Exception: Unable to resolve symbol: foo in this context (NO_SOURCE_FILE:1) user=> (def foo 1) #’user/foo user=> foo 1 user=> (ns-unmap (find-ns ‘user) ‘foo) nil user=> foo java.lang.Exception: Unable to resolve symbol: foo in this context (NO_SOURCE_FILE:1)
I wrote clojure.test, and I am working on a new framework, lazytest, with a more functional style.
Its now 11 months after I originally asked this question. I’ve just started a new project to help beginners make the transition to clojure. Its called 4clojure, and it challenges you to solve fill-in-the-blank style interactive problems. 4Clojure.com
Idiomatic Clojure favors defining independent functions that operate on a very small set of core data structures; this unbundling of methods and data is a strong statement against object orientation and in favour of a functional style. Rich Hickey (creator of Clojure) has repeatedly stated the importance of this; for example here: “Clojure eschews the … Read more
== is for comparing numbers. If either of its arguments is not a number, it will always return false: (== :a :a) ; => false As you can see by saying (clojure.contrib.repl-utils/source ==) at the REPL (with repl-utils require‘d, of course), == calls the equiv method of clojure.lang.Numbers. The relevant bit of clojure/lang/Numbers.java (from the … Read more
Require require loads a Clojure library so that you can use it in your current file or REPL. This is the normal way to access functions and definition in a Clojure library. Use use brings in a Clojure namespace in the same way as require, but in addition it refers to the definitions in the … Read more
core.clj is built from top to bottom, starting with just what Java provides and building up all the requirements for Clojure as it goes. When when is defined the syntax quote does not yet exist. The when macro is defined on line 456 of core.clj and the requirements for syntax-quote are not available until line … Read more
I think andih’s solution works great. Here is an alternate way because hey why not. It uses concat and distinct: user> (distinct (concat ‘(1 2 3) ‘(2 3 4))) => (1 2 3 4)
There is now a generalized threading macro in Clojure since 1.5 called as->. This tweet gives an example of how it works: https://twitter.com/borkdude/status/302881431649128448 (as-> “/tmp” x (java.io.File. x) (file-seq x) (filter (memfn isDirectory) x) (count x)) First ‘x’ is bound to “/tmp” and a file is made out of it. ‘x’ is rebound again to … Read more