Hi Ken,
> What does zipmap do if the key seq contains duplications?
It acts like a merge:
(zipmap
'(:a :b :c :d :c :c)
'(:A :B :C :D :E :F))
gives {:a :A :b :B :c :F :d :D}.
The input map itself seems to be irrelevant: the example I gave here
was synthetic just for simplicity.
--
You recei
What does zipmap do if the key seq contains duplications?
--
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.
--
You received this message because you
Hi all,
I've just run into what appears to be either some subtle transients
behaviour I'm misunderstanding, or a bug (I'm running the 1.3 beta).
Given the function:
(defn test-fn1
[map-context1]
(persistent!
(reduce
(ƒ [map-context2 key]
(when-not (get map-context2 key) (throw (
Hi,
maybe you just want a factory?
(defrecord Foo [a b])
(defn make-Foo
[a b]
(Foo. a b))
(defn make
[^String class & args]
(let [last-dot (.lastIndexOf class \.)
factory (ns-resolve (symbol (subs class 0 last-dot)) (symbol (str
"make-" (subs class (inc last-dot)]
(when
the oracle jdbc adapter returns a whole host of strange datatypes. for
instance, it returns bigdecimals for numbers you have mapped to be
numbers (with a precision, without a scale) in the table. it also
returns its own custom time classes. these generally have a toJdbc()
method to convert them to
On Tue, Aug 23, 2011 at 6:54 PM, HiHeelHottie wrote:
> Completely agree with you that it shouldn't automatically map out of
> the box. As a newbie to clojure and jdbc, do you have any advice on
> how I can get into resultset-seq* to do the mapping? I think it would
> be better not to have to map a
On Tue, Aug 23, 2011 at 9:54 PM, HiHeelHottie wrote:
> Are there any future plans to add a mapping api to resultset-seq or is
> the pattern just to chain any custom mappings after resultset-seq?
Is wrapping in (map double ...) too much typing? :)
--
Protege: What is this seething mass of parent
Hey Sean,
I really appreciate the quick response and your work with java.jdbc.
Completely agree with you that it shouldn't automatically map out of
the box. As a newbie to clojure and jdbc, do you have any advice on
how I can get into resultset-seq* to do the mapping? I think it would
be better n
No, you'd have to do it yourself. Since not all BigDecimal values
would fit correctly in double, it would be dangerous for resultset-seq
to do it.
I expect there are all sorts of JDBC data types that don't quite match
Clojure types but I don't think automatically mapping them would be a
good idea.
test=> (def foo-class-symbol (load-string "test.Foo"))
test=> (def foo (eval (list 'new foo-class-symbol 1 2)))
test=> foo
#:test.Foo{:A 1, :B 2}
Is that what you want?
On Aug 23, 6:24 pm, Timothy Baldridge wrote:
> Given:
>
> test=>(defrecord Foo [A B])
> test=>(class (Foo. 1 2))
> test.Foo
>
>
Hi,
It looks like Oracle NUMBER types get mapped to BigDecimal in a result
seq from clojure.java.jdbc. Is there an easy way to configure
clojure.java.jdbc/ResultSet to map Oracle NUMBERS to doubles?
The resultset-seq from
https://github.com/clojure/java.jdbc/blob/master/src/main/clojure/clojure
On Aug 23, 3:39 pm, Craig Andera wrote:
> > (Class/forName "java.lang.String")
>
> Oh, does that work in 1.3? Because (new (Class/forName "user.Foo"))
> was the first thing I tried (under 1.2) and it doesn't work. Perhaps
> unsurprisingly given that new is a special form.
No. But you can use refl
> (Class/forName "java.lang.String")
Oh, does that work in 1.3? Because (new (Class/forName "user.Foo"))
was the first thing I tried (under 1.2) and it doesn't work. Perhaps
unsurprisingly given that new is a special form.
--
You received this message because you are subscribed to the Google
Gro
> Given:
>
> test=>(defrecord Foo [A B])
> test=>(class (Foo. 1 2))
> test.Foo
>
> How do I:
>
> test=>(new "test.Foo" 1 2)
> #:test.Foo{:A 1, :B 2}
>
> Currently I get " Unable to resolve classname: test/Foo".
Check out
http://stackoverflow.com/questions/3748559/clojure-creating-new-instance-fro
> Given:
>
> test=>(defrecord Foo [A B])
> test=>(class (Foo. 1 2))
> test.Foo
>
> How do I:
>
> test=>(new "test.Foo" 1 2)
> #:test.Foo{:A 1, :B 2}
>
> Currently I get " Unable to resolve classname: test/Foo".
>
> Thanks,
>
> Timothy
(Class/forName "java.lang.String")
>
Be mindful of the
Given:
test=>(defrecord Foo [A B])
test=>(class (Foo. 1 2))
test.Foo
How do I:
test=>(new "test.Foo" 1 2)
#:test.Foo{:A 1, :B 2}
Currently I get " Unable to resolve classname: test/Foo".
Thanks,
Timothy
--
“One of the main causes of the fall of the Roman Empire was
that–lacking zero–they ha
> user=> (defn if-a [a b] (if (a) (str a) (str b)))
The problem is " (a) " - it tries to call a as a function, which
throws NullPointer if a is nil. You meant:
> user=> (defn if-a [a b] (if a (str a) (str b)))
mg
On Tue, Aug 23, 2011 at 9:37 PM, Andrew Xue wrote:
> this doesn't work:
>
>
You have an extra set of parens around a, treating it as a function call. Try:
(defn if-a [a b] (if a (str a) (str b)))
Hope that helps,
Dave
On Tue, Aug 23, 2011 at 4:37 PM, Andrew Xue wrote:
> this doesn't work:
>
> user=> (defn if-a [a b] (if (a) (str a) (str b)))
> #'user/if-a
> user=> (
this doesn't work:
user=> (defn if-a [a b] (if (a) (str a) (str b)))
#'user/if-a
user=> (if-a nil "b")
java.lang.NullPointerException (NO_SOURCE_FILE:0)
user=> (if-a "a" nil)
user=> java.lang.ClassCastException: java.lang.String cannot be cast
to clojure.lang.IFn (NO_SOURCE_FILE:0)
this does work
Did you use the "-cp" option to include the contrib when running
java.exe on clojure.jar? The error shows that it's looking in a
subdirectory with a .class rather than the packaged jar file.
I'd suggest using leiningen to avoid build problems like this.
On Aug 23, 6:10 am, Wanderfels wrote:
>
Wow nice! :-)
Of course wait-till can be done with Timers build-in JDK.
And here is a proposition for cron parsing function:
(defn parse-cron-expr[ pattern ]
(let[ cal (Calendar/getInstance) ]
(let [[min-pat hour-pat day-pat month-pat week-pat] (letfn[ (parse-cron[ val
pos cal ]
(letfn[ (range-
Hi,
Am 23.08.2011 um 18:01 schrieb Michael Jaaka:
> I have some challenge for you, sine it is easy express it in
> imperative language I would like to ask you if is it possible to
> create DSL to express such algorithm in clojure or if is it too
> complicated just write it in functional manner. T
After the post I suddenly saw the code in my mind: http://pastebin.com/kYYYirdb
The expression abilities are truly near the mind.
Clojure rox :-)
On Aug 23, 6:01 pm, Michael Jaaka
wrote:
> Hi!
>
> I have some challenge for you, sine it is easy express it in
> imperative language I would like to a
Hi!
I have some challenge for you, sine it is easy express it in
imperative language I would like to ask you if is it possible to
create DSL to express such algorithm in clojure or if is it too
complicated just write it in functional manner. The challenge is to
write cron algorithm. I can express
I was trying to construct a simple example of what I actually have in
my apps that use pooling on top of java.jdbc. My actual code *does*
work to create a singleton but you're right, I've contracted my code
too far in trying to create a simple example of it... I'll have
another attempt!
Sean
On A
In the ClojureScript case, you can do lazy compile time compilation
instead, where the predicate call is really a macro that always
expands into a predicate call but during compile time can check if the
tree needs to be updated. This isn't as lazy as the runtime version
but at least groups of exten
Hi
On 23 August 2011 12:10, Wanderfels wrote:
> Hello,
>
> win XP, clojure 1.2.1 and clojure.contrib-1.2.0.jar here. i want to
> learn clojure (background python and javascript and a bit Haskell) and
> are currently reading the pdf 'Programming Clojure' from 2009.
> In Chapter 1.3: 'Exploring Clo
Hello,
win XP, clojure 1.2.1 and clojure.contrib-1.2.0.jar here. i want to
learn clojure (background python and javascript and a bit Haskell) and
are currently reading the pdf 'Programming Clojure' from 2009.
In Chapter 1.3: 'Exploring Clojure Libraries' it says:
"
Clojure code is packaged in lib
On Tue, Aug 23, 2011 at 09:44, Mark Engelberg wrote:
> I had always assumed that vectors were sorted lexicographically. In
> other words, you sort on the first element, and then refine by the
> second element, and so on. I was surprised tonight to discover that
> is not the case.
>
>> (compare "
perfect answer.
thank you !
btw: my snippet is taken out of the docs for java.jdbc.
On Aug 22, 12:04 pm, "Meikel Brandmeyer (kotarak)"
wrote:
> Hope, I'm not too far off.
>
> Sincerely
> Meikel
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To po
I had always assumed that vectors were sorted lexicographically. In
other words, you sort on the first element, and then refine by the
second element, and so on. I was surprised tonight to discover that
is not the case.
> (compare "abc" "b"); Strings are compared lexicographically
-1
> (
31 matches
Mail list logo