Re: sort-by reverse order?

2020-10-14 Thread Matthew O. Smith
Google brought this up in 2020

Try
(comp - compare)



On Tuesday, December 23, 2014 at 10:04:35 AM UTC-7 julian...@googlemail.com 
wrote:

> That's awesome! (though I'm slightly surprised there isn't an easier way). 
>
> Thanks. 
>
>
> On Tuesday, 23 November 2010 21:03:37 UTC, Tyler Perkins wrote:
>>
>> Nice! And with just a bit more, we have a clean, sorting DSL: 
>>
>> (def asc compare) 
>> (def desc #(compare %2 %1)) 
>> ;;  compare-by generates a Comparator: 
>> (defn compare-by [& key-cmp-pairs] 
>>   (fn [x y] 
>>   (loop [[k cmp & more] key-cmp-pairs] 
>>  (let [result (cmp (k x) (k y))] 
>>   (if (and (zero? result) more) 
>>   (recur more) 
>>   result) 
>>
>> (sort (compare-by :last-name asc, :date-of-birth desc) coll)
>
>

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/769d3b44-e1dc-43f4-8728-7ecfdce86e79n%40googlegroups.com.


Debugging with Cider

2013-10-31 Thread Matthew O. Smith

Hi all,

Has anyone gotten debugging in emacs working with cider (was nrepl).  I did 
fork and update cljdb but it is pretty old school. 
https://github.com/m0smith/cljdb
Is there any work on ritz or cdt?

Thanks.

-- 
-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[ANN] lein-resource 0.2.0 hits clojars

2012-12-28 Thread Matthew O. Smith

https://github.com/m0smith/lein-resource

lein-resource 

A plugin that can be used to copy files from mulitiple source directories 
to a target directory while maintaining the sub-directories. Also, each 
file will be transformed using 
stencilhttps://github.com/davidsantiago/stencil. 
The map that is passed to stencil contains a combination of:

   - The project map
   - The system properties (with .prop added to the name )
   - Additional values (currently only :timestamp)
   - Values set in the project.clj using :resource :extra-values


-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: [ANN] lein-stencil 0.1.0

2012-12-19 Thread Matthew O. Smith
I renamed the project to lein-resource as that better matches the intent of 
the project rather than an implmentation detail

*https://github.com/m0smith/lein-resourcehttps://github.com/m0smith/lein-stencil

*

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

[ANN] lein-stencil 0.1.0

2012-12-18 Thread Matthew O. Smith
*It is not in clojars yet as I wanted people to have the opportunity to 
give feedback before making it live*
*
*
*https://github.com/m0smith/lein-stencil
*
*
*

A plugin that can be used to copy files from multiple source directories to 
a target directory while maintaining the sub-directories  Also, each file 
will be transformed using stencil https://github.com/davidsantiago/stencil. 
The map that is passed to stencil contains a combination of:

   - The project map
   - The system properties (with .prop added to the name )
   - Additional values (currently only :timestamp)
   - Values set in the project.clj using :stencil :extra-values

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Cdr car

2012-10-17 Thread Matthew O. Smith
I came to Clojure from a similar background and posted my thoughts of car, 
cdr, and cons here 
http://software-ninja-ninja.blogspot.com/2011/08/clojure-patterns-cons-car-and-cdr.html


On Wednesday, October 17, 2012 1:10:15 PM UTC-6, Jeff Heon wrote:

 If I may suggest the following presentation:

 http://blip.tv/clojure/clojure-for-lisp-programmers-part-1-1319721
 http://blip.tv/clojure/clojure-for-lisp-programmers-part-2-1319826

 There used to a transcript available on the newsgroup until Google decided 
 to remove all files from newsgroup 8)

 On Wednesday, October 17, 2012 2:16:01 PM UTC-4, Curtis wrote:

 Cons seems to be strange

 How do i use Cons with an atom to make a list?

 (cons 1 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 moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Map literal with keys generated by function cause Duplicate key exception

2012-09-12 Thread Matthew O. Smith

On Wednesday, September 12, 2012 8:03:58 AM UTC-6, jarppe wrote:

 I have a function that generatwed unique ID's, something like this:

   (def k (atom 0))
   (defn generate-id [] (swap! k inc))

  and I try to use it like this:

{(generate-id) foo
 (generate-id) bar}

 How ever, I get

IllegalArgumentException Duplicate key: (generate-id)  
 clojure.lang.PersistentArrayMap.createWithCheck (PersistentArrayMap.java:70)

 This works as expected.

   (let [id1 (generate-id)
 id2 (generate-id)]
 {id1 foo id2 bar})

 Should I be able to call generate-id in map literal?

 -- 
 -jarppe

  
This also fails:

 {  (gensym) foo
(gensym) bar }

From the stack trace I get it looks like the reader macro that handles map 
literals is only looking at the function call, not the result of the 
function call.  This makes sense as it is the reader, not the evaluator.

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: topoged-hibernate 1.0.0

2012-01-20 Thread Matthew O. Smith


On Jan 6, 8:20 am, Bill Robertson billrobertso...@gmail.com wrote:
 On Jan 3, 4:26 pm, Matthew O.  Smith m0sm...@gmail.com wrote:

  There is a mismatch between hibernate maps and clojure maps which
  means that there is some translating between them. Hopefully, this
  will be smoothed over in the future

 What is the mismatch?

The mismatch is that Hibernate and Clojure see Map object differently
so there is an (in my mind) unnecessary conversion that has to take
place at the boundary between the two systems both in sending data to
Hibernate and also retrieving it.  It is not a huge deal, but it is
annoying.

As an example consider this code.  Rather than treating a map as
Clojure map (immutable), the develop has to treat the map as a mutable
object.

 (with-session [session _]
  (let [person (.load session Person 1)
 email topo...@topoged.com]
   (doto (. person (get emailAddresses)) (.add email

Instead I would like somthing like:

 (with-session [session _]
  (let [person (.load session Person 1)
 email topo...@topoged.com]
(assoc-in person [:emailAddresses] email)))

But that leaves the question of how to propagate the change back to
the Hibernate session.I had thought about some hybrid between
java.util.Map and IMap but decided not as it would end up just
creating more problems than it solves.

It is a problem I am still working on.

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


topoged-hibernate: a clojure hibernate library

2011-12-13 Thread Matthew O. Smith
As part of a larger project, Topoged, I am developing a Hibernate
library that makes working with Hibernate from within Clojure much
easier IMHO.  It uses the standard Hibernate configuration and
provides wrappers and whatnot to simplify the interaction.  For
example, to  write a record to the database:

(hibernate)   ;; Only called once

(with-session [session tx]
(.save session Event (doto (java.util.HashMap.)
 (.put  title Our 
very first event!)
 (.put date (Date.

I am working on making the library

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: topoged-hibernate: a clojure hibernate library

2011-12-13 Thread Matthew O. Smith

I am working on making library useful to the public:
https://github.com/m0smith/topoged-hibernate

One question I would like a comment on:  I have been using entity-maps
rather than POJOs because it makes for a cleaner interop with
Clojure.  The amount of code needed goes way down while the standard
POJO makes for a lot of code.  Do you see a need to do a lot of work
to support POJOs?

Thanks in advance.

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en