
- #USING CLOJURE WITH NEDIT HOW TO#
- #USING CLOJURE WITH NEDIT FULL#
- #USING CLOJURE WITH NEDIT CODE#
- #USING CLOJURE WITH NEDIT ZIP#
Square brackets, respectively) may be driving you a bit bonkers. Test are just libspecs in these situations, so you can use theġ user=> ( require ' ( clojure test )) 2 nil 3 user=> ( string/join ) 4 "123"Īt this point, the variation between list and vector notation (parentheses and Here, clojure is the prefix for both of the libraries we want, so Same in several libraries you want to load:ġ user=> ( require ' ( clojure string test )) 2 nil One last way to use require simplifies things when a prefix is the You can also mix and match symbols with vectors:ġ user=> ( require 'clojure.string ' ) 2 nil 3 user=> ( test/is ( = 1 1 )) 4 true Will take an arbitrary number of libspecs, such as the quoted symbolĪnd vector we’ve just seen. The same concepts apply to using requiring multiple namespaces: require The strange looking quoted vector is a shorthand to avoid having to quote every Namespace, and you’d get the same result:ġ user=> ( require ' ) 2 nil 3 user=> ( string/capitalize "foo" ) 4 "Foo" Refer to a string namespace rather than a clojure.string There’s also a way to alias namespaces when you require them, such that you could
#USING CLOJURE WITH NEDIT CODE#
Something to keep in mind as you write your own Clojure code and have need to require it That particular case is already true within the Clojure jar, but it’s So in order to require clojure.string, you’d need a directory namedĬlojure relative to your classpath, and a file called string.clj It’s worth noting here that the name of the lib itself parallels the directory structure, There’s a way around that (mainly for interactive development), as we’ll see later on,īut for now, just start up a new repl as you’re trying these out. Require a lib a second time, nothing will happen. Keep in mind that I’m starting a fresh repl for each of these examples, toĭemonstrate what happens the first time you load a lib.
#USING CLOJURE WITH NEDIT ZIP#
We can also pass multiple quoted symbols:ġ user=> ( require 'clojure.string 'clojure.test ) 2 nil 3 user=> ( clojure.string/join " " ) 4 "name address city state zip email phone" 5 user=> ( clojure.test/is ( = 1 2 )) 6 7 FAIL in $EmptyList 1 ( NO_SOURCE_FILE :10 ) 8 expected : ( = 1 2 ) 9 actual : ( not ( = 1 2 )) 10 false
#USING CLOJURE WITH NEDIT FULL#
Namespace named by that symbol available with the full namespace/var-name Takes a few different types of arguments.įirst, we could pass a single quoted symbol, and require will make the Let’s take a moment to examine this, the most basic syntax for So let’s tell the repl that we’reġ user=> ( require 'clojure.string ) 2 nil 3 user=> ( clojure.string/split "name,address,city,state,zip,email,phone" # "," ) 4 That get auto-required into the user namespace when the repl starts up,īut clojure.string isn’t one of them. There are a few namespaces ( re, t, etc.) Whoops! We forgot to actually tell Clojure that we’re going to be using that namespace. Let’s try to use split to break up the first line of aġ user=> ( clojure.string/split "name,address,city,state,zip,email,phone" # "," ) 2 : clojure.string ( NO_SOURCE_FILE :0 ) Version of Clojure (1.2), there’s a library called clojure.string whichĬontains some useful functions like split, join, and Let’s say we want to use some of Clojure’s built-in string operations. However, since require, use,Īnd import are what you’ll often use in the repl, and because thoseĪre used behind the scenes, we’ll start there. Later, we’ll see the ns macro, which is much more idiomatic, and that’s what If you already have the jar, just fire up a repl using Let’s start a Clojure repl, where we’ll outline ), but I thought it might be helpful to give an overview of the various calls you The design discussion around namespaces in the Clojure Confluence Now, I won’t spend time moaning about the current state of namespaces (see I find myself apologizing that it’s a bit complex and confusing.
#USING CLOJURE WITH NEDIT HOW TO#
Whenever I’m showing a newcomer to Clojure how to bring in code from other namespaces,
