On Fri, Sep 17, 2010 at 08:58, Michael Wood wrote:
> On 17 September 2010 00:56, Michael Ossareh wrote:
>> Meikel,
>>
>>>
(recur (cond (not (nil? (data key)))
(true? true)
>>>
>>> *ieeck* Please do (cond ... :else default-clause). Not true, or (true?
>>> true) or othe
On 17 September 2010 00:56, Michael Ossareh wrote:
> Meikel,
>
>>
>>> (recur (cond (not (nil? (data key)))
>>> (true? true)
>>
>> *ieeck* Please do (cond ... :else default-clause). Not true, or (true?
>> true) or other stuff.
>
> Wow, I somehow missed the :else option in cond? I
Meikel,
>
>> (recur (cond (not (nil? (data key)))
>> (true? true)
>
> *ieeck* Please do (cond ... :else default-clause). Not true, or (true?
> true) or other stuff.
Wow, I somehow missed the :else option in cond? I've got that (true?
true) stuff scattered all over my code - goi
>> (loop [data (sorted-map)
>> collection newData
>> meeting (first collection)]
>>
>> (def key ( ))
>
> As a general rule, def should only be used at the top level. You
> probably want (let [key ...] (if ...) here.
Hey, thanks for pointing this out - I was actually just t
On Thu, Sep 16, 2010 at 07:53, Laurent PETIT wrote:
> 2010/9/16 Meikel Brandmeyer
>>
>> Hi Laurent,
>>
>> On 16 Sep., 15:54, Laurent PETIT wrote:
>>
>> > you don't like my one-liner ? :-)
>>
>> I saw your message only after I sent mine. :)
>>
>> > (update-in coll [k] (fnil update-in *default-val
That pattern will be a great addition to the toolbox, thank you :)
On Sep 16, 9:58 am, Laurent PETIT wrote:
> And note that the pattern works at any level, and is easily readable, since
> update-in "flattens" the arguments of the modifying function :
>
> If you want to "touch" the path [:a :b :c
And note that the pattern works at any level, and is easily readable, since
update-in "flattens" the arguments of the modifying function :
If you want to "touch" the path [:a :b :c :d] and provide specific default
values at each level if the key is not found, it's as "simple" as :
(update-in coll
So nested calls to update-in are needed in order to be able to provide a
specific default value, everytime just having an empty map created isn't
sufficient.
So instead of (update-in {} [:a :b] identity) which returns {:a {:b nil}} ,
you can break the key path at :a so that the default value if no
My poor brain can't handle nested calls to update-in, so this is what
I came up with:
(defn add-meetings [data k meetings]
(cond
(nil? (data k)) (assoc data k {:title "title" :meetings meetings})
:else (update-in data [k :meetings] concat meetings)))
On Sep 16, 8:53 am, Laurent PETIT wro
2010/9/16 Meikel Brandmeyer
> Hi Laurent,
>
> On 16 Sep., 15:54, Laurent PETIT wrote:
>
> > you don't like my one-liner ? :-)
>
> I saw your message only after I sent mine. :)
>
> > (update-in coll [k] (fnil update-in *default-value*) [:meetings] (comp
> vec
> > concat) data)
>
> Hmm... (comp ve
Hi Laurent,
On 16 Sep., 15:54, Laurent PETIT wrote:
> you don't like my one-liner ? :-)
I saw your message only after I sent mine. :)
> (update-in coll [k] (fnil update-in *default-value*) [:meetings] (comp vec
> concat) data)
Hmm... (comp vec concat) == into?
Meikel
--
You received this m
Hi Meikel,
you don't like my one-liner ? :-)
(update-in coll [k] (fnil update-in *default-value*) [:meetings] (comp vec
concat) data)
2010/9/16 Meikel Brandmeyer
> Hi,
>
> On 16 Sep., 15:36, Meikel Brandmeyer wrote:
>
> > > (if (not (nil? (next collection)
> >
> > You can save the nil?. (if
Hi,
On 16 Sep., 15:36, Meikel Brandmeyer wrote:
> > (if (not (nil? (next collection)
>
> You can save the nil?. (if (not (next collection))) will also work.
> nil is logically false.
And of course this should be (if (next collection)). The not belongs
to the "You can save" part.
Sincerely
Me
Hi,
maybe this does what you want. I'm not sure, since you add the new
meeting to *all* meetings? And where does the :title come from when
you add a new meeting? I assume you have a map of a meeting title and
a meeting and want to add this to the corresponding entry in the data
map. If the meeting
Something along those lines :
(def t { 0 {:title "some" :meetings [ :d1 ]} 2 {:title "some2" :meetings [
:d2 ]}})
user=> (pprint (update-in t [1] (fnil update-in {:title "title" :meetings
[]}) [:meetings] (comp vec concat) [:d1 :d2]int (update-in t [1] (fnil
update-in {:title "title" :meetings []
On Wed, 15 Sep 2010 11:48:09 -0700
Michael Ossareh wrote:
> Hi Guys,
>
> One of the things that has struck me about clojure, by virtue of being
> a lisp, is the concision of the code - I really find it very
> attractive. However yesterday I found something that I couldn't work
> out how to do in
On Wed, Sep 15, 2010 at 2:48 PM, Michael Ossareh wrote:
> Hi Guys,
>
> One of the things that has struck me about clojure, by virtue of being
> a lisp, is the concision of the code - I really find it very
> attractive. However yesterday I found something that I couldn't work
> out how to do in a
I'm interested in Conjure webframework and I'm considering trying to
read its source code and participate later.
What do you think?
Do you other projects in mind?
This discussion is amazing guys :)
On Sep 3, 8:25 pm, CuppoJava wrote:
> I had the exact same problem transitioning from OOP to Lisp,
This may help!
http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/
"These twenty video lectures by Hal Abelson and Gerald Jay Sussman are
a complete presentation of the course, given in July 1986 for Hewlett-
Packard employees, and professionally produced by Hewlett-Packard
Te
On Fri, Sep 3, 2010 at 8:23 AM, Michael Ossareh wrote:
>> I'd go over SICP, though it not in Clojure but in Scheme - it will
>> show you how to "think" functional.
> +1 on this.
> http://mitpress.mit.edu/sicp/
i think some folks argue that
http://www.htdp.org/
is even better :-)
or at least a goo
I had the exact same problem transitioning from OOP to Lisp, and I can
only offer my own experiences. I finally "understood" lisp, by
programming a new pet project FROM SCRATCH, in the most
STRAIGHTFORWARD way possible. I originally started by porting over a
program I had written in Java, and found
Really nice example Peter,
Thanks, I appreciate it.
On Sep 3, 6:36 am, Peter Buckley wrote:
> I'm only a little ways through Joy of Clojure (my first Clojure book)
> but bear with me as I'm thinking aloud on what it means for me to
> "think in Clojure." I hope list members will forgive me if I ge
On Thu, Sep 2, 2010 at 21:05, Miki wrote:
> I'd go over SICP, though it not in Clojure but in Scheme - it will
> show you how to "think" functional.
>
+1 on this.
http://mitpress.mit.edu/sicp/
--
!new number!
415-400-6772
--
You received this message because you are subscribed to the Googl
On Thu, Sep 2, 2010 at 11:36 PM, Peter Buckley wrote:
>
> One of the things that stuck out for me that I heard somewhere (can't
> remember exactly) was that OOP is about framing questions in terms of
> "nouns" and FP is about framing questions in terms of "verbs."
Perhaps you heard it in Yegge's
Sean and Peter made comments that ring very true for me. I've always
had a problem with Java/Smalltalk/C# type OO. I also thought the
Common Lisp/Dylan way of generic functions and data structures made
more sense. Like Peter mentioned, I tend to think in terms of verbs
and transformations of dat
I'm only a little ways through Joy of Clojure (my first Clojure book)
but bear with me as I'm thinking aloud on what it means for me to
"think in Clojure." I hope list members will forgive me if I get
things wrong - and please correct my working concept(s) as well.
One of the things that stuck out
On Thu, Sep 2, 2010 at 9:29 PM, HB wrote:
> Hey,
> I finished reading "Programming Clojure" and "Practical Clojure" and
> I'm hooked :)
> Please count me in the Clojure club.
> But I failed how to think in Clojure.
> My main career is around Java web applications (Hibernate, Spring,
> Lucene) and
On 2010-09-02, at 10:02 PM, HB wrote:
> So in idiomatic Clojure applications, maps are considered like
> objects?
> And to operate on them we pass them to functions?
I think that considering maps as a state representation is reasonable. There
are alternatives, but that's fine-tuning I think.
T
On Thu, Sep 2, 2010 at 6:29 PM, HB wrote:
> Usually we create some domain entities, map them with Hibernate/
> iBatis.
> I don't know how a Clojure application would be build without objects.
I wonder if watching this talk by Rich Hickey will help?
http://www.infoq.com/presentations/Are-We-There
I'd go over SICP, though it not in Clojure but in Scheme - it will
show you how to "think" functional.
On Sep 2, 6:29 pm, HB wrote:
> Hey,
> I finished reading "Programming Clojure" and "Practical Clojure" and
> I'm hooked :)
> Please count me in the Clojure club.
> But I failed how to think in C
I highly recommend "Joy of Clojure". It's a good "2nd book on clojure".
It shows you the "why things are the way they are", and how to
do things the clojure way as much as possible.
On Thu, Sep 2, 2010 at 9:29 PM, HB wrote:
> Hey,
> I finished reading "Programming Clojure" and "Practical Clojure"
So in idiomatic Clojure applications, maps are considered like
objects?
And to operate on them we pass them to functions?
On Sep 3, 4:55 am, David Nolen wrote:
> On Thu, Sep 2, 2010 at 9:29 PM, HB wrote:
> > Hey,
> > I finished reading "Programming Clojure" and "Practical Clojure" and
> > I'm ho
On Thu, Sep 2, 2010 at 9:29 PM, HB wrote:
> Hey,
> I finished reading "Programming Clojure" and "Practical Clojure" and
> I'm hooked :)
> Please count me in the Clojure club.
> But I failed how to think in Clojure.
> My main career is around Java web applications (Hibernate, Spring,
> Lucene) and
On Mon, Jan 26, 2009 at 11:13 PM, Whirlycott wrote:
>
> I'm new to Clojure and I'm wondering how I'm supposed to be thinking
> about various things. I want to use the c3p0 database connection pool
> in a Clojure app. In Java, I would simply create an instance of this
> class and either assign i
Here is one way:
(let [dbc (make-db)]
(defn get-apples []
(.query dbc "select * from apples")))
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to clojure@go
35 matches
Mail list logo