Re: instaparse: composing smaller rules into a bigger one

2013-11-19 Thread Jim - FooBar();
an optional whitespace rule everywhere, documented here under: https://github.com/Engelberg/instaparse/blob/master/docs/ExperimentalFeatures.md#auto-whitespace On Mon, Nov 18, 2013 at 5:47 AM, Jim - FooBar(); jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: Hi all, I'm having a small

Re: Padding missing elements in a sequence of identical K/V maps

2013-11-19 Thread Jim - FooBar();
On 19/11/13 11:29, Colin Yates wrote: Imagine the sequence represents a distribution between 1 and 5. The initial sequence might only be [{:key 3 :value 30} {:key 4 :value 40}]. I want it to be [{:key 1 :value nil} {:key 2 :value nil} {:key 3 :value 30} {:key 4 :value 40} {:key 5 :value

Re: Padding missing elements in a sequence of identical K/V maps

2013-11-19 Thread Jim - FooBar();
On 19/11/13 11:42, Jim - FooBar(); wrote: On 19/11/13 11:29, Colin Yates wrote: Imagine the sequence represents a distribution between 1 and 5. The initial sequence might only be [{:key 3 :value 30} {:key 4 :value 40}]. I want it to be [{:key 1 :value nil} {:key 2 :value nil} {:key 3 :value

Re: Padding missing elements in a sequence of identical K/V maps

2013-11-19 Thread Jim - FooBar();
On 19/11/13 11:29, Colin Yates wrote: In Java I would do something like: // create a convenient look up to avoid nasty N^2 lookups MapObject, Object keyToValue = new HashMap for (MapObject, Object kvMap: kvSequence) keyToValue.put(kvMap.get(key), kvMap.put(value)); ListObject allKeys =

preferred way to dereference a ref: outside or inside dosync?

2013-11-20 Thread Jim - FooBar();
Hi all, I've been wondering about this lately and I'm not sure which approach to pick as both give the correct results (in my rudimentary tress-test). So as I understand it is generally suggested to have pure, testable functions that oter side-effecting functions rely on. like so for example:

Re: preferred way to dereference a ref: outside or inside dosync?

2013-11-21 Thread Jim - FooBar();
On 20/11/13 19:36, juan.facorro wrote: The value for all refs whose value you don't actually modify inside a transaction should be obtained through ensure http://clojuredocs.org/clojure_core/clojure.core/ensureif you want to make sure :P their value won't be changed by a different

Re: preferred way to dereference a ref: outside or inside dosync?

2013-11-21 Thread Jim - FooBar();
Hi Stefan, thanks for your interest. let me explain further... 1. I did start with a design that involved a map (the bank) full of agents (accounts). Then I switched to a map full of atoms thinking that I don't really need asynchronous operations. I settled to the single ref approach because

Re: preferred way to dereference a ref: outside or inside dosync?

2013-11-21 Thread Jim - FooBar();
/13 10:58, Jim - FooBar(); wrote: Hi Stefan, thanks for your interest. let me explain further... 1. I did start with a design that involved a map (the bank) full of agents (accounts). Then I switched to a map full of atoms thinking that I don't really need asynchronous operations. I settled

Re: preferred way to dereference a ref: outside or inside dosync?

2013-11-21 Thread Jim - FooBar();
On 21/11/13 13:19, John D. Hume wrote: If you want to demonstrate STM with the deposit-withdraw-transfer example, you definitely need a ref for each account. I'd suggest an atom for the account-num-balance-ref map (the bank) and an atom for the account-num-generator, but you say

Re: preferred way to dereference a ref: outside or inside dosync?

2013-11-21 Thread Jim - FooBar();
-num-balance-ref map (the bank) and an atom for the account-num-generator, but you say coordination is necessary for opening and closing accounts. What coordination do you have in mind? On Nov 21, 2013 5:27 AM, Jim - FooBar(); jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: also I

Re: preferred way to dereference a ref: outside or inside dosync?

2013-11-21 Thread Jim - FooBar();
is necessary for opening and closing accounts. What coordination do you have in mind? On Nov 21, 2013 5:27 AM, Jim - FooBar(); jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: also I forgot to add that having the bank in some reference type allows opening/closing new accounts

Re: preferred way to dereference a ref: outside or inside dosync?

2013-11-22 Thread Jim - FooBar();
On 22/11/13 08:18, Stefan Kamphausen wrote: How about (defn get-key-generator [] (let [i (atom 0)] (fn [] (swap! i inc (def generate-keys (get-key-generator)) nice one, much better than mine :) thanks Stefan... Jim -- -- You received this message because you are subscribed to

Re: preferred way to dereference a ref: outside or inside dosync?

2013-11-24 Thread Jim - FooBar();
On 23/11/13 14:17, Justin Smith wrote: you may want to make that (defonce generate-keys (get-key-generator)) and even better, add a start argument to get-key-generator so you can persist across restarts of the vm. Of course in a real app the key should be serialized to a persistent,

accessing big-resource - what are people doing?

2013-12-07 Thread Jim - FooBar();
Hi all, Technically speaking this is not a question specific to Clojure. I 'd like to see how people are generally accessing some big resource (e.g a massive .csv file). My use case is this: I've got code that fetches the weather conditions from Yahoo, given a WOE_ID code. The problem is

implementing arithmetic operators without using [+ - * / even? odd? inc dec]

2013-12-09 Thread Jim - FooBar();
Hi all, A very popular interview question is to try implement all arithemtic operations for integers without using all the usual suspects. After thinking for a while I concluded that I only really need inc/dec in order to implement everything else. And the good news is that one can easily

Re: howto use reify in defmacro

2013-12-18 Thread Jim - FooBar();
as an aside, if you're writing def-like macros, I'd encourage you to look at 'clojure.tools.macro/name-with-attributes' Jim On 18/12/13 12:14, Tassilo Horn wrote: Xiangtao Zhou tao...@gmail.com writes: Hi! I want to use reify in macro, but the namespace is the problem. the following code

get rid of reflection in proxy-super?

2013-12-22 Thread Jim - FooBar();
Hi all, is there any way to get rid of reflection in simmilar looking? Nothing seems to work... (proxy [JPanel ActionListener KeyListener] [] (paintComponent [^java.awt.Graphics g] (let [^JPanel this this] (proxy-super paintComponent g)) thanks in advance... :) Jim -- --

Re: get rid of reflection in proxy-super?

2013-12-25 Thread Jim - FooBar();
Thanks Colin, I did vote for it but its title implies something different...something restoring original binding on exception... Jim On 25/12/13 04:06, Colin Fleming wrote: That is indeed the same issue, and it even includes a patch with a test! I've voted for this one, please consider doing

Re: Are all clojure namespaces loaded in repl by default?

2014-01-07 Thread Jim - FooBar();
The namespaces you mentioned have already been loaded and thus you can use the fully qualified name . What if you try (clojure.inspector/inspect [1 2 3]) in a bare repl??? ClassNotFoundException clojure.inspector java.net.URLClassLoader$1.run (URLClassLoader.java:366) I hope that clarifies

Re: Are all clojure namespaces loaded in repl by default?

2014-01-07 Thread Jim - FooBar();
Generally speaking, you wouldn't care what has been loaded and what hasn't and you certainly should not rely on something having been implicitly loaded. The current best practice is to use :require in conjunction with :refer or :as, in all your ns declarations, thus avoiding the need for fully

Re: Contributors needed for Rouge (Clojure on Ruby)

2014-01-08 Thread Jim - FooBar();
On 08/01/14 14:38, John Gabriele wrote: For a tiny Clojure uberjar, startup time on my desktop is about a second. Tolerable. well, a tiny Clojure/Swing uberjar on the raspberry-pi (oracle-java7) takes 9-12 seconds to start!!! not so tolerable... in fact, in the absence of a splash screen, the

Re: Contributors needed for Rouge (Clojure on Ruby)

2014-01-08 Thread Jim - FooBar();
compiled and copied to the device, but still, not exactly the ideal solution. Timothy On Wed, Jan 8, 2014 at 8:43 AM, Jim - FooBar(); jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: On 08/01/14 14:38, John Gabriele wrote: For a tiny Clojure uberjar, startup time on my

Re: Contributors needed for Rouge (Clojure on Ruby)

2014-01-08 Thread Jim - FooBar();
, but still, not exactly the ideal solution. Timothy On Wed, Jan 8, 2014 at 8:43 AM, Jim - FooBar(); jimpil1...@gmail.comwrote: On 08/01/14 14:38, John Gabriele wrote: For a tiny Clojure uberjar, startup time on my desktop is about a second. Tolerable. well, a tiny Clojure/Swing uberjar

Re: Contributors needed for Rouge (Clojure on Ruby)

2014-01-08 Thread Jim - FooBar();
://www.oracle.com/technetwork/java/embedded/downloads/javase/index.html ? On Wed, Jan 08, 2014 at 04:36:02PM +, Jim - FooBar(); wrote: I would recommend the newly available through official Pi channels, oracle-java7-jdk...It is a full distribution of JIT'ed Java (including Swing) with hardware-floating

Re: Contributors needed for Rouge (Clojure on Ruby)

2014-01-08 Thread Jim - FooBar();
indeed :) On 08/01/14 17:32, Max Gonzih wrote: Well it's actually cool that this is inside Raspbian channels. -- -- 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

Re: Processing a lazy sequence consuming the heap

2014-01-09 Thread Jim - FooBar();
that is obviously because you still use the Var `xml` somewhere...change it to a function call`(xml)` and try again :) Jim On 09/01/14 11:38, Peter Ullah wrote: I now get Don't know how to create ISeq from: xml_example.core$xml clojure.lang.RT.seqFrom (RT.java:505) -- -- You received this

Re: Processing a lazy sequence consuming the heap

2014-01-09 Thread Jim - FooBar();
oops, ny bad it seems you figured it out :) Jim On 09/01/14 11:42, Peter Ullah wrote: My bad, was passing a reference to the function, rather than the response from the function Doh! On Thursday, January 9, 2014 11:38:44 AM UTC, Peter Ullah wrote: I now get Don't know how to create

Re: How can I improve this?

2014-01-10 Thread Jim - FooBar();
I quickly put together this which seems to preserver the orderof the original seq: (defn uniquify [coll] (let [post-fn #(group-by first (- % meta :encountered))] (loop [unique (with-meta [] {:encountered []}) [f more] coll] (if (nil? f) (flatten (concat unique (reduce #(conj %

Re: How can I improve this?

2014-01-10 Thread Jim - FooBar();
actually `post-fn` should be #(group-by identity (- % meta :encountered)) Jim On 10/01/14 15:28, Jim - FooBar(); wrote: I quickly put together this which seems to preserver the orderof the original seq: (defn uniquify [coll] (let [post-fn #(group-by first (- % meta :encountered))] (loop

Re: How can I improve this?

2014-01-10 Thread Jim - FooBar();
oops! my fn will not keep the original ordering...sorry Colin Jim On 10/01/14 15:34, Jim - FooBar(); wrote: actually `post-fn` should be #(group-by identity (- % meta :encountered)) Jim On 10/01/14 15:28, Jim - FooBar(); wrote: I quickly put together this which seems to preserver

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
In order to do that you would have to reach to the interface behind the protocol...observer this: user= (defprotocol P (f1 [_] nil)) P user= P {:on-interface user.P, :on user.P, :sigs {:f1 {:doc YES!, :arglists ([_]), :name f1}}, :var #'user/P, :method-map {:f1 :f1}, :method-builders

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
On 12/01/14 13:04, bob wrote: Exactly! the compiler throws the reflection warnings, I want to type hint for the input parameters to eliminate the warnings. you must be doing something wrong as a pure protocol based implementation that doesn't involve interop, shouldn't exhibit

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
On 12/01/14 13:07, Jim - FooBar(); wrote: On 12/01/14 13:04, bob wrote: Exactly! the compiler throws the reflection warnings, I want to type hint for the input parameters to eliminate the warnings. you must be doing something wrong as a pure protocol based implementation that doesn't

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
Haha I knew it Instead of using .ret-value and .write use cqrs.storage/ret-value and cqrs.storage/write...Also in your ns declaration you don't really need to bring in the protocol. YOu can bring in the functions it defines :) Jim On 12/01/14 13:22, bob wrote: Sure, here has a

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
many protocols is to put them all in a single file and :refer :all it. hope that helps, Jim On 12/01/14 13:27, Jim - FooBar(); wrote: Haha I knew it Instead of using .ret-value and .write use cqrs.storage/ret-value and cqrs.storage/write...Also in your ns declaration you don't really need

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
It is not compiling because it cannot find the function...either fully qualify it like in my previous email or change your ns declaration to something like: [cqrs.storage :as stora] and then simply use stora/ret-value, stora/write, stora/write-batch Jim On 12/01/14 13:26, bob wrote: If I

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
On 12/01/14 13:38, Jim - FooBar(); wrote: It is not compiling because it cannot find the function...either fully qualify it like in my previous email or change your ns declaration to something like: [cqrs.storage :as stora] and then simply use stora/ret-value, stora/write, stora/write-batch

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
oops (set! *clojure.core*/*warn-on-reflection* true) instead of (set! *user*/*warn-on-reflection* true) On 12/01/14 13:52, Jim - FooBar(); wrote: there you go: (defprotocol IBark (bark [this])) (in-ns 'other) (set! user/*warn-on-reflection* true) (clojure.core/defrecord Dog [] user

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
On 12/01/14 13:57, bob wrote: Thanks for the big help, I treated the protocol as interface. :) no worries :) I was also surprised to see that you are type-hinting the clojure.lang.Atom...why would you do that? from what I can see you are only using `reset!` and `swap!`...I doubt that you are

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
On 12/01/14 13:59, Jim - FooBar(); wrote: On 12/01/14 13:57, bob wrote: Thanks for the big help, I treated the protocol as interface. :) no worries :) I was also surprised to see that you are type-hinting the clojure.lang.Atom...why would you do that? from what I can see you are only using

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
On 12/01/14 14:15, Jim - FooBar(); wrote: (map [this f] (let [^DBIterator iterator (.iterator db)] (.seekToFirst iterator) (clojure.core/map #(apply f %) (iterator-seq iterator or even nicer: (map [this f] (let [^DBIterator iterator (doto (.iterator db) .seekToFirst)] (clojure.core

Re: Hello, hereĀ“s a new clojur adict... with a question.

2014-01-14 Thread Jim - FooBar();
an atom cannot be used as a function! deref it first to get the vector inside and then try again... Jim On 14/01/14 11:25, Andreas Olsson wrote: Cant get this to work. (def sx2(atom [2 3 4])) (println (sx2 3)) Den tisdagen den 14:e januari 2014 kl. 12:04:27 UTC+1 skrev Omer Iqbal:

Re: Grouping and nested keys in a hash

2014-01-16 Thread Jim - FooBar();
You could do something like this: (def v {:a--id 1 :a--name A :b--id 2 :b--name B}) (group-by #(- % first str second str keyword) v) ={:b [[:b--name B] [:b--id 2]], :a [[:a--id 1] [:a--name A]]} (reduce-kv #(assoc % %2 (into {} %3)) {} *1) = {:a {:a--id 1, :a--name A}, :b {:b--name B,

Re: [Large File Processing] What am I doing wrong?

2014-01-21 Thread Jim - FooBar();
On 21/01/14 13:11, Chris Perkins wrote: This part: (some #{hashed} already-seen) is doing a linear lookup in `already-seen`. Try (contains? already-seen hashed) instead. +1 to that as it will become faster... I would also add the following not so related to performance: (drop1 (line-seqf))

Re: random thought on #_

2014-01-22 Thread Jim - FooBar();
On 22/01/14 13:21, Christophe Grand wrote: #_ nests nicely: #_#_ comments out the next two expressions. Christophe WHAT?!!! I had no idea.I guess you do learn something new every day :) Jim -- -- You received this message because you are subscribed to the Google Groups Clojure group. To

Re: equality

2014-01-27 Thread Jim - FooBar();
Use `==` instead: user= (== 42 42.0) true user= (== 42 42M) true Jim On 27/01/14 13:41, Dennis Haupt wrote: one does not simply compare floating point numbers for equality 2014-01-27 Eric Le Goff eleg...@gmail.com mailto:eleg...@gmail.com Newbie question : user= (= 42 42)

David Nolen's sudoku solver not compatible with Peter Norvig's generator?

2014-01-30 Thread Jim - FooBar();
Hi all, I think we are all familiar with the wonderful core.logic implementation of a sudoku solver by David Nolen. Now, I am trying to combine his solver with the `random-puzzle` generator shown here ( http://jkkramer.com/sudoku.html). I have made the necessary changes (to deal with seqs

Re: David Nolen's sudoku solver not compatible with Peter Norvig's generator?

2014-01-31 Thread Jim - FooBar();
On 31/01/14 00:47, Norman Richards wrote: I don't know how many solutions there are, but it seems like there are a lot... I think you are just generating all of them and it's taking a long time. spot on!!! I was just being stupid (again)...tried with `first` and worked immediately :)

Re: Should predicates always have one argument?

2014-01-31 Thread Jim - FooBar();
A predicate is something that returns true or false. Nothing more nothing less...you can have as many args as you want - it is still a function predicate :) Jim On 31/01/14 16:44, Ryan wrote: Hello, I am wondering if all my predicates should be one argument functions because I run into a

Re: How to organize clojure functions? A clojure newbie here...

2014-02-03 Thread Jim - FooBar();
I suggest you check this out: https://github.com/jimpil/MultiSnake/blob/master/src/multi_snake/core.clj It is within the LOC you asked and shows a complete snake-game. It has been adopted and extended from the book Programming Clojure, to handle 2 snakes and some other stuff like dying when

Re: Programming clojure second Edition

2014-02-03 Thread Jim - FooBar();
a vector is a function of its indices a map is a function of its keys a set is a function of its elements does this help at all? Jim On 03/02/14 15:29, action wrote: (defn index-filter [pred coll] (when pred (for [[idx elt] (indexed coll) :when (pred elt)] idx))) (index-filter #{\a

range-sum

2014-02-06 Thread Jim - FooBar();
Hi all, I often see this code for summing up a range from 0-N : `(reduce + (range N))` However there is a much faster way for this : `(/ (* N (dec N)) 2)` Do you think this should be in the language so that people do not use the slow version? Jim -- You received this message because

Re: Error throw when defining function with return type hint

2014-02-10 Thread Jim - FooBar();
On 10/02/14 15:08, macdevign mac wrote: (defn testing (^String []) (.toUpperCase hello world)) ;;syntax for overloading (defn testing (^String [] ;;notice the omitted bracket (.toUpperCase hello world)) (^String [^String a] (.toUpperCase a)) ) ;;non-overloaded fns (defn

Re: How would I write it with concurrency

2014-02-10 Thread Jim - FooBar();
If `session` returns a list, why don't you just do `(take 5 (repeatedly session))` ??? with regards to concurrency I am not sure what you're asking...you want to do the same thing from multiple threads and accumulate a global result? Jim On 10/02/14 18:46, Haim Ashkenazi wrote: Hi I have a

Re: Email delivery libs not working

2014-02-24 Thread Jim - FooBar();
How about the JavaMail API? here is an example : (defn- map-properties Converts a MapString, String to a java.util.Properties object. [^java.util.Map property-value-map] {:pre [(every? #(every? string? %) property-value-map)]} (doto (java.util.Properties.) (.putAll property-value-map)))

Re: map and lazy sequence

2014-02-28 Thread Jim - FooBar();
Clojure works on a chunked basis for performance reasons...THe size of a chunk is 32 elements - thus you would actually get 32 printouts if you supplied a collection larger than 31 elements. Jim On 28/02/14 17:04, Andy Smith wrote: Hi, Can someone correct my misunderstanding here. I was

Re: SIGBUS : A fatal error has been detected by the Java Runtime Environment

2013-01-28 Thread Jim - FooBar();
I feel obliged to come in and say that using this flag did not cure my problem completely...This error is still thrown whenever i use ^:const and reducers to traverse tree of moves deeper than 6...It doesn't happen always but most of the times! If i don't use ^:const it seems to not happen.

Re: SIGBUS : A fatal error has been detected by the Java Runtime Environment

2013-01-28 Thread Jim - FooBar();
: Hi Jim, did you try a 32bit jvm? I wonder if it still happens with that On Mon, Jan 28, 2013 at 7:28 PM, Jim - FooBar(); jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: I feel obliged to come in and say that using this flag did not cure my problem completely...This error

Re: SIGBUS : A fatal error has been detected by the Java Runtime Environment

2013-01-28 Thread Jim - FooBar();
On 28/01/13 18:58, larry google groups wrote: Interesting. My app leans heavily on (reduce). I think in some places I might call reduce from inside of another reduce. This is the problem then? No no I don't mean plain old 'reduce' but the new 'reducers' library in 1.5... Jim -- -- You

Re: How to use pmap over a partition-all list of list?

2013-02-02 Thread Jim - FooBar();
Use this: (pmap #(reduce + %) (partition-all 5 (range 1 20))) OR as you yourself said you can use 'apply' instead of reduce Jim On 02/02/13 12:31, Leandro Moreira wrote: Hi there, I have this: *user=* (partition-all 5 (range 1 20)) ((1 2 3 4 5) (6 7 8 9 10) (11 12 13 14 15) (16 17 18

Re: How to use pmap over a partition-all list of list?

2013-02-02 Thread Jim - FooBar();
aaa you want a scalar as the result? then use an outer reduce as well: (reduce + (pmap #(reduce + %) (partition-all 5 (range 1 20 =190 Jim On 02/02/13 13:10, Jim - FooBar(); wrote: Use this: (pmap #(reduce + %) (partition-all 5 (range 1 20))) OR as you yourself said you can use 'apply

Re: How to use pmap over a partition-all list of list?

2013-02-02 Thread Jim - FooBar();
apply does exactly what you're describing...it treats a collection as several arguments: (apply + [1 2 3 4]) is equivalent to: (+ 1 2 3 4) = 10 so (pmap + '(1 2 3) '(4 5 6) '(7 8 9) ) is equivalent to: (apply pmap + ['(1 2 3) '(4 5 6) '(7 8 9)]) no need for macros and stuff...actually apply

Re: constructing matrix-like structures with list-comprehension

2013-02-05 Thread Jim - FooBar();
Ok, I think I cracked it but as usual someone else might come up with a cleaner approach...:-) (defn matrix [dim dim-lengths] {:pre [(not (nil? dim))]} ;;cannot accept (let [bindings (map #(vector (gensym) `(range ~%)) dim-lengths) symbols (mapv first bindings) counts (inc

Re: constructing matrix-like structures with list-comprehension

2013-02-06 Thread Jim - FooBar();
Hi Mike, thanks for your reply...I've actually been keeping a very close eye on core.matrix since day 1 and I have to admit I am very very tempted to start contributing...My research is on Text-mining which as you probably know is machine-learning on text (mainly sequence-labelling, HMM based

protocol implementation delegating to protocol extension doesn't compile

2013-02-14 Thread Jim - FooBar();
let me explain with an example: ;;in some namespace x (defprotocol IStemmable (stem [this token] [this token lang]) (getRoot [this token dictionary])) (defprotocol IDistance (getDistance [this s1 s2] [this s1 s2 m-weight])) ;;in some namespace y that refers all vars from x (extend-type

Re: protocol implementation delegating to protocol extension doesn't compile

2013-02-15 Thread Jim - FooBar();
Hi Juan, I have to admit you're a life saver! You didn't say anything that I did not know but you did make a couple of observations that made me have a closer look on my code...For example you noticed that the protocol extension to String was never registered...That is the *real* problem

Re: Why is this so difficult?

2013-02-17 Thread Jim - FooBar();
clojure-doc.org ?? OMG, is this new? it seems to have some gorgeous tutorials for newcomers...LIke Bizics, i had no idea this site existed! How come google is not showing this in the first page when typing Clojure docs or something like that? I'm definately bookmarking this...

Re: Using local jar

2013-02-17 Thread Jim - FooBar();
Even though what Aaron said is correct, I'll just add that with lein2 you can get away with not installing your jar in ~/.m2/. Just use the :resource-paths key in your project.clj and point to a folder with 'orphan' jars...something like this: :resource-paths [orphan-jars/*] ;;all jars under

Re: Creating a hash-map with conditional keys

2013-02-21 Thread Jim - FooBar();
I think Alex is trying to say that a macro is almost never appropriate when a first-class function would do...therefore, there is no good reason for carrying the complexity of macros all over your code, given that in your case they do nothing special (like postponed evaluation) and can be

protocol granularity

2013-02-23 Thread Jim - FooBar();
Hi everyone, I'm facing a little problem when extending protocols in a mix of inheriting and implementing classes...Let me explain: stanford-corenlp defines a top level interface called Annotator (with a single 'annotatate' method signature'). It also defines a class called

creating code stubs to use inside an extend-protocol form

2013-02-23 Thread Jim - FooBar();
I seem to be unable to quote a form and then repeatedly pass it inside the extend-protocol macro...something like this: (def ^:private co-stub '(run [this ^String text] (let [ann (edu.stanford.nlp.pipeline.Annotation. text)] (.annotate this ann) ann))) (extend-protocol IComponent

Re: creating code stubs to use inside an extend-protocol form

2013-02-24 Thread Jim - FooBar();
Thanks to both Atkaaz Tim... you were both very helpful, albeit for different reasons! Atkaaz pointed me to a promising syntax-quoting library that I didn't even know existed and Tim essentially provided the solution I settled for. Since that code-snippet can be found in core, I'll just

attaching doc-string from macro is driving me insane!

2013-02-24 Thread Jim - FooBar();
Hi everyone, I cannot figure out for the life of me how to pass in an optional doc-string into a 'defsomething' macro and have it to work. If I hard-code it then it works just fine... (defmacro def-plus-doc [name syms] `(def ~(with-meta name (assoc (meta name) :doc HI!)) ~@syms)) ;;this

Re: attaching doc-string from macro is driving me insane!

2013-02-24 Thread Jim - FooBar();
inside the ` but failed On Sun, Feb 24, 2013 at 6:02 PM, Jim - FooBar(); jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: Hi everyone, I cannot figure out for the life of me how to pass in an optional doc-string into a 'defsomething' macro and have it to work. If I hard-code

Re: attaching doc-string from macro is driving me insane!

2013-02-24 Thread Jim - FooBar();
(NO_SOURCE_FILE:3) On Sun, Feb 24, 2013 at 7:49 PM, Jim - FooBar(); jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: I tried with eval, tried the let inside and outside the syntax-quote - I've tried everything! This is so frustrating! Jim On 24/02/13 18:24, AtKaaZ wrote: ds

Re: attaching doc-string from macro is driving me insane!

2013-02-24 Thread Jim - FooBar();
On 24/02/13 19:44, AtKaaZ wrote: you can maybe do with just (vec components) instead of (vector ~@components) nice one! it works :) Jim -- -- 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

Re: attaching doc-string from macro is driving me insane!

2013-02-24 Thread Jim - FooBar();
On 24/02/13 19:44, AtKaaZ wrote: The problem is that you cannot catch that assert if it throws, ie. inside a deftest - just because it happens at compile time... a deftest will have its own top-level assertion...this is for client usage -- -- You received this message because you are

was there a time when clojure empty seqs were falsy?

2013-02-25 Thread Jim - FooBar();
I found this code snippet [1] written by Rich but presumably using a very old version of Clojure. The thing that stand out the most is this at the bottom (the 'correct' fn): (or (known [word] *nwords*) (known (edits1 word) *nwords*) (known-edits2 word *nwords*) [word]) It

Re: was there a time when clojure empty seqs were falsy?

2013-02-25 Thread Jim - FooBar();
I see... thanks a lot! :-) Jim On 25/02/13 12:34, David Powell wrote: Some time before the release of Clojure 1.0, there didn't used to be any such thing as an empty sequence. You either had a (lazy) sequence, or nil. This made it easy to use sequences as emptiness tests, but had the cost

Re: problem redefining protocols and records in emacs+nrepl

2013-02-27 Thread Jim - FooBar();
I'm not sure I fully understand the problem but I'll do my best to guess... 1) are you sure you're using the protocol or are you actually trying to define a method in the interface that the protocol generates? Try fully qualifying the name of you protocol at the extension point... 2)Do your

Re: what on earth is happening?

2013-02-28 Thread Jim - FooBar();
I just walked in home, sat on my pc, /git-pull/ (what I pushed 30 min ago), /lein2 repl/, /load-file xxx.clj/ , *BOOM!* CompilerException java.lang.VerifyError: (class: hotel_nlp/concretions/models/Workflow, method: run signature: ()Ljava/lang/Object;) Unable to pop operand off an empty

Re: what on earth is happening?

2013-02-28 Thread Jim - FooBar();
No I did not try Oracle Java6 and it would be a real hassle since it's not even installed...I think I've got openJDK 6 though...hmm I'll poke around with the dependencies of the namespace I'm trying to load see if that changes anything and if it doesn't I'll give openJDK a spin... Clojure

Re: what on earth is happening?

2013-02-28 Thread Jim - FooBar();
On 28/02/13 17:29, David Nolen wrote: Your run protocol defines three arities, you do not implement all three. what's wrong with that? protocols, unlike interfaces let you do that... Did you try limiting the definition of the run protocol to the two arity case that you are actually

Re: what on earth is happening?

2013-02-28 Thread Jim - FooBar();
are very knowledgeable and always have good insights/suggestions so I'm only trying to learn. Jim On 28/02/13 18:05, David Nolen wrote: On Thu, Feb 28, 2013 at 1:00 PM, Jim - FooBar(); jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: On 28/02/13 17:29, David Nolen wrote

Re: what on earth is happening?

2013-02-28 Thread Jim - FooBar();
On 28/02/13 18:16, Softaddicts wrote: We AOT all our code here and even that prove hard to stabilize with multiple arities. doesn't /lein2 check/ do AOT? how else would it be able to emit reflection warnings? If that is the case, I always AOT my code periodically too. In this particualr case

fully populated protocols (or not)?

2013-03-01 Thread Jim - FooBar();
Hi all, Since yesterday, I've been thinking about something David Nolen said in my /what on earth is happening?/ post. In a nutshell, he suggested that protocols *should* be fully populated. Luc from softaddicts agreed and actually shared his own horrific experiences with non-fully populated

Re: fully populated protocols (or not)?

2013-03-01 Thread Jim - FooBar();
but multiple arities correspond to different method signatures on the interface level and in fact the protocol level as well...when you implement either you really treat them as separate fns/methods...how does the one complect (not implementing some arity) and the other doesn't (not

Re: fully populated protocols (or not)?

2013-03-01 Thread Jim - FooBar();
On 01/03/13 15:15, Meikel Brandmeyer (kotarak) wrote: However for some reason I seldomly have the desire to use multiple arities in protocol functions. this is the case for me too but only when I'm working in an all-Clojure project...when doing interop though and especially when I need to

Re: problem redefining protocols and records in emacs+nrepl

2013-03-01 Thread Jim - FooBar();
On 01/03/13 15:44, Joachim De Beule wrote: When I change the number of slots in a record, e.g. from (defrecord MyRecord [slot1 slot2] ...) to (defrecord Myrecord [slot1] ...) are you reloading the namespace between these steps? Jim -- -- You received this message because you are

Re: problem redefining protocols and records in emacs+nrepl

2013-03-01 Thread Jim - FooBar();
On 01/03/13 16:17, Joachim De Beule wrote: I'm not sure what you mean. I am not changing between namespaces in this last example, only trying to delete a slot from a record definition and create a record according to the new definition subsequently. The problem occurs even when I do a C-c C-k

Re: Possible to suppress some stderr output?

2013-03-05 Thread Jim - FooBar();
I don't know if you can suppress it, but you can certainly ignore it with 'without-str' which will give you what was supposed to be printed out, as a string...then it's up to you what to do with it... :) HTH, Jim On 05/03/13 08:56, bruce li wrote: Hi, guys, I'm currently playing clojure

Re: Possible to suppress some stderr output?

2013-03-05 Thread Jim - FooBar();
(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722 2013/3/5 Jim - FooBar(); jimpil1...@gmail.com mailto:jimpil1...@gmail.com I don't know if you can suppress it, but you can certainly ignore

Re: Possible to suppress some stderr output?

2013-03-05 Thread Jim - FooBar();
)] (binding [*out* s# *err* s#] ~@body (str s# Jim On 05/03/13 14:33, Jim - FooBar(); wrote: aaa sorry...I guess I should have tested first... Jim On 05/03/13 14:24, bruce li wrote: Thanks, Jim. But with-out-str only works for output to *out*(stdout), but not *err*(stderr

Re: Possible to suppress some stderr output?

2013-03-05 Thread Jim - FooBar();
still doesn't work though! strange... why would you want to do this anyway? Jim On 05/03/13 14:35, Jim - FooBar(); wrote: but then it's pretty trivial to adapt it: (defmacro with-out-err-str Evaluates exprs in a context in which *out* and *err* ire bound to a fresh StringWriter

Re: Possible to suppress some stderr output?

2013-03-05 Thread Jim - FooBar();
On 05/03/13 14:50, bruce li wrote: What is the difference between *err* and System/err?! its the same but wrapped in a PrintWriter http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/*err* Jim -- -- You received this message because you are subscribed to the Google Groups

how does one embed nrepl in his own application?

2013-03-05 Thread Jim - FooBar();
Hi all, I am intrigued about the idea of communicating with my application remotely...The book 'Clojure Programming' says that nrepl comes with a consumer lib and is easily embeddable to your apps. Can anyone point me to a direction where I can find more? perhaps someone ha already done that

Re: Possible to suppress some stderr output?

2013-03-05 Thread Jim - FooBar();
the *err* writer, but instead use the System/err stream will not get affected. Hope this makes sense. 2013/3/5 Jim - FooBar(); jimpil1...@gmail.com mailto:jimpil1...@gmail.com On 05/03/13 14:50, bruce li wrote: What is the difference between *err* and System/err?! its the same

Re: how does one embed nrepl in his own application?

2013-03-05 Thread Jim - FooBar();
wow! that is 10 times easier than I expected...I guess I'll have to ditch the socket-based approach... thanks Martin :) Jim On 05/03/13 15:22, Weber, Martin S wrote: $ lein new replbuiltin cd replbuiltin $ sed -Ee 's,.0,.0][org.clojure/tools.nrepl 0.2.2,' project.clj p mv -f p

Re: how does one embed nrepl in his own application?

2013-03-05 Thread Jim - FooBar();
this is brilliant, thanks a lot! Jim On 05/03/13 15:45, Chas Emerick wrote: See https://github.com/clojure/tools.nrepl#embedding-nrepl-starting-a-server Cheers, - Chas -- http://cemerick.com [Clojure Programming from O'Reilly](http://www.clojurebook.com) On Mar 5, 2013, at 10:03 AM, Jim

Re: how does one embed nrepl in his own application?

2013-03-05 Thread Jim - FooBar();
On 05/03/13 15:22, Weber, Martin S wrote: $ lein run -m replbuiltin.core $ lein repl :connect 42042 user= (in-ns 'replbuiltin.core) replbuiltin.core= (foo 42) 42 trying to use 'telnet localhost' instead of 'lein repl :connect' cos I may not have lein access, and it doesn't work! I don't get

  1   2   3   4   5   6   7   >