> in db.clj
> I have
> (:require [some-library :as mylib])
> in api.clj:
> I have (:require [myapp.db :as db])
> I then want to call mylib/somefunction -
You can use "some-library/..." directly after requiring db, e.g;
xxlib.clj...
(ns xxlib)
(defn xxfoo [] :xxfoo)
db.clj...
(ns db
(:require
I would guess the problem is referring to T inside the deftype. This works;
(deftype T [] Object (equals [this o] (if (instance? (class this) o)
true false)))
(let [t (T.)] (.equals t t))
==> true
On Wed, Nov 3, 2010 at 12:39 PM, ka wrote:
> Clojure 1.2.0
> 1:1 user=>
> 1:2 user=>
> 1:3 user=>
Hi Dmitri,
The problem is probably related to calling init with args. It requires
that super() gets called - I can't remember where I saw the
documentation, but here's an example of what works for me.
The following is a generic servlet which gets passed a clojure
namespace name as an init paramet
> Just fixed this with some help from Hugo Duncan; best guess is it's a
> weird Mac encoding issue. Should be clear now though.
Hi Sean,
Noticed you're running java 1.5. Fwiw, I used to run 1.5 with Mac OSX
Leopard 10.5 (vanilla install) and I remember having a few "funnies"
with clj/java. I did
lojure up and running. You
> download one script, make it executable and run it to install
> Leiningen and then projects are as easy as 1. lein new myproject, 2.
> lein deps, 3. lein test - although I pretty much always add lein-run
> and I'm looking forward to it being built
I strongly support any initiative that does not assume maven is a given.
-Rgds, Adrian.
On Thu, Sep 9, 2010 at 5:03 AM, Sean Devlin wrote:
> Until you don't want to deal with maven, and just need a jar. Like if
> you're installing Enclojure & just want the stupid jars.
>
> On Sep 8, 3:42 pm, bu
e myComp)
true
On Wed, Sep 1, 2010 at 4:33 PM, Adrian Cuthbertson
wrote:
> Have a look at Stuart Halloway's video on protocols;
> http://vimeo.com/11236603
> and also clojure.core.protocols.clj in the 1.2 source code.
> A general google on clojure protocols also brings up some blogs
Have a look at Stuart Halloway's video on protocols;
http://vimeo.com/11236603
and also clojure.core.protocols.clj in the 1.2 source code.
A general google on clojure protocols also brings up some blogs in
which various people have some good examples and explanations.
Also note that deftype of cou
te:
> Hi,
>
> On 1 Sep., 07:33, Adrian Cuthbertson
> wrote:
>
>> There are probably ways of creating types on protocols, but I haven't
>> tried that yet.
>
> Clojure is a dynamically typed language. I don't think that putting
> types on protocols is very
Hi Albert,
I made sense of this by keeping the concept of defprotocol separate
from definterface and deftype. defprotocol is like multimethods and
deftype is like creating an implementation of an interface. You then
need to instantiate a new instance of the deftype to execute its
methods. The foll
Here's an approach that might work...
; app1.clj
(ns app1)
(defn myinc[x] (inc x))
(defn mydec[x] (dec x))
(defn .)
;app2.clj
(ns app2)
(defn mysq[x] (* x x))
then you have a mylib.clj which is your public "user" module;
(ns mylib)
(require 'app1 'app2)
(defn exports[]
(refer 'app1 :only
Hi Nicolas,
I've done a bit of manipulation of namespaces for dynamic loading and
executing of functions in a web app context which might give you some
ideas...
Here ns-nm and ipath have been extracted from a url. Then...
(let [ .
ipath (if (or (nil? ipath) (= ipath "")) "root" ipath)
ip
Hi Brian,
System/out
#
(System/out)
#
both return the "out" PrintStream object, so
(.. System/out (print "-"))
-nil
(.. (System/out) (print "-"))
-nil
(.. System/out (print "-"))
-nil
all invoke the print method on the java PrintStream object and
correctly return nil
as does...
(.print System/o
> :)
(inc ":)")
On Sat, Aug 7, 2010 at 7:27 AM, Meikel Brandmeyer wrote:
> Hi,
>
> Am 07.08.2010 um 05:06 schrieb j-g-faustus:
>
>> I don't think there's a direct way to create a String array in Clojure
>
> (defn to-env
> [env-vars-map]
> (->> env-vars-map
> (map #(str (name (key %)) "=" (
unable to find an
> online API there. http://richhickey.github.com/clojure/ is the only
> online API I have seen. And again, the other new 1.2 namespaces like
> clojure.java.io show up just fine there, which is why I'm confounded
> why clojure.string is not there.
>
&g
Hi Benny,
The 1.2 release source site has moved to
http://github.com/clojure/
-Regards, Adrian
On Sat, Jul 17, 2010 at 8:00 AM, Btsai wrote:
> Hi Clojurians,
>
> The recent 1.2 beta release is the first time I played with 1.2. When
> reading the release notes, I saw a number of new namespaces.
Apparently there's a problem with git clone http://...
Should be git clone git://github.com/clojure/clojure.git
Sorry for the noise.
On Thu, Jul 15, 2010 at 3:57 PM, Adrian Cuthbertson
wrote:
> I'm trying...
> git clone http://github.com/clojure/clojure.git
> and getting
I'm trying...
git clone http://github.com/clojure/clojure.git
and getting the following error...
Getting pack 9be7389ab68fea4a8309596c2916961599d2b06c
which contains 833f9f368d2274766aa4699195b3fba3f9e4e8f0
error: Unable to get pack file
http://github.com/clojure/clojure.git/objects/pack/pack-9be
Hi Sean,
I think there are two ways to do this;
1) Use an agent. You can "send-off" a fn to the agent with your
select/update logic and this will run within the agent thread -
guaranteed to be serial so you only need your select/update and no
retry logic. The state of the agent is not important -
> To test with pooled DB connections I thought I'd mention Apache Commons
> dbcp. Its a generic connection pool library that could be used for any jdbc
> connection.
There's also the lighter-weight MiniCollectionPoolManager. See
http://www.source-code.biz/snippets/java/8.htm
-Regards, Adrian.
--
> I think it is the var that should be hinted. In practice you probably
> have a function which could have a hinted arg.
That's it! Thanks Karl.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups
I don't seem to be able to get rid of reflection warnings on
definterface/deftype field/method calls...
Clojure 1.2.0-master-SNAPSHOT
user=> (set! *warn-on-reflection* true)
true
(import '(java.io File))
java.io.File
(definterface IFile (^String getNm[]))
(deftype TFile [^File file] IFile (^String
Sorry, you don't need the type hists just the "this" arg...
(seq (.list (java.io.File. ".") (reify java.io.FilenameFilter (accept
[_ f s] (not (.startsWith s "."))
On Tue, Jun 29, 2010 at 3:35 PM, Adrian Cuthbertson
wrote:
> You need the "this
You need the "this" arg and I find you need to hint the exact types
when reifying java interfaces;
(seq (.list (java.io.File. ".") (reify java.io.FilenameFilter
(^boolean accept [_ ^java.io.File f ^String s] (not (.startsWith s
"."))
... works for me.
- Rgds, Adrian
--
You received this me
> 1. Have you written, or are you writing, a web application that uses
> Clojure? What does it do?
I am and have been extending an existing production java web
application environment with all new server work now being done in
clojure. It is a complex jvm server running tomcat and other threaded
p
> You can use Compojure to build webapp in more convenient way.
I should elaborate on my previous post. It was intended not to
recommend the clojure way of building web apps (there's plenty of info
regarding that - compojure, ring, clout, hiccup, conjure, etc), but
rather as a specific, detailed e
> 1. Loading .clj files
> Is it possible to load up .clj files from the classpath of an
> arbitrary java app? For example, could you proxy HttpServlet and run
> your servlet as a .clj from within a servlet container?
Hi Todd, here's a pattern for doing what you want;
1.) Create svlt/Svlt.clj as b
The do form (see http://clojure.org/special_forms#do) only
encapsulates forms and returns the value of the last form evaluated.
The forms generally perform some side effect (otherwise they would be
superfluous). An example of where it's useful is with an if...
(if some-pred return-something
(do (
Hi Jared,
Some good clojure specific learning resources;
http://java.ociweb.com/mark/clojure/article.html
and the essential http://clojure.org/
- Regards, Adrian
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to
You can also use a multiline string in a comment...
(comment "
To do: x y z
More to do: a b c
")
-Rgds, Adrian.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from ne
> Is that a bug or is there a usage rule I'm missing?
seems so - underscore in the definterface method works...
(definterface INm (^String get_nm []))
==> user.INm
(deftype Nm[nm] INm (^String get-nm [this] (str "Mr " nm)))
(.get-nm (Nm. "Smith"))
==> "Mr Smith"
--
You received this message be
Hi,
It seems definterface/deftype have a problem with "-" in the method name...
... Clojure 1.2.0-master-SNAPSHOT (today)
(definterface INm (^String get-nm []))
==> user.INm
(deftype Nm[nm] INm (^String get-nm [this] (str "Mr " nm)))
==> java.lang.IllegalArgumentException: Can't define method no
Also have a look at Christophe's excellent "Taming multidim Arrays"...
http://clj-me.cgrand.net/2009/10/15/multidim-arrays/
-Rgds, Adrian
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
N
> That said, I'd rather make sure that my low-level data structures are being
> operated on by only one implementation.
You could use closures to encapsulate the refs/atoms ...
(let [car-mem (ref nil)]
(defn set-car-mem [new-car-mem]
(dosync (ref-set car-mem new-car-mem)))
(defn update-
On Fri, May 21, 2010 at 4:57 AM, Mibu wrote:
> I tried to use Long keys from the java.io.File/length method in a hash-
> map and failed to retrieve values using them. sorted-map is fine. The
> doc says hash-maps require keys that support .equals and .hashCode.
> Doesn't Long support those or am I
> thanks for the hint. I looked into clojure.core and similar files,
> and didnt find much use of *err*.
>
There are a few in clojure.contrib. Have a look at logging.clj,
repl_ln.clj, server_socket.clj, internal.clj and utilities.clj.
(doc *in*)
-
clojure.core/*in*
A ja
On Wed, May 19, 2010 at 9:06 AM, alux wrote:
> Any comment here?
(defn spawn-repl [socket]
"spawns a repl on a given socket"
(let [input (new LineNumberingPushbackReader
(new InputStreamReader (.getInputStream socket)))
output (new PrintWriter (.getOutputStream sock
> Actually, it seems to do what I thought.
Right, indeed
(satisfies? PStr ss)
-> true
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated -
> What is the canonical way to know whether something satisfies (is satisfies
> the right terminology?) a protocol.
You're looking for extends? ...
(doc extends?)
-
clojure.core/extends?
([protocol atype])
Returns true if atype extends protocol
(defprotocol PStr "String
Hi Base,
It's useful to think of the "pattern" of loop/recur and then apply it
to your problem. I.e
(loop [-- initial bindings --]
(if --- terminating condition ---
---return result---; otherwise...
(do-stuff with bindings
(recur ---with new bindings---
A simple examp
I don't think there's a way to do it with :keys, but could you use
individual key destructuring? I.e;
(let [{x :x/y} {:x/y 20}] x)
20
-Rgds, Adrian.
On Thu, May 13, 2010 at 6:47 PM, David McNeil wrote:
> Is there a way to destructure namespace qualified map keys?
>
> I want to do something like
Some time ago I experimented with migrating definitions between
namespaces. Here's a post from then that covers some lower-level
detail regarding namespaces.
http://groups.google.com/group/clojure/msg/f00a82b747c1636f
-Hth, Adrian.
On Mon, May 10, 2010 at 12:15 AM, Mark Engelberg
wrote:
> The m
> simple, you'd be embarrassed to admit that you didn't see WHAT WAS
> STARING YOU IN THE FACE all along?
Don't be too hard on yourself - it takes a while for the clojure
patterns to sink in so you easily spot the simple errors. Best to
throw it out there so someone else can help.
Gen-class is a
(last p) returns a char \/
(first p) returns \B)
so, use (= (str (last p)) sep)
-Rgds, Adrian.
On Wed, Apr 28, 2010 at 3:30 PM, WoodHacker wrote:
> Can someone explain to me why this doesn't work:
>
> (let [ p "Bill/"
> sep (System/getProperty "file.separator")
> ]
>
>
Not sure about your specific case, but when you don't get back
expected results it's usually due to the functions called being lazy.
Try doall or dorun to force the iterations.
-Rgds, Adrian.
On Tue, Apr 27, 2010 at 12:25 AM, David McNeil wrote:
> I am experimenting with clojure.test and I encou
> I hereby cast my vote into the void: release often; release 1.2
> soon. :-)
(inc (fetch void))
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are modera
You could perhaps also try format;
(println (format "%5.2f" 10.2)))
-Rgds, Adrian
On Thu, Apr 1, 2010 at 7:27 AM, Mark Engelberg wrote:
> printf doesn't seem to do anything inside a gen-class -main function, when
> run from the executable jar program (compiled by the latest Netbeans
> Enclojure
f a lengthy exposition on this topic last year after
experimenting with modifying namespaces. Perhaps that will give you
some ideas. See below...
>On Sun, Aug 30, 2009 at 8:46 AM, Adrian Cuthbertson
> wrote:
>> Is there a way to unregister some names from a namespace without reload
You asked for it! What's the bet there are at least 50 responses to
your post. How about;
natty, nattle, clonat, or just nat.
-Rgds, Adrian.
On Wed, Mar 17, 2010 at 9:08 AM, mac wrote:
> After just a little more test and polish I plan on calling clj-native
> 1.0. But clj-native is a *really* bor
There's a fundamental law of nature that says; if you don't try it at
the repl before posting, you WILL get it wrong :-).
On Mon, Mar 8, 2010 at 5:19 PM, Meikel Brandmeyer wrote:
>
>> (let [{:keys host port user password} config]
>> (.connect store host port user password))
>
> module missing
Maybe just;
(let [{:keys host port user password} config]
(.connect store host port user password))
On Mon, Mar 8, 2010 at 9:47 AM, Michael Gardner wrote:
> Given a Java instance 'store' with a .connect method that takes a host, port,
> user and password, and given a hash-map 'config' with co
Hi Ivar,
> ;; Do things such as hash-map comprehensions exist? Should they? ;-)
> (defn some-eqn3 [obj]
> (let [{:a a :b b :c c} obj]
> (/ (+ (- b) (sqrt (- (* b b) (* 4 a c
> (* 2 a
At least a partial stab at some of your questions...
(def myhash {:a 1 :b 5 :c 6 :x nil})
(defn s
Hi Dan, you need to include an arg for "this" in -fooMeth, i.e
(defn -fooMeth [this] "fooMeth")
or
(defn -fooMeth [_] "fooMeth")
- Rgds, Adrian
On Sun, Feb 28, 2010 at 12:06 AM, Dan Becker wrote:
> Hi,
>
> I'm trying to write a java class in clojure, and then call it from
> java. But I keep get
You can also do stuff in the middle of a let;
(let [a vala
b valb
_ (do-something-with a b)
c (some-fn a b)
d (some-fn a b)
_ (do-something a b c d)
e (fn ...)
f (fn )]
(and-whatever-else))
Here _ is just some arbitrary unused variable.
Note that y
Try including [*print-dup* true] in the binding;
(defn write-nick-sets [file-name obj]]
(with-open [w (FileWriter. (File. file-name))]
(binding [*out* w *print-dup* true] (prn obj
You can read it back with;
(defn rec-load
"Load a clojure form from file"
[#^File file]
(with-open [
> Diversity is good. Nice work.
I concur. There is a huge body of Jsp code out there and many
thousands even millions of J2EE developers who work with it. Tools
that bridge the Clojure/J2EE gap are very welcome.
Additionally, looking at the the Fleet library it seems well designed
and written, an
Have a look at clojure/core_print.clj in the clojure source. It is
indeed used with serialization - see print-dup. Here's an example of
usage;
(import '(java.io File FileWriter PushbackReader FileReader))
(defn rec-save
"Save a clojure form to file. Returns the called form."
[#^File file frm]
I concur with Garth - structures like coordinates, points, etc are
non-changing in their structure and hence don't need "mapped"
references into their elements. Destructuring is the easy way to get
at the elements;
(let [[x y z] pt] ...
and they can be combined in collections, arrays, etc, and mani
Here's an idiomatic way of doing what you want;
(defn lp [col]
(loop [ll (seq col)]
(when ll
(try
(let [itm (first ll)]
(if (= itm 'x) (throw (IllegalArgumentException.
(str itm " not supported.")))
(println (str "done item: " itm
I'd like to pitch in here as I think it's distressing to see (vim
familiar) people abandoning clojure when it's quite possible to have
an easy and very efficient working environment using just vim,
vimclojure and rlwrap. I set this up 14 months ago when I started with
clojure and I'd be dragged kic
In the doc for dotimes, the "bindings" are required as "name n" (see below).
Hence (dotimes [i 5] ... ) is the only pattern. Check out (doseq and (for
for what you're trying to do.
user=> (doc dotimes)
-
clojure.core/dotimes
([bindings & body])
Macro
bindings => name n
>How about the intricacies of syntax-quotes and in particular, nested
>syntax-quotes?
Yeah, +1.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderat
>> >> I vote let's turn this into a clojure vacation, and hold it in an
>> >> exotic location.
Well, how about Johannesburg or Cape Town. Sort of equidistant from
the US, Europe, Asia and Aus. Also if you wait a month or two you can
get to watch a soccer (footie) match or three as well :).
--
Yo
Hi Sean,
The background to this lies in the implementation of lazy sequences -
seq returns an implementation of ISeq for the data structure in
question - nil when there are no elements in the structure. Have a
look at http://clojure.org/sequences and also http://clojure.org/lazy
which gives the fu
How about;
(defn reflection-dump [o]
(let [methods (seq (.getDeclaredMethods o)) ]
(str
o " has " (count methods) "methods...\n"
(second (reduce (fn [[i st] meth] [(inc i) (str st "meth" i ": "
meth "\n")]) [0 ""] methods)
(print (reflection-dump java.io.InputStream))
class java
Hi Greg, here's a sample but realistic pattern of the sort of thing
you're doing;
(import '(java.io BufferedReader FileReader File IOException)
'(bqutils BQUtil))
(defn samp-loop
"Read a csv file containing user records."
[#^String fpath]
(with-open [r (BufferedReader. (FileReader. (File
> (reduce (fn [model f] (assoc model f (inc (get model f 1
>{} features))
> Do Clojurians usually arrange like that? Can it be rearrange for more
> understandability?
I would write it exactly like that. What happens as you become
familiar with Clojure is that the patterns of the api b
Hi Towle,
Judging by the articulateness of your post, I would say that Clojure
would definitely be an ideal language for what you are looking for. It
is not "handed to you on a plate" and you will have to engage deeply
to achieve your goals, but if you do so, along with the increasingly
prolific d
For a data analysis/reporting application, I use colt for some matrix
processing, joda time for period calculations, jfreechart to generate
charts, an adaptation clj-html to create some dynamic html, also now
some StringTemplate templates to bring in and manipulate static
content and finally all th
Hmm, someone else has made another "closure" available :).
http://googlecode.blogspot.com/2009/11/introducing-closure-tools.html
-Adrian.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to t
> (let [x nil]
> ;; do something and modify 'x'
> )
>
>how does one modify the value of 'x' ?
Hi Chick, there's nothing stopping you re-binding x within the let
construct, eg;
(defn myfn [x]
(let [x (if (or (nil? x) (< x 0.2)) 0.0 x)
x (if (>= x 0.8) 1.0 x)]
quot; (println "HasdfasdfasdfasdfasdfasdfasdfasdfI")))
(.start th)
nil
HasdfasdfasdfasdfasdfasdfasdfasdfI
(.getName th)
"foo"
- Adrian.
On Mon, Oct 19, 2009 at 7:18 AM, Adrian Cuthbertson
wrote:
> The following seems to do it;
>
> (defmacro with-thread [nm & body]
> `(let [thre
The following seems to do it;
(defmacro with-thread [nm & body]
`(let [thread# (Thread. (fn [] (do ~...@body)))]
(if ~nm (.setName thread# ~nm))
(.start thread#)
thread#))
(with-thread "foo" (println "HasdfasdfasdfasdfasdfasdfasdfasdfI"))
#
user=> HasdfasdfasdfasdfasdfasdfasdfasdfI
I was just trying out str-utils2 when Stuart posted. Here's an example;
(require '[clojure.contrib.str-utils2 :as s])
(s/replace "hello Jung" #"hello (\S+)" #(str "hello, how are you "(% 1)))
"hello, how are you Jung"
Rgds, Adrian.
On Tue, Sep 29, 2009 at 4:58 PM, Stuart Sierra
wrote:
>
> Hi
Generally I use the source code for clojure and contrib documentation.
I open an instance of Jedit on the source directory and use it's
search/grep facilities to find what I'm looking for. It also helps in
familiarising with the clojure and contrib implementations and
learning the techniques used.
If y're Sco'ish... -> 59
(dotimes[i 4](println"Appy Birthdy"({2"D'r XXX"}i"To Ye")))
Appy Birthdy To Ye
Appy Birthdy To Ye
Appy Birthdy D'r XXX
Appy Birthdy To Ye
On Fri, Sep 18, 2009 at 6:35 AM, David Nolen wrote:
> hiredman in the lead!
> (dotimes[i 4](println"Happy Birthday"({2"Dear XXX"}i
There's also re-split in str-utils in clojure.contrib;
(use 'clojure.contrib.str-utils)
(re-split #"\s" "The quick brown fox")
=> ("The" "quick" "brown" "fox")
You can then use all the good clojure collection functions;
(def words (re-split #"\s" "The quick brown fox"))
(some #{"brown"} words)
Alternatively, if really meant to use defn then it should have been;
(defn vect1 [] [1 2 3 4])
#'user/vect1
user=> (* (count (vect1)) 5)
20
On Mon, Sep 14, 2009 at 2:28 PM, Adrian Cuthbertson
wrote:
> Hi Jeff, you're using defn which defines a function instead of def
>
Hi Jeff, you're using defn which defines a function instead of def
which defines a var;
(def vect1 [1 2 3 4])
#'user/vect1
user=> (* (count vect1) 5)
20
Rgds, Adrian.
On Mon, Sep 14, 2009 at 8:05 AM, Jeff Gross wrote:
>
> I have a vector that I need to count the size of and do a simple math
>
You need to pass the object to (class, e.g...
user=> (class "a")
java.lang.String
user=> (class String)
java.lang.Class
user=> (class 1)
java.lang.Integer
(So String is actually a Class object).
Rgds, Adrian.
On Thu, Sep 10, 2009 at 5:00 PM, Gorsal wrote:
>
> Hello. I'm trying to use (class St
What about a golf competition on the golf competition scorer? Then we
can evaluate that using;
(defmacro score-scorer [scorer] ... )
:)
- Adrian
On Thu, Sep 10, 2009 at 8:12 AM, Christophe Grand wrote:
>
> I propose to compute the score of a golf competition entry using this
> function:
> (d
> Could you put it on GitHub anyway? It would be a good way to evaluate
> it.
+1 - I'd be interested in using it.
- Adrian.
On Thu, Sep 10, 2009 at 6:40 AM, Sean Devlin wrote:
>
> Could you put it on GitHub anyway? It would be a good way to evaluate
> it.
>
> On Sep 10, 12:36 am, Richard New
Clojure's compare;
(compare \a \b)
-1
user=> (doc compare)
-
clojure.core/compare
([x y])
Comparator. Returns 0 if x equals y, -1 if x is logically 'less
than' y, else 1. Same as Java x.compareTo(y) except it also works
for nil, and compares numbers and collections
I mostly revert to good ole loop/recur for these large file processing
exercises. Here's a template you could use (includes a try/catch so
you can see errors as you go);
(import '(java.io BufferedReader FileReader PrintWriter File))
(defn process-log-file
"Read a log file tracting lines matchi
> Is there a way to unregister some names from a namespace without reloading it
> ?
This is a bit trickier than one might think. An example illustrates this;
Given two files, a.clj...
(ns a)
(defn stuff-a [] :stuff-a)
(defn hello [] :hello)
And b.clj...
(ns b)
(defn stuff-b [] :stuff-b)
Say w
> (defn fzipmap [f col]
> "Takes a col, applies f to each element and generates a
Note that the args should have come after the doc string!
On Tue, Aug 25, 2009 at 6:20 AM, Adrian
Cuthbertson wrote:
> For completeness we should include a loop/recur pattern;
>
> (defn fzipm
Also just what I needed - thanks!
On Mon, Aug 24, 2009 at 8:05 PM, Dragan Djuric wrote:
>
> It may look silly, but that's just what I need AND the last time I
> checked
> it didn't work!
> Now it does :)
>
> Thanks!
>
>> On Aug 24, 7:14 pm, samppi wrote:
>> I just discovered something cool that
For completeness we should include a loop/recur pattern;
(defn fzipmap [f col]
"Takes a col, applies f to each element and generates a
hash map keyed on each element of col."
(loop [col (seq col) mp {}]
(if col (recur (next col) (assoc mp (first col) (f (first col
mp)))
user=
Hi Raphaël,
If you're going to drive your app (and server) from clojure, then you
can use Compojure's jetty.clj module. This allows you to create a
servlet holder (in which you can add an instantiated Jwt servlet on a
jetty url path). Compojure also supports the Ring protocol, so you can
also the
Hmm, not so sure this is related, but I've often thought it would be
great to have some way of having "embedded" source of other types as a
"special" string defined as normal in the clojure source but marked in
such as way that the editor (vim, emacs, etc) could recognise this and
do formatting, s
Hi Rob, have a look at http://clojure.org/sequences and then on that
page there's a reference to http://clojure.org/lazy, which explains
the evolution of the lazy/eager sequences. Next is used for eager
cases (e.g loop/recur) and rest for lazy-seq. Should make sense if you
check out those referenc
I get around this for servlets by combining gen-class and proxy in my
servlet file;
(ns my-servlets.MyServlet
(:import (javax.servlet.http HttpServlet HttpServletRequest
HttpServletResponse))
(:gen-class :extends HttpServlet)
)
(defn req-do
[#^HttpServlet svlt #^HttpServletRequest r
You can also pass functions (and closures) around in a map;
(defn my-app-uses-do-something
[map-with-cfg-stuff]
...
((:do-something map-with-cfg-stuff) 13 19)) )
(defn do-something-quickly [x y] ...
(defn do-something-elegantly [x y] ...
(my-app-uses-do-something
{:do-something do-somet
It's also worth searching this group for 'performance' and checking
out the discussions over the past few months. There've been lots of
queries about many different aspects of performance and some really
good advice dispensed.
- Adrian.
On Wed, Jul 15, 2009 at 3:39 PM, Frantisek Sodomka wrote:
>
Hi Nicolas, sorry, that last post missed the second part, I meant to add;
If you know the method you wish to call, do you not know the class and can
thus call the static method directly?
-Adrian.
On Tue, Jul 7, 2009 at 5:21 AM, Adrian Cuthbertson <
adrian.cuthbert...@gmail.com> wrote:
You can call the static method directly on the class name;
(java.nio.ByteBuffer/allocate 1024)
or just (ByteBuffer/allocat 1024)
if it's imported.
Rgds, Adrian.
On Tue, Jul 7, 2009 at 2:16 AM, Nicolas Buduroi wrote:
>
> I've just figured out that the macro version in the allocate example
> ca
You could use assoc-in...
(def rms (ref {:key1 {:key2 {:key3 #{))
(dosync (alter rms assoc-in [:key1 :key2 :key3] "foo"))
{:key1 {:key2 {:key3 "foo"}}}
Rgds, Adrian.
On Sun, Jul 5, 2009 at 6:07 AM, Rowdy Rednose wrote:
>
> Say I have a data structure like this
>
> (def ref-map-map-map-set
#'user/test-2-s
> user=> (def accessor-a (accessor test-s :a))
> #'user/accessor-a
> user=> (accessor-a (struct test-2-s 5 3 2))
> java.lang.Exception: Accessor/struct mismatch (NO_SOURCE_FILE:0)
>
> But thanks for the tip anyway!
>
> On Jun 29, 6:47 pm, Adrian Cu
As a matter of interest, one can get the keys keys in an unknown struct by
allocating an empty struct;
(def st (create-struct :a :b :c))
(keys (struct st))
(:a :b :c)
-Adrian.
On Tue, Jun 30, 2009 at 12:14 AM, samppi wrote:
>
> Wonderful. Thanks for the answer.
>
> On Jun 29, 2:47 pm, Rich Hic
> I need some pointers on this. This is a really crucial thing for me and
> any help will be appreciated.
Here's one - better warn them not to let on what the startup is. Someone
here will get it to market an order of magnitude quicker than they will on
some other platform :-).
On Thu, Jun 25, 2
1 - 100 of 169 matches
Mail list logo