The value of 'maps' can be, for example; [{:lat 1 :lng 4} {:lat 2 :lng 3}].
If you enter (min [{:lat 1 :lng 4} {:lat 2 :lng 3}]) in the repl the result
will be {:lat 1 :lng 3}
If you replace 'min' by its definition you get;
(min [{:lat 1 :lng 4} {:lat 2 :lng 3}])
=>
(zipmap [:lat :lng]
(
AFAIK there are two options.
You can add a symbol after fn:
(let [fib (fn y [x]
(cond
(< x 2) x
:else (+ (y (- x 2)) (y (- x 1)]
(fib 5))
Or, as Bobby already suggested, you can use letfn:
(letfn [(fib [x]
(cond
(<
There is no need to push jdbc drivers to clojars.
I have never used Vertica but perhaps it helps if I show you how to add the
two jdbc-drivers that I do use.
Example 1; postgres
The details for the postgres-driver can be found here:
http://mvnrepository.com/artifact/org.postgresql/postgresql
You can wrap s/keys in s/and to add additional predicates, eg;
(s/and (s/keys) #(or (::secret %) (and (::user %) (::pwd %
You can also match the map with a predicate instead of s/keys, eg;
#(and (map? %) (or (::secret %) (and (::user %) (::pwd %
The the first option, with s/keys, will c
It's like magic. I added some specs to cljc namespaces and it just works!
I'm making domain specific error messages with just a few lines of code.
This is a huge leap forward.
Thank you, and all involved, so much.
--
You received this message because you are subscribed to the Google
Groups "Cl
Check out the presentation that Tommy Hall gave at EuroClojure:
https://vimeo.com/100425264
>From slide 12 onward he describes his Clojure implementation of geomlab and
how it can be used to teach children how to program
--
You received this message because you are subscribed to the Google
Gro
You could use 'select-keys' to filter the hashmaps;
(defn submap?
[m1 m2]
(= m1 (select-keys m2 (keys m1
(filter (partial submap? {:quad-col 0 :quad-row 0}) test-galaxy)
(filter (partial submap? {:sec-row 4 :sec-col 4}) test-galaxy)
(filter (partial submap? {:type :star}) test-galaxy)
--
Planet Clojure: http://planet.clojure.in/
On Tuesday, September 29, 2015 at 2:04:22 AM UTC+2, Jonathon McKitrick
wrote:
>
> What list of blogs, websites, and/or feeds would you suggest for someone
> who does not work with Clojure full time that will maximize exposure to
> advancements in the la
Hi,
This is an example from http://github.com/stuartsierra/component
(defn get-user [database username]
(execute-query (:connection database)
"SELECT * FROM users WHERE username = ?"
username))
Here 'database' is a component which is passed to 'get-user' as an
argument. The component
You can do this using multimethods. defmulti and defmethod will allow you
to do everything you ask for apart from adding a doc-string to each
command. Have a look at:
http://clojuredocs.org/clojure_core/clojure.core/defmulti
On Thursday, May 29, 2014 3:05:56 AM UTC+2, Will Duquette wrote:
>
> I
You have to replace the underscore with a function. The value of (= (_ [1 2
3 4 5]) 5) must be true. So the value of (_ [1 2 3 4 5]) must be 5. So the
function you are looking for will have to return the last element of the
array.
On Wednesday, April 30, 2014 5:28:26 PM UTC+2, Roelof Wobben wro
I recently moved from Emacs to Light Table for Clojurescript and I like
working with it. I created a tutorial that outlines my Clojurescript
workflow using Light Table: github.com/wvdlaan/todomvc
For my work on the JVM I still use Emacs because old habits die hard. But I
expect to move to Light
This will only give you one nil:
(doseq [i (range 1 1)]
(let [val (Math/sqrt i)
diff (Math/abs (- (Math/pow val 2) (* val val)))]
(when (> diff 1.1755025E-38)
(println (format "Different for %d (%e)" i diff)
On Tuesday, April 8, 2014 9:28:44 PM UTC+2, Cecil Westerhof wr
I moved to 1.6 two weeks ago for development and have had no problem. I had
to change some tests because they depended on the order of elements if you
seq a hashmap.
On Tuesday, March 18, 2014 3:21:22 PM UTC+1, Alex Miller wrote:
>
> Hello all,
>
> We would love to release Clojure 1.6.0 final s
Try this:
(defn inplace-xor [^bytes a ^bytes b ^bytes out]
(let [ln (count a)]
(loop [x 0]
(if (< x ln)
(do
(aset-byte out x (bit-xor (aget a x) (aget b x)))
(recur (inc x)))
On Thursday, March 13, 2014 6:26:33 AM UTC+1, Ignacio Corderi wrote:
>
> Hey g
Hi Florian,
To unpack your edn-acls I entered these expressions in a repl. Each
expression goes one step deeper, so it is only the last expression that you
need to unpack the acls. The other steps are included to illustrate the
process.
(for [acl edn-acls]
{:acl acl})
(for [acl edn-acls
First, regarding OO. When programming Clojure I never think about adding
objects to the application, I think "how can I extend the language so it is
better tailored to my application domain?". And for a lot of domains good
libraries are already available. So, for the example that you gave I woul
Please try these exercises if you want to know what a channel is:
https://github.com/halgari/clojure-conj-2013-core.async-examples/blob/master/src/clojure_conj_talk/core.clj
Op vrijdag 13 december 2013 11:01:57 UTC+1 schreef Joachim De Beule:
>
> Thanks, that indeed did the trick.
>
> More genera
Hi Dave,
Thanks for the overview.
I found one error. When running the Google Clojure example on its own this
expression gives an error:
(first (query "#menu ul"))
This is because 'first' depends on the protocols implemented in
domina.events.
This expression will fix the error:
(aget (query "#m
Hi,
You could try to do it like this...
Use a hashmap instead of a vector in the atom:
(def room-list (atom {}))
Insert rooms using a hashmap for the user-id's:
(swap! room-list assoc "67890" {:user-list {"id-3" {:name "name-3"}}})
You can now find a user in a room like this:
(get-in @room-list
An alternative that I'm looking at is pedestal 0.3.0. It sort of works like
this...
;; Create a transform-channel and transform-function to handle all changes
to 'state'
(defn init []
(let [c (chan)]
(go (while true
(when-let [[path v] (! transform-chan [path v]))
;; Change the
It is possible to execute forms in a debugging context but AFAIK there is
no easy setup that allows you to step through the execution.
The easiest way to evaluate forms in context is to setup emacs as described
here http://clojure-doc.org/articles/tutorials/emacs.html. This will allow
you to se
Chas Emerick did a presentation on this:
http://blip.tv/clojure/chas-emerick-modeling-the-world-probabilistically-using-bayesian-networks-in-clojure-5961126
But AFAIK the "raposo" library has not been published yet.
On Saturday, July 14, 2012 4:20:17 PM UTC+2, Simone Mosciatti wrote:
>
> Hi guys
A few years back I copied a small rewrite system from Scheme to Clojure
while watching the SICP video lectures. It's a nice use case for a rewrite
system. You can enter a mathematical function and the system will rewrite
the function to its derivative.
>
>
Perhaps this code plus the videos will
You can save state in an atom like this:
(def state (atom (new-game))) ; initial state
(swap! state move \x [1 1]) ; make a move
--
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 po
You could start with pure functions to handle the game logic, e.g.:
(defn new-game []
[[\- \- \-]
[\- \- \-]
[\- \- \-]])
(defn print-game [game]
(doseq [row game]
(println (apply str row
(defn move [game mark pos]
(assoc-in game pos mark))
(print-game (new-game))
(print-gam
Are you somehow required to use the Java library?
Otherwise you could also use a Clojure map as a sparse matrix.
This will be much easier to implement.
Walter
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to cloju
You can add something like this to project.clj:
:resources-path "/usr/lib/jvm/java-6-sun/lib/tools.jar"
Walter
--
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 memb
That's a big relieve.
Thanks for the answer!
--
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 - please be patient with your
first post.
To un
Hi,
When I run this expression:
(map (fn [x] (println x) x) (range 5))
I expect to get (0 1 2 3 4) but instead I get (0 1 2 3 4 0 1 2 3 4)
It seems like the println output is included in the result list.
Am I missing something?
--
You received this message because you are subscribed to the G
You could first turn the Values from String into Double like this:
(defn step1 [coll]
(map (fn [m]
(assoc m "Value" (Double/parseDouble (m "Value"
coll))
Next, you can use reduce to calculate the sum per Value:
(defn step2 [coll]
(reduce (fn [res m]
(let [k (m "
This gives several I/O examples:
http://nakkaya.com/2010/06/15/clojure-io-cookbook/
--
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 - please b
You could use this:
(defn non-existing-key [mp] (inc (reduce max (keys mp
For example:
(non-existing-key {1 "a" 2 "b"}) => 3
--
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 p
t; and see if that gives you any hints. if not, send me the output of
> that command, and the full path and namespace of one of your source
> files, I'll see if I can see anything you are missing.
>
> g
>
> On Oct 5, 6:40 am, Walter van der Laan
> wrote:
>
>
>
&g
Thanks George, this is great. I tried the screencast instructions and
it all works, but I can't get it to work with my own source. I tried
several settings for (set-source-path) but I must be doing something
wrong. Can you perhaps give an example?
On Oct 1, 10:32 pm, George Jahad wrote:
> For you
You can find a lot of examples using http://github.com/defn/walton
For example you can point your browser at
http://getclojure.org:8080/examples/reduce
for reduce examples.
On Jun 30, 8:08 am, michele wrote:
> Mother's invention is a lazy necessity, I think.
>
> On Jun 29, 9:46 pm, Meikel Brand
36 matches
Mail list logo