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: 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: 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

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: 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

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

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: 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)

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: [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: 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: 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: 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: 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: 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: 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: 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: 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

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: 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

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

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

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,

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-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

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: 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 =

instaparse: composing smaller rules into a bigger one

2013-11-18 Thread Jim - FooBar();
Hi all, I'm having a small problem composing smaller matches in instaparse. Here is what I'm trying...just observe the bold bits: (def parsePK (insta/parser S = TOKEN (SPACE TOKEN PUNCT?)* END TOKEN = (NUM | DRUG | PK | DRUGPK | MECH | SIGN | EFF | ENCLOSED) / WORD WORD =

a possibly vague question

2013-11-14 Thread Jim - FooBar();
Hi people, I 'll have to apologise in advance for the potential vagueness of my question but I am utterly baffled by the behaviour I am seeing and I'd like to share ask. I have a (seesaw) GUI with a swingx.busy-label which I want activated when certain tasks are performed. The code that

Re: a possibly vague question

2013-11-14 Thread Jim - FooBar();
mailto:joshnet2...@gmail.com wrote: Try to create a simple app that just demonstrate the issue. Then send the sample to the mailing list. Most likely you won't have to send because you will discover the problem in the process. Josh On 14 Nov 2013 23:08, Jim - FooBar(); jimpil1

Re: a possibly vague question

2013-11-14 Thread Jim - FooBar();
in the process. Josh On 14 Nov 2013 23:08, Jim - FooBar(); jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: Hi people, I 'll have to apologise in advance for the potential vagueness of my question but I am utterly baffled by the behaviour I am seeing and I'd

Re: How to convert this simple (and inefficient) fibonacci function to # format

2013-11-13 Thread Jim - FooBar();
you don't need 'fn' when you're using #(...) - that is the whole point. To not have to declare a function and its args explicitly. this particular example you cannot write using #() syntax though because it is recursing at 2 points and you cannot use 'recur'. Jim wOn 13/11/13 17:41, Angus

Re: Regarding Clojure's license

2013-11-12 Thread Jim - FooBar();
sorry for nitpicking but Richard Stallman has spent some 35 years explaining/defining what is meant by free. I will not pretend that I know what all these licences say or even that I spend too much time deciding what license to use for my own code but at least a philosophical level, I stand

Re: StackOverflowError

2013-11-09 Thread Jim - FooBar();
Hi Ru, Think of it this way...In Java you can't declare something as public from within a method. Ok, in Java this would break the object's contract but even if you look at languages like python, you still don't define global variables from within functions. I have seen python code where

macro definition slight problem

2013-11-05 Thread Jim - FooBar();
Hi all, I was under the impression that I fully understood what name-with-attributes does but I'm having a slight problem. I'm trying to define macros like the following: (defmacro defworkflow Defines a top-level Workflow with the specified name optionally doc-string and attr-map on the

Re: Incanter/vector-clj use error

2013-10-31 Thread Jim - FooBar();
On 31/10/13 12:43, P Martin wrote: To clarify my error, I did not put your suggestion into the ns declaration. I called it on a separate line of code. I now just have all of my require statements at the top of my clj files with proper aliasing and it works fine. well yes if you do have a

instaparse question

2013-10-31 Thread Jim - FooBar();
Hi all, I'm starting to get the hang of instaparse and it just looks awesome! However there is a little thing that bugs meI may be doing it wrong that why I'm asking here. The behaviour that I want sounds reasonable at least to me...so here is an example: (insta/parser S = TOKEN

Re: Request for help optimising a Clojure program

2013-10-31 Thread Jim - FooBar();
awesome news :) Jim On 31/10/13 14:19, Andy Fingerhut wrote: Just a follow up after a fair amount of thinking and experimentation has been done on this problem. Mark Engelberg has a very nice document describing the existing hash functions used by Clojure, examples with why they can cause

Re: instaparse question

2013-10-31 Thread Jim - FooBar();
On 31/10/13 16:23, Jim - FooBar(); wrote: The result of this is a parser which sees everyhting as :TOKEN. That is because WORD matches almost everything. However I thought that putting it last would remedy the situation...it seems that the most general rule is applied first. Is that by design

Re: instaparse question

2013-10-31 Thread Jim - FooBar();
On 31/10/13 17:21, Lars Nilsson wrote: Perhaps remove DRUG from the grammar and use the transform function on a parse-result to do something like (insta/transform {:WORD (fn [w] (if (...) [:DRUG w] [:WORD w]))} parse-result) so [:DRUG w] is emitted for whatever criteria you may have (lookup)

Re: Why isn't a docstring allowed for defrecord?

2013-10-30 Thread Jim - FooBar();
On 30/10/13 16:19, Mars0i wrote: Still, I'm surprised. /Why/ can't I document a record type with a docstring? of course you can...just add a :doc key in the record's meta :) Jim -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this

Re: Incanter/vector-clj use error

2013-10-30 Thread Jim - FooBar();
On 30/10/13 16:56, P Martin wrote: Thanks - I'm still a little confused on the different between use and require. 'use' is sort of deprecated after it was noticed that people were abusing it. It's not exactly deprecated because in some cases like incremental development at the repl it is

Re: Why isn't a docstring allowed for defrecord?

2013-10-30 Thread Jim - FooBar();
On 30/10/13 16:54, Phillip Lord wrote: Jim - FooBar(); jimpil1...@gmail.com writes: On 30/10/13 16:19, Mars0i wrote: Still, I'm surprised. /Why/ can't I document a record type with a docstring? of course you can...just add a :doc key in the record's meta :) The OP is correct. He says why

Re: Overwrite equals in defrecord

2013-10-22 Thread Jim - FooBar();
use deftype which is more low-level and I think doesn't define equals or put y in meta data that don't participate in equality...:) Jim On 22/10/13 22:44, Marc Dzaebel wrote: http://cmayes.wikispaces.com/PracticalClojure13: ... defrecord does not support Java class inheritance, so it

Re: is PG's imperative outside-in advice any good?

2013-10-15 Thread Jim - FooBar();
On 15/10/13 18:02, Sean Corfield wrote: One construct using let that I see in my code quite a bit that I haven't figured out a cleaner way to express: (let [x (some-expression)] (if (p x) (f x) (g x))) wasn't cond- designed exactly for that? (let [x (some-expression)] (cond- x

Re: How to type hint a String array?

2013-10-09 Thread Jim - FooBar();
From the 1.3 docs: ;; Currently Clojure does not permit type hints of arrays, e.g. ^ints as ;; argument types or return types in a definterface. This may be enhanced ;; later. Jim ps: also, non-primitive arrays are hinted like this if I'm not mistaken: #^[Ljava.lang.String; On 09/10/13

Re: How to type hint a String array?

2013-10-09 Thread Jim - FooBar();
On 09/10/13 14:12, Jim - FooBar(); wrote: ps: also, non-primitive arrays are hinted like this if I'm not mistaken: #^[Ljava.lang.String; actually you can use both #^ ^ in regular 'defn' Jim -- -- You received this message because you are subscribed to the Google Groups Clojure group

light-table doesn't like (set! *unchecked-math* true)

2013-09-24 Thread Jim - FooBar();
Hi all, does anyone have a clue why light-table 0.5.3 throws exception whenever it sees a (set! *unchecked-math* true)? I mean it swallows (set! *warn-on-reflection* true) just fine! Is this a bug? the actual exception is (set! *warn-on-reflection* true) (set! *unchecked-math* true)

Re: much lower recursion depth with memoization

2013-09-23 Thread Jim - FooBar();
as Armando pointed out unless you remove the stack-issue memoization is not going become your friend. My take would be to simply use loop/recur and then you can memoize 'relentlessly', as Rich likes to put it :) (defn gauss-recurse [n] (loop [i n acc n] (if (zero? i) acc (recur

how does one unquote a list of records that implement IFn without treating the first item as a function?

2013-09-05 Thread Jim - FooBar();
HI all, I've gotten myself into a weird situation... I'm defining a def-like macro and I want to use 'name-with-attributes'. Consider the following skeleton: (defmacro defX [name args] (let [[name attrs] (name-with-attributes name args)] `(let [cs-coll# ~attrs] (assert (every?

Re: how does one unquote a list of records that implement IFn without treating the first item as a function?

2013-09-05 Thread Jim - FooBar();
I ended up using (list ~@attrs) which is very similar to what you're suggesting...:) JIm On 05/09/13 20:22, Dave Ray wrote: ~(vec attrs), perhaps? On Thu, Sep 5, 2013 at 12:20 PM, Jim - FooBar(); jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: HI all, I've gotten myself

Re: A macro for writing defn-like macros?

2013-09-03 Thread Jim - FooBar();
I've been staring at this function for 20 minutes now (name-with-attributes)...I must be totally stupid but even though I 've understood what it does I can't figure out how to use it. Does anyone have an example usage? Let's suppose I want to define a DEFN macro that behaves exactly like

Re: A macro for writing defn-like macros?

2013-09-03 Thread Jim - FooBar();
Yes! I eventually figured it out...thanks Konrad :) Jim On 03/09/13 20:49, Konrad Hinsen wrote: --On 3 septembre 2013 19:08:12 +0100 Jim - FooBar(); jimpil1...@gmail.com wrote: understood what it does I can't figure out how to use it. Does anyone have an example usage? Let's suppose I want

Re: too circular?

2013-08-29 Thread Jim - FooBar();
On 29/08/13 20:23, JvJ wrote: I wonder if the somewhat counterintuitive concept of a named anonymous function eludes some people, or isn't properly conveyed in tutorials. I only consider #(...) as an anonymous function. The longer form (fn [] (...)) has the potential of being perfectly

Re: problem with edn

2013-08-26 Thread Jim - FooBar();
On 23/08/13 10:49, Jim wrote: I do regret not having checked whether Java serialization preserves the metadata or not .I plan to do it this afternoon. If it does ,I've got 2 perfectly working ways to achieve what I want, with no extra dependencies added... I finally got the chance to check

Re: ANN: clj-tuple, efficient small collections

2013-08-26 Thread Jim - FooBar();
I had a quick look at clj-tuple and I don't remember seeing any macros... Jim On 26/08/13 19:02, Asim Jalis wrote: I believe this is what clj-tuple is doing under the hood with macros. On Aug 26, 2013, at 10:38 AM, Kevin Downey redc...@gmail.com wrote: A Tuple protocol that defines get0

Re: ANN: clj-tuple, efficient small collections

2013-08-25 Thread Jim - FooBar();
wow! very interesting stuff as always Zach...quick question: I don't see Tuple implementing clojure.lang.Associative, so 'get' won't work right? Jim ps: I've got a project where I 'm working with a lot of 2-element vectors...I can't wait to try this out :) On 25/08/13 03:38, Zach Tellman

Re: problem with edn

2013-08-22 Thread Jim - FooBar();
all I'm trying to do is to provide a uniform mechanism to save/load game-states across my 2D board-games. Everything works just fine without that trick for most games but chess is peculiar (or my implementation is peculiar if you like) because in order to implement castling/enpassant moves

Re: NotSerializableException clojure.core.Vec

2013-08-21 Thread Jim - FooBar();
? Jim On 20/08/13 20:17, Jim - FooBar(); wrote: Hi all, I've a rather strange problem...I know that all clojure collections implement Serializable but when I try to use standard Java serialization on a vector of records I get this exception: /NotSerializableException clojure.core.Vec

problem with edn

2013-08-21 Thread Jim - FooBar();
Hi everyone, I am trying to serialise a record with edn. I think I am using all the good practices but I get a weird error...I am using these simple functions: (defn data-string Writes the object b on a file f on disk as a string. [b f] (io! (with-open [w (clojure.java.io/writer f)]

NotSerializableException clojure.core.Vec

2013-08-20 Thread Jim - FooBar();
Hi all, I've a rather strange problem...I know that all clojure collections implement Serializable but when I try to use standard Java serialization on a vector of records I get this exception: /NotSerializableException clojure.core.Vec java.io.ObjectOutputStream.writeObject0

Re: calling java static member using string?

2013-08-14 Thread Jim - FooBar();
why on earth is this a macro and not a regular fn? Jim On 14/08/13 16:19, Daniel Meneses wrote: Hi! Thanks for your answer Sean I got it solved using clj-time Also I found the problem with my macro attempt user (defmacro is [s instant] `(= (.get ~instant

Re: calling java static member using string?

2013-08-14 Thread Jim - FooBar();
On 14/08/13 16:45, Daniel Meneses Báez wrote: (defn is [s instant] (= (.get instant Calendar/DAY_OF_WEEK) (. Calendar s))) (def ^:private day-int {:MONDAY 2 :TUESDAY 3 :WEDNESDAY 4 :THURSDAY 5 :FRIDAY 6 :SATURDAY 7 :SUNDAY 1}) (defn is-today? ([s instant] (= (.get

Re: calling java static member using string?

2013-08-14 Thread Jim - FooBar();
On 14/08/13 17:46, Jim - FooBar(); wrote: On 14/08/13 16:45, Daniel Meneses Báez wrote: (defn is [s instant] (= (.get instant Calendar/DAY_OF_WEEK) (. Calendar s))) (def ^:private day-int {:MONDAY 2 :TUESDAY 3 :WEDNESDAY 4 :THURSDAY 5 :FRIDAY 6 :SATURDAY 7 :SUNDAY 1

Re: function creation, partial or #()

2013-08-13 Thread Jim - FooBar();
On 13/08/13 13:47, Jay Fields wrote: Say you have a simple function: (defn do-work [f] (f)) When you want to call do-work you need a function, let's pretend we want to use this function: (defn say-hello [n] (println hello n)) Which of the following solutions do you prefer? (do-work (partial

Re: [ANN] Leiningen 2.3.0 released

2013-08-09 Thread Jim - FooBar();
same here! can we get the 2.3.0.-jar from clojars? does anybody know? Jim On 09/08/13 08:14, Phillip Lord wrote: Also here on linux. Unfortunately, after upgrading the bash script, so it leaves a broken install. Phil From: clojure@googlegroups.com

Re: Wrong documentation of contains?

2013-08-07 Thread Jim - FooBar();
aa the old 'why contains? doesn't work' discussion...even though it's been a while since it last came up on this list, it must be the single most popular questions :) Jim On 07/08/13 12:24, Goldritter wrote: In an program I used the result of keys as an argument for a function which

Re: FYI: Intro to Clojure video from Java Tech Boise and Justin Reed

2013-08-04 Thread Jim - FooBar();
the video is not available from that link... Jim On 04/08/13 17:25, John Conti wrote: Hi all, Justin Reed recently spoke at our local user group on Clojure. One thing I like about this talk is it addresses many of the concerns and complaints of programmers who do not want to try Clojure

Re: FYI: Intro to Clojure video from Java Tech Boise and Justin Reed

2013-08-04 Thread Jim - FooBar();
hmmm... this is strange. I am getting the classic The video is currently unavailable. Learn more crap ... Jim On 04/08/13 20:59, Frank Hale wrote: That video seems to work fine for me. On Sun, Aug 4, 2013 at 3:56 PM, Jim - FooBar(); jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote

Re: extend-type on

2013-08-02 Thread Jim - FooBar();
your extension point on Number is never fired because 10 is a Long. Generally speaking extending protocols to interfaces is not suggested...I've been bitten a couple of times in particular whenever I'm extending to 2 different interfaces that *are* related...You can certainly do it but you

Re: extend-type on

2013-08-02 Thread Jim - FooBar();
it here : https://github.com/jimpil/hotel-nlp/blob/master/src/hotel_nlp/tools/normalito/core.clj 500 lines of pure protocol extension points! It is that long because a requirement of mine was not to output the same type as the input. Jim On 02/08/13 11:55, Jim - FooBar(); wrote: your

  1   2   3   4   5   6   7   >