Re: Joy of Clojure example not working

2014-05-20 Thread Greg D
Yes, the examples in the book are missing some lines. I think the following log shows what they were going for: joy.udp=> (remove-method compiler ::osx) joy.udp=> (def unix (into unix {::c-compiler "/usr/bin/gcc"})) joy.udp=> (def osx (into osx {:c-compiler "gcc"})) oy.udp=> osx {:home "/Users",

Re: ArithmeticException from unchecked-add

2014-05-20 Thread Greg D
Thanks. I've got to pay more attention to the distinction between long and Long in the documentation. The docs for unchecked-add ( > http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/unchecked-add > ) > only cover the case of both arguments being primitive longs. > -- You r

ArithmeticException from unchecked-add

2014-05-19 Thread Greg D
I didn't expect this one. See the illustrative sequence below. Should I be reporting this as a bug, or re-read the docs? ; CIDER 0.5.0 (Clojure 1.6.0, nREPL 0.2.3) user> (require '[clojure.stacktrace :as st]) user> (unchecked-add (Long/MAX_VALUE) (Long/MAX_VALUE) ) -2 user> (unchecked-add ^lo

Re: Best way to pass parameters?

2014-05-19 Thread Greg D
Not an answer to your question, but you may want to check out: Datomic: The fully transactional, cloud-ready, immutable database. On Monday, May 19, 2014 10:07:15 AM UTC-7, Ivan Schuetz wrote: > > Hi, > > I'm building a webservice, have 2 layers: webservice and database.

Re: Joy of Clojure example not working

2014-05-19 Thread Greg D
The second edition of Joy of Clojure, MEAP v10 shows the same error and progressive solution about half way down pdf-page 318 in section 9.2.4. On Monday, May 19, 2014 6:39:26 AM UTC-7, gamma235 wrote: > > Hi guys, I am working through the pre-release second edition of Joy of > Clojure's section

Re: Improving pprint behavior for anonymous functions

2014-04-26 Thread Greg D
Simpler yet using metadata: (ns example.ppfn) (defn print-pf [pf] (if-let [ppf (::ppf (meta pf))] ppf pf)) (defmacro partial* [& args] `(let [m# (pr-str '(partial* ~@args)) pf# (with-meta (partial ~@args) {::ppf m#})] (defmethod print-method (class pf#) [o# w#] (print-simple (

Re: Improving pprint behavior for anonymous functions

2014-04-25 Thread Greg D
/* 1 1 7) user=> p6 (partial clojure.core/+ 1 2 3) user=> (def comma-join (partial* clojure.string/join ", ")) #'user/comma-join user=> comma-join (partial clojure.string/join ", ") user=> (p6 100) 106 user=> (t7 5) 35 user=> (comma-join ['a &#x

Re: Improving pprint behavior for anonymous functions

2014-04-25 Thread Greg D
om/clojure/clojure/blob/master/src/clj/clojure/core.clj#L2460 > > > On Fri, Apr 25, 2014 at 5:47 PM, Greg D > > wrote: > >> I guess I don't understand the problem, or what is meant by "different >> classes". A counter-example would be helpful. >>

Re: Improving pprint behavior for anonymous functions

2014-04-25 Thread Greg D
ote: > > That's not going to work, all the return classes of partial are the same > class. > > > On Fri, Apr 25, 2014 at 5:26 PM, Greg D > > wrote: > >> I don't know if this is considered good Clojure, but you could define a >> print-method within a m

Re: Improving pprint behavior for anonymous functions

2014-04-25 Thread Greg D
, all the return classes of partial are the same > class. > > > On Fri, Apr 25, 2014 at 5:26 PM, Greg D > > wrote: > >> I don't know if this is considered good Clojure, but you could define a >> print-method within a macro to set up the normal string repres

Re: Improving pprint behavior for anonymous functions

2014-04-25 Thread Greg D
I don't know if this is considered good Clojure, but you could define a print-method within a macro to set up the normal string representation for the partial function: (defmacro partial* [fname arg0 & args] `(let [pf# (partial ~fname ~arg0 ~@args) cpf# (class pf#)] (defmethod pr

Re: puzzled by RuntimeException

2014-04-25 Thread Greg D
Thanks Alex and Steve, I've based a ton of work on keywords where the second character is numeric. The http://clojure.org/readers page should be the normative reference. > The work is based on *reliance* on the definitions in the readers page. I believe it is unambiguous in demanding a colon as

Re: puzzled by RuntimeException

2014-04-22 Thread Greg D
I believe this is a problem in REPL-y, which is used when using 'lein repl'. I used Cider to start a nREPL server, then used 'leing repl :connect' to get the REPL-y interface. The problem was evident in the latter, but not the former. I opened an issue for REPL-y. Thanks again, Steve -- You

Re: puzzled by RuntimeException

2014-04-21 Thread Greg D
Steve, Thanks. I did a quick check, and it seems that I don't get exceptions when I start the repl as you do. I normally start mine with 'lein repl'. You've given me a good lead to investigate. Greg -- You received this message because you are subscribed to the Google Groups "Clojure" gro

puzzled by RuntimeException

2014-04-21 Thread Greg D
The sequence in the transcript below shows runtime exceptions when a numeric keyword is followed by a list starting with a symbol or character. Would anyone help me with a reason for the failing cases? user=> (clojure-version) "1.6.0" user=> '(:42 a) (:42 a) user=> '(:42 "a") (:42 "a") user=> '(

Re: Thoughts on bags?

2014-04-19 Thread Greg D
Added link missing in previous post. A simple multiset/bag implementation for Clojure -- 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 fr

Re: Thoughts on bags?

2014-04-19 Thread Greg D
While searching for MultiSet or Bag resources, I found this implementation by Achim Passen at: A simple multiset/bag implementation for Clojure. However, I found I could meet my needs by adding functions to treat vectors, or other collection types, as unordered. These can then be used directly,

Re: Thoughts on bags?

2014-04-17 Thread Greg D
While searching for MultiSet or Bag resources, I found this implementation by Achim Passen at: A simple multiset/bag implementation for Clojure . However, I found I could meet my needs by adding functions to treat vectors, or other collection types, as unorder

Re: Questions regarding Map vs Record and usage

2014-04-09 Thread Greg D
FWIW, I use: - (->Book "Lord of the Rings", "Tolkien") - when I define the record instance with the default fields, and the number of default fields is a small number - (map->Book {:title "The Fellowship of the Ring", :author "Tolkien",

self-evaluation of record instances

2014-04-02 Thread Greg D
Greetings, The nuance below took a long time to identify and reduce from a test failure. Should it be considered a bug? $ lein repl nREPL server started on port 52758 on host 127.0.0.1 REPL-y 0.3.0 Clojure 1.6.0 user=> (defrecord Fields0 []) ; record with 0 fields user.Fields0 user=>

not quite getting refs

2014-03-26 Thread Greg D
I've looked, but can't find, a discussion of the choice of a history mechanism for refs. I can't understand why the transactions just don't check #'identical? for the ref value, rather than maintaining a history queue. In other words, I don't see why (dosync (ref-set foo @foo))) should cause ot

Re: STM history queues, when is a snapshot pushed

2014-03-24 Thread Greg D
Having learned a little more about refs and transactions from M. Fogus and C. Houser "The Joy of Clojure, Second Edition", I altered the stress-ref function from 10.2.4. Using Clojure 1.5.1: (defn stress-ref [r] (let [slow-tries (atom 0)] (future (dosyn

STM history queues, when is a snapshot pushed

2014-03-23 Thread Greg D
Is a new snapshot pushed onto the history queue of a ref when 1. every time the ref is a target of alter, commute, ref-set, reset, alter-meta!, or reset-meta!, or 2. only when the committed value for the ref is not identical to the value at the end of the history queue? When chec

Re: non-equality (=) of records nuance

2014-03-18 Thread Greg D
I'm on 1.5.1 I have a workaround: - instead of - (map->Foo this) - use - (map->Foo (into {} this)) On Tuesday, March 18, 2014 5:47:46 PM UTC-7, Alex Miller wrote: > > What Clojure version are you on? -- You received this message because you are subscribed to the Google

non-equality (=) of records nuance

2014-03-18 Thread Greg D
Greetings, I'm confused by the failure of 2 record instances to compare as equal, only when generated by a protocol method and having extra fields. The code below shows this, with uninformative REPL responses snipped. The attached file has similar code as a clojure.test. Would somebody please