Re: Why is the compiler more strict on one of my machines?

2013-04-16 Thread Jim foo.bar
It sounds to me that you forgot to run 'lein clean' at work, leaving certain classfiles present in 'target'. This would explain why you got your uberjar at work but not at home (presumably .class files are being ignored by git) Jim On 16/04/13 13:59, larry google groups wrote: I have a Mac

nice Clojure at Nokia talk

2013-04-12 Thread Jim foo.bar
Nice talk :) http://skillsmatter.com/podcast/scala/clojure-at-nokia-entertainment/wd-23 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 Note that posts from new members are

Re: defrecord and namespace-qualified symbols

2013-04-10 Thread Jim foo.bar
On 10/04/13 14:03, Simon Katz wrote: Second, Clojure supports namespace-qualified keywords, presumably because it's possible that different libraries might want to use the same keyword for different purposes. I don't think that is the reason for having namespace-qualified

Re: Something goofy you can do in Clojure.

2013-04-09 Thread Jim foo.bar
Hey Mark, don't get paranoid :)... this is all Cedric did! user= (def .3 0.4) #'user/.3 user= (+ .3 1.7) 2.1 Jim On 09/04/13 10:46, Mark Engelberg wrote: What version are you running? As far as I know, .3 isn't even a valid representation for a number -- you'd have to write it as 0.3. So

Re: Using update-in to produce vectors from nothing

2013-04-05 Thread Jim foo.bar
if I understood correctly you're looking for 'fnil' : =(update-in {} [:foo :bar] (fnil conj []) :a :b :c) {:foo {:bar [:a :b :c]}} Jim On 05/04/13 12:25, Simon Katz wrote: Hi. Is there an idiomatic way to have update-in create a vector when the supplied keys do not already exist? (Or maybe

Re: Using update-in to produce vectors from nothing

2013-04-05 Thread Jim foo.bar
aaa Laurent beat me to it! :) it seems we both understood the same thing so fnil is indeed your friend... Jim On 05/04/13 12:29, Jim foo.bar wrote: if I understood correctly you're looking for 'fnil' : =(update-in {} [:foo :bar] (fnil conj []) :a :b :c) {:foo {:bar [:a :b :c]}} Jim On 05

Re: Apply elements in a vector as arguments to function

2013-03-27 Thread Jim foo.bar
On 27/03/13 03:13, Michael Klishin wrote: Complain loudly to maintainers on this list that their documentation has gaps and they should clarify this and that. The idea that people should read the source to get reasonably straightforward stuff done is wrong and does a lot of long term damage to

Re: Concurrency and custom types.

2013-03-25 Thread Jim foo.bar
On 24/03/13 22:59, Andy Fingerhut wrote: It might not be obvious at first, but Clojure's immutable types are *not* immutable in the sense of they cannot be modified in place from within the JVM, but only in the sense of they cannot be modified in place by using Clojure's functions alone on

Re: Concurrency and custom types.

2013-03-25 Thread Jim foo.bar
On 25/03/13 12:08, Michael Klishin wrote: How often do you see implementation details such as PersistentVector#tail used in Clojure code? That is what matters. I've never seen that in Clojure code but is 'how responsible a programmer is' what really matters? In other words, are clojure's

Re: Concurrency and custom types.

2013-03-25 Thread Jim foo.bar
On 25/03/13 12:28, Michael Klishin wrote: There is no absolute immutability on the JVM, .NET, in JavaScript. There is always a backdoor to mutability. But 99.9% of projects won't use it. Andy hinted this last night as well...is this true? if I declare a Integer/String object as private

Re: Concurrency and custom types.

2013-03-25 Thread Jim foo.bar
On 25/03/13 12:45, Michael Klishin wrote: Not sure how strings and numerical types fit into this discussion about collection mutability. I only asked because you said there is no 100% immutability on the JVM. I also found this blog-post where Doug Lea joined in for a discussion...

Re: Concurrency and custom types.

2013-03-25 Thread Jim foo.bar
On 25/03/13 12:50, Shantanu Kumar wrote: However, I'd consider they are just implementation details and intended for idiomatic use from within the Clojure language. I think you meant *not* intended for idiomatic use from within the Clojure language. Jim -- -- You received this message

Re: Concurrency and custom types.

2013-03-25 Thread Jim foo.bar
On 25/03/13 12:55, Michael Klishin wrote: Take a look at https://blogs.oracle.com/jrose/entry/value_types_in_the_vm, it indicates that there is interest in true value types on the JVM but at best they will make it in JDK 9 in 2015. thanks for thisvery interesting stuff indeed... :) Jim

cannot get more than 94 fibonacci numbers - integer overflow

2013-03-25 Thread Jim foo.bar
I've literally tried all the variations of fibonaci sequences i could find! all of them throw an ArithmeticException integer overflow clojure.lang.Numbers.throwIntOverflow (Numbers.java:1388) as soon as I try more than 94 elements! my favourite version is this (from Christophe Grand ):

Re: cannot get more than 94 fibonacci numbers - integer overflow

2013-03-25 Thread Jim foo.bar
On 25/03/13 15:22, Ben Wolfson wrote: The 94th fibonacci number is greater than Long/MAX_VALUE, so it overflows. It is using longs. I seeshouldn't Clojure auto-promote it to a BigInt then? Jim -- -- You received this message because you are subscribed to the Google Groups Clojure group.

Re: cannot get more than 94 fibonacci numbers - integer overflow

2013-03-25 Thread Jim foo.bar
Cool, thanks guys :) Jim On 25/03/13 15:34, David Powell wrote: On Mon, Mar 25, 2013 at 3:24 PM, Jim foo.bar jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: On 25/03/13 15:22, Ben Wolfson wrote: The 94th fibonacci number is greater than Long/MAX_VALUE, so

Re: ANN: Illegal Argument podcast on Typed Clojure

2013-03-21 Thread Jim foo.bar
thanks guys! I enjoyed this.. :) Jim On 21/03/13 08:32, Mark Derricutt wrote: Hey all, We couldn't let everyone at Clojure/West have all the fun so our latest podcast is an awesome chat with Ambrose Bonnaire Sergeant all about Typed Clojure.

Re: Apparent interaction of libraries with lein

2013-03-14 Thread Jim foo.bar
Could it be that you're using lein1 instead of lein2? Is lein1 still actively maintained? In any case I suggest you upgrade to lein2... Jim On 14/03/13 12:48, Nico Swart wrote: The Leiningen project file I use include these dependancies: (defproject fb20try 1.0.0-SNAPSHOT :description

Re: fold over a sequence

2013-03-13 Thread Jim foo.bar
how come your project depends on the problematic version 1.5.0? Jim On 13/03/13 14:03, Paul Butcher wrote: Thanks Stuart - my Contributor Agreement is on its way. In the meantime, I've published foldable-seq as a library: https://clojars.org/foldable-seq I'd be very interested in any

Re: fold over a sequence

2013-03-13 Thread Jim foo.bar
there was a memory leak hence the 1.5.1 release the next day... Jim On 13/03/13 14:12, Paul Butcher wrote: On 13 Mar 2013, at 14:05, Jim foo.bar jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: how come your project depends on the problematic version 1.5.0? 1.5.0 is problematic

Re: fold over a sequence

2013-03-11 Thread Jim foo.bar
I don't think you will be able to do a parallel fold on a lazy-seq which is what clojure.data.xml/parse returns. Vectors are the only persistent collection that supports parallel fold and something tells me it's because they are NOT lazy... why can't you 'vec' the result of xml/parse and then

Re: What's the point of - ?

2013-03-11 Thread Jim foo.bar
On 11/03/13 15:08, Dave Kincaid wrote: I'm with you. I don't like it personally. Every time I come across it reading code I have to stop and think about what exactly it does. I didn't use to like it either but after coding rubik's cube I've come to appreciate it more...imagine this: (-

what on earth is happening?

2013-02-28 Thread Jim foo.bar
I've got a project 1. I can /'lein2 repl'/ in it and navigate to any namespace - no problem 2. I can /'lein2 check'/ it and it compiles everything - no problem 3. I can /'lein2 test'/ or /'lein2 test some-namespace'/ and BOOM! - *PROBLEM! * *Exception in thread main

Re: what on earth is happening?

2013-02-28 Thread Jim foo.bar
On 28/02/13 14:34, Marko Topolnik wrote: So it makes sense that it blows up only when you try to actually run the code. It doesn't low up when I try to run the code...as I said, I can easily navigate into any namespace from the repl and run any code that I wantso there is no problem

Re: what on earth is happening?

2013-02-28 Thread Jim foo.bar
On 28/02/13 15:12, Alex Robbins wrote: Maybe you are already doing this, but as soon as I get into This doesn't seem possible territory, I run a lein clean. That has resolved the problem for me several times. I've got nothing in /target...I am not AOT-compiling anything! I think i found the

Re: what on earth is happening?

2013-02-28 Thread Jim foo.bar
)... hehe :) Jim On 28/02/13 15:21, Marko Topolnik wrote: Nondeterministic behavior - suspect race conditions. Maybe compilation was happening concurrently on several threads and the resulting bytecode got mangled. On Thursday, February 28, 2013 4:17:52 PM UTC+1, Jim foo.bar wrote: On 28/02

Re: what on earth is happening?

2013-02-28 Thread Jim foo.bar
On 28/02/13 15:36, Softaddicts wrote: Hi, can you post the JVM used, maybe a snippet of the code around line 68, the dependencies tree (lein deps :tree) and your project.clj ? With these we can probably find the root cause of this. Luc P. Hi Luc, thanks for your interest but I think I've

wouldn't it make sense for identity to take variadic args?

2013-02-27 Thread Jim foo.bar
I often find myself asking for identity of something but identity takes a single argument! Why not have it take as many as one likes but only return the identity of the first? I find that very handy...do people agree? (defn identity Returns its argument or its first argument when there are

Re: wouldn't it make sense for identity to take variadic args?

2013-02-27 Thread Jim foo.bar
On 27/02/13 12:12, Chris Ford wrote: Can you give an example use case? sure... sometimes I do something this: (map (if even? (fn [num _] (identity spans)) str) some-seq1 some-seq2) but I'd like to write this instead: (map (if even? identity str) some-seq1 some-seq2) Personally, I would

Re: wouldn't it make sense for identity to take variadic args?

2013-02-27 Thread Jim foo.bar
thinking about it a bit more, it would certainly make sense to return a seq with all the identities. Then I can just ask for the first...hmm interesting :) Jim On 27/02/13 12:20, Jim foo.bar wrote: On 27/02/13 12:12, Chris Ford wrote: Can you give an example use case? sure... sometimes I

Re: wouldn't it make sense for identity to take variadic args?

2013-02-27 Thread Jim foo.bar
On 27/02/13 12:35, Marko Topolnik wrote: it is a function that transforms its argument into itself. It is useful in the context of higher-order functions where it plays the role of a no-op that is exactly what I'm trying to do..a no-op based on some condition...Though, I can see why it

Re: wouldn't it make sense for identity to take variadic args?

2013-02-27 Thread Jim foo.bar
On 27/02/13 12:52, Marko Topolnik wrote: In this line: (map (if even? (fn [num _] (identity spans)) str) some-seq1 some-seq2) you appear to involve /identity/ in a way that makes no sense since (identity spans) is just spans. You also don't involve the /num/ argument at all; but maybe you

Re: wouldn't it make sense for identity to take variadic args?

2013-02-27 Thread Jim foo.bar
On 27/02/13 13:10, Marko Topolnik wrote: A side note: since /spans?/ is a constant within the /map/ transform, it would pay to decide up-front which function to use: nice catch! Jim ps: thanks a lot for your comments :) -- -- You received this message because you are subscribed to the

assertion-forms inside macros without using eval?

2013-02-21 Thread Jim foo.bar
Hi all, I''d like to have a macro like the following but preferably without the 'eval' inside the assertion form: (defmacro defcomponent [name co] (assert (component? (eval co)) Not a valid IComponent) `(def ~name ~co)) If I don't use eval, everything works as long as I pass a var

Re: assertion-forms inside macros without using eval?

2013-02-21 Thread Jim foo.bar
On 21/02/13 14:07, Jim foo.bar wrote: Hi all, I''d like to have a macro like the following but preferably without the 'eval' inside the assertion form: (defmacro defcomponent [name co] (assert (component? (eval co)) Not a valid IComponent) `(def ~name ~co)) If I don't use eval, everything

Re: assertion-forms inside macros without using eval?

2013-02-21 Thread Jim foo.bar
ugly doesn't it? Jim On 21/02/13 14:11, AtKaaZ wrote: or you could place the assert inside the backquote On Thu, Feb 21, 2013 at 3:10 PM, Jim foo.bar jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: On 21/02/13 14:07, Jim foo.bar wrote: Hi all, I''d like to have

Re: assertion-forms inside macros without using eval?

2013-02-21 Thread Jim foo.bar
) = (defcomponent a 1) #'runtime.q/a = (defcomponent a (+ 1 3)) #'runtime.q/a On Thu, Feb 21, 2013 at 3:11 PM, AtKaaZ atk...@gmail.com mailto:atk...@gmail.com wrote: or you could place the assert inside the backquote On Thu, Feb 21, 2013 at 3:10 PM, Jim foo.bar jimpil1...@gmail.com

Re: assertion-forms inside macros without using eval?

2013-02-21 Thread Jim foo.bar
/a = (a) 2 nil = (defmacro a [] `(do (println 1) (println 2) ) ) #'runtime.q/a = (a) 1 2 nil On Thu, Feb 21, 2013 at 3:14 PM, Jim foo.bar jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: I tried this and it works, but I need 2 backticks and I'm

Re: assertion-forms inside macros without using eval?

2013-02-21 Thread Jim foo.bar
at the end! strange stuffI may end up using 'eval' as I used to... Jim On 21/02/13 14:20, Jim foo.bar wrote: I settled for: (defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c# Not a valid IComponent)) (def ~name c#))) Jim On 21/02/13 14:18, AtKaaZ wrote: that one doesn't

Re: assertion-forms inside macros without using eval?

2013-02-21 Thread Jim foo.bar
Hi Meikel, This seems to work but returns nil and so you can't see that a new var has been defined! cluja.core= (defcomponent maxent-person maxent) nil cluja.core= maxent-person ;;was it defined? #NameFinderME opennlp.tools.namefind.NameFinderME@2019666a ;;yes it was! Jim On 21/02/13

Re: assertion-forms inside macros without using eval?

2013-02-21 Thread Jim foo.bar
Yes you're right, this does the trick...However now I've ended up unquoting 'name' 3 times! I'm pretty sure this not a good practice in general, is it? On the other hand I cannot use 'gensym' cos I want the name intact or later access...hmmm...I never expected this would be so confusing! Jim

Re: assertion-forms inside macros without using eval?

2013-02-21 Thread Jim foo.bar
Moreover, now the exception thrown when the validation fails is not very informative! IllegalStateException Invalid reference state clojure.lang.ARef.validate (ARef.java:33) assert let's you speciy the message you want that is why I preferred it... Jim On 21/02/13 14:56, Jim foo.bar

Re: assertion-forms inside macros without using eval?

2013-02-21 Thread Jim foo.bar
something before the assert to log if that point was ever reached. On Thu, Feb 21, 2013 at 3:29 PM, Jim foo.bar jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: oops major typo! the correct is: (defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c

Re: Create map from vector of keywords and other items

2013-02-20 Thread Jim foo.bar
'keycollect-partition' looks sensible and idiomatic to me... perhaps juxt can come into play here? Of course, both versions will only work with keys as keywords and non-keys as non-keywords. If you use anything else other than a keyword for a key or a keyword for an item, both will break...

:use an entire namespace full of protocols or stick with :require?

2013-02-14 Thread Jim foo.bar
I know that using a bare :use in the ns macro is generally frowned upon as it provides no hints about what is actually being used... However, I 've got 2 namespaces 'abstractions.clj' and 'concretions.clj'...concretions.clj will eventually use all the protocols defined in

constructing matrix-like structures with list-comprehension

2013-02-05 Thread Jim foo.bar
Hi all, I 'm a bit confused with this - I'm trying to think but I can't!!! Probably cos I've not had any food yet! Up till now I thought I could construct matrices with 'for'...So (for [i (range 3)] i) gives us a 1d structure (a list)... (for [i (range 3) j (range 4)] [i j]) gives us a 2d

Re: constructing matrix-like structures with list-comprehension

2013-02-05 Thread Jim foo.bar
I do hate writing code on thunderbird!!! '( counts 1)' should obviously be '( ~counts 1)'... Jim On 05/02/13 15:03, Jim foo.bar wrote: Hi all, I 'm a bit confused with this - I'm trying to think but I can't!!! Probably cos I've not had any food yet! Up till now I thought I could

Re: Puzzle with lazy sequences

2013-02-05 Thread Jim foo.bar
Couldn't the compiler infer that the 2 expressions are identical with identical arguments and perform the reduce only once? Basically what the programmer would do in a let statement? Would that be too expensive? Jim On 05/02/13 15:21, Herwig Hochleitner wrote: Clojure has a feature called

parallel dynamic-programing?

2013-01-29 Thread Jim foo.bar
Hi all, I realise this may be a slightly naive question and my implementation is certainly naive, however I'd like to see if anyone else has attempted anything similar. Of course, by 'dynamic-programming' I 'm not referring to dyncamic scope but to the statistical technique which divides

Re: pool-map - a more disciplined version of pmap on top of executors

2013-01-15 Thread Jim foo.bar
On 15/01/13 09:25, Marko Topolnik wrote: The order in which you are polling is not very relevant given the fact that /doall/ won't return until *all* futures are realized. It's just an internal detail. I finally fully grasped what you were saying...So yes you're right - as long as I'm

Re: pool-map - a more disciplined version of pmap on top of executors

2013-01-15 Thread Jim foo.bar
On 15/01/13 12:57, Marko Topolnik wrote: The tasks are waiting in the queue, they are not being executed at all. And the time they spend waiting cannot theoretically be a function of the time they will take to execute, once they get their chance. a so Java Futures are not the same as

Re: pool-map - a more disciplined version of pmap on top of executors

2013-01-15 Thread Jim foo.bar
On 15/01/13 13:49, Marko Topolnik wrote: It's not about futures, but about the way the ExecutorService is configured. Clojure's /future-call/ apparently uses the /agent send-off pool/, which is an unbounded thread pool executor. So you can use the same thing with

replacing specific symbols in arbitrary expressions

2013-01-14 Thread Jim foo.bar
Hi everyone, I hope you're all well! I recently faced a problem when i needed to receive some piece of code and replace all the invalid symbols in it with the proper (existent) ones. Imagine for example you have the following map from made-up characters to real characters: (def

Re: macro: retrieving metadata for an object bound to a symbol passed as argument

2013-01-14 Thread Jim foo.bar
On 14/01/13 14:27, wujek.sru...@gmail.com wrote: (defmacro with-obj [name] (let [obj-meta (meta name)] (if (or (nil? obj-meta)) ; (not (::my-obj obj-meta))) (throw (IllegalArgumentException. (str name seems not be our object) `(println nice)) Try this: (defmacro with-obj

Re: macro: retrieving metadata for an object bound to a symbol passed as argument

2013-01-14 Thread Jim foo.bar
Of course you should know that built-in java types do not support meta-data...You need to implement IObj in order to provide meta-data support to your own types...otherwise use records... Jim On 14/01/13 14:32, Jim foo.bar wrote: On 14/01/13 14:27, wujek.sru...@gmail.com wrote: (defmacro

Re: macro: retrieving metadata for an object bound to a symbol passed as argument

2013-01-14 Thread Jim foo.bar
Why does this have to be a macro? Why can't it be a first-class function instead? (defn with-obj [ob] (if-let [obj-meta (meta ob)] name (throw (IllegalArgumentException. (str ob seems not be our object) Jim On 14/01/13 14:34, Jim foo.bar wrote: Of course you should know that built

Re: macro: retrieving metadata for an object bound to a symbol passed as argument

2013-01-14 Thread Jim foo.bar
work. wujek On Mon, Jan 14, 2013 at 3:41 PM, Jim foo.bar jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: Why does this have to be a macro? Why can't it be a first-class function instead? (defn with-obj [ob] (if-let [obj-meta (meta ob)] name

Re: macro: retrieving metadata for an object bound to a symbol passed as argument

2013-01-14 Thread Jim foo.bar
On Mon, Jan 14, 2013 at 4:25 PM, Jim foo.bar jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: I am not sure I follow...Do you by any chance want the macro-expansion to lead you directly to one of your two options (printing or exception)? In this case you can do

Re: Idiom for transforming a map

2013-01-10 Thread Jim foo.bar
On 10/01/13 12:57, Jonathon McKitrick wrote: Excellent stuff, guys. Thanks for the help. I just got 'Joy of Clojure' and 'Clojure Programming' in the mail yesterday so hopefully I'll be up to speed quickly. no worries...happy reading! :-) Jim -- You received this message because you are

String wrapper that supports meta-data...

2013-01-09 Thread Jim foo.bar
Hi all, I often find myself wanting to attach meta-data to built-in Java classes and particularly to the 'String' class. In a text-mining and NLP context, it is very useful for example to have a dictionary of strings where each string 'knows' its synonyms...Of course one can get around that

Re: clojure.string/capitalize API

2012-12-12 Thread Jim foo.bar
There is an easy solution to your problem...Just hange the fn definition slightly. For example I am regularly using this: (defn un-capitalize [^String s] (let [Cfirst (subs s 0 1) Crest (subs s 1) ] (str (.toLowerCase Cfirst) Crest))) It is pretty obvious what you need to do to convert the

Re: Need ideas for carving project into namespaces

2012-12-12 Thread Jim foo.bar
On 12/12/12 00:16, Mark Engelberg wrote: I would much prefer to have some sort of core function that serves as a polymorphic constructor. This way users don't need to require the concrete implementations individually. I faced the same sort of issue a couple of months ago. Just like you, I

Re: Meaning of =

2012-12-11 Thread Jim foo.bar
I disagree... One of the nice things about clojrue is that, at tis hear, lies the 'equiv' operator which is basically the 'egal' fn as defined by Baker [1993] [Equal rights for functional objects or the mroe things change the more they stay the same]. When using '=' with data-structures you

Re: Meaning of =

2012-12-11 Thread Jim foo.bar
*, comparison. hope that helps... Jim On 11/12/12 13:17, Jim foo.bar wrote: I disagree... One of the nice things about clojrue is that, at tis hear, lies the 'equiv' operator which is basically the 'egal' fn as defined by Baker [1993] [Equal rights for functional objects or the mroe things change

Re: Meaning of =

2012-12-11 Thread Jim foo.bar
, Jim foo.bar wrote: From the docs: Equality. Returns true if x equals y, false if not. Same as Java x.equals(y) except it also works for nil, and compares numbers and collections in a type-independent manner. Clojure's immutable data structures define equals() (and thus =) as a value

Re: Meaning of =

2012-12-11 Thread Jim foo.bar
Apologies...I did not realise this had already been answered... oops! :-) On 11/12/12 13:32, Jim foo.bar wrote: If you're looking for some truly unintuitive equality behavior check this out: user= (def pred (Boolean. false)) ;;not a primitive but an object #'user/pred user= (= pred false

Re: seq? vs sequential? vs coll?

2012-11-26 Thread Jim foo.bar
My understanding is that everything (all data-structures) is coll? (obviously not strings) lists and vectors are sequential? (and coll?) sets are only coll? maps are map? (and coll?) All seq? are sequential? Yes and also coll? All sequential? are coll? Well yeah but not only...all

Re: seq? vs sequential? vs coll?

2012-11-26 Thread Jim foo.bar
On 26/11/12 14:19, Philip Potter wrote: Has anyone compiled a little table of what things satisfy which predicates? I'm not 100% sure, but I think Clojure Programming has a table like this...I can confirm as soon as I get back home... Jim -- You received this message because you are

Re: seq? vs sequential? vs coll?

2012-11-26 Thread Jim foo.bar
Ooops!!! No, Mark asked this in his first post... sorry for the confusion! Jim On 26/11/12 14:31, Philip Potter wrote: On 26 November 2012 14:27, Jim foo.bar jimpil1...@gmail.com wrote: On 26/11/12 14:19, Philip Potter wrote: Has anyone compiled a little table of what things satisfy which

core.logic and laziness...

2012-11-22 Thread Jim foo.bar
Hi all, this question may sound stupid but I've got to ask it given a fn like the one below, how would one make it lazy (assuming that it can be done)? also if it can, I'd like to make it fully-lazy (instead of chunked-lazy)...any ideas? I remember something about restoring '1 at a time'

Re: core.logic and laziness...

2012-11-22 Thread Jim foo.bar
On 22/11/12 16:25, David Nolen wrote: core.logic has lazy-run. ooo thanks a lot!!! 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 Note that posts from new members are moderated -

deserialising records from Swing...

2012-11-21 Thread Jim foo.bar
Hi all, I discovered yesterday that records cannot be deserialised from the EDT using the normal way (prn/read-string)... NoClassDefFound Exception trying the same thing from a bare repl (no swing), works just fine!!! Googling deserialisng clojure records pointed me to [1] where Stuart

Re: feeding leiningen a local JAR file

2012-11-21 Thread Jim foo.bar
On 21/11/12 11:47, Dick Davies wrote: Also, is it possible to 'override' a given dependency to favour a local JAR over the 'official' maven one? just install the jar into your local maven repo (~/.m2/) (with identifiable name) and then pull it from whatever project you want. I think

Re: Edit/write Clojure code on Android

2012-11-20 Thread Jim foo.bar
The problem with that is that it will only work if there are no external dependencies! As long as your code depends only on clojure 1.4 it's all good...this is very unlikely though for a descent sized project... Jim On 20/11/12 16:14, Nenad Seke wrote: You can write your clojure code in some

defpromise?

2012-11-20 Thread Jim foo.bar
I was just wondering...we have a 'defsomething' macro for almost everything... How come there is no 'defpromise'? It is very easy to write one and since we always initialize promises like this: (def x (promise)), I don't see any reason why not... (defmacro defpromise [name] `(def ~name

Re: question concerning macros by a newbie

2012-11-13 Thread Jim foo.bar
You can't convert to keyword simply by (str : (str (first components))...you need the (keyword (first components))...also why is your argument (symbol obj)? I'd prefer obj# or (gensym obj)... Jim On 13/11/12 10:06, Johannes wrote: Hi, I define a record (defrecord point [x y]) and the

Re: Question about sets

2012-11-12 Thread Jim foo.bar
Yes, this has been discussed extensively in the pastI think the convention is to use the ctor functions if you're passing data dynamically, otherwise if dealing with constants the literals should be just fine...In the case just replace the set literal with (hash-set ...) or (set ...).

Re: Question about sets

2012-11-12 Thread Jim foo.bar
sorry 'set' will convert from a coll to a set...use 'hash-set' , 'sorted-set' etc etc... Jim On 12/11/12 13:22, Jim foo.bar wrote: Yes, this has been discussed extensively in the pastI think the convention is to use the ctor functions if you're passing data dynamically, otherwise

Re: [Ann] Kibit 0.0.6

2012-11-12 Thread Jim foo.bar
Thank you Bronza...this is exactly what I meant! when using reducers 'into' is the norm isn't it? Couldn't kibit parse the ns declaration before it starts suggesting things? It seems that at least for namespaces that use core.logic or reducers kibit's suggestions will break your code! For

Re: transient/persistent! not worth for less than 7-8 operations

2012-11-09 Thread Jim foo.bar
exactly the point I was trying to make! However, other peoples' experiment seem not to agree with that! Jim On 09/11/12 15:09, Cedric Greevey wrote: In the real world, it's more complicated than that, and N could end up not only depending on which transient operations and on vector vs. map

Re: Slow image convolution

2012-11-09 Thread Jim foo.bar
I thought 'definline' addresses exactly that...cases where one might want to pull out small pieces of first class functionality without sacrificing performance and without macros (which are not first-class)...am I mistaken? Jim ps: the only similarly big function that I've ever written

Re: does clojure.java.jdbc/with-connection db keep the connection alive?

2012-11-09 Thread Jim foo.bar
the general idiom with-some-resource means that resources will be cleared after leaving its scope. JUst like with 'with-open' which has a try/finally in order to .close() any closable resource upon exit. I've not used clojure.java.jdbc but I suspect the same rationale applies for

Re: what is the modern equivalent of clojure.contrib.java-utils/file?

2012-10-25 Thread Jim foo.bar
are you aot compiling? If yes delete all the calss files and re-compile...also there is no reason to require it unless you alias it to something... a common one would be (:require [clojure.java.io :as io])...personally, for clojure.java.io, I just use the fully qualified name most of the

Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Jim foo.bar
On 25/10/12 16:59, Brian Craft wrote: I have a fairly common scenario where I have a set of operations that need to work on two types of data (not data types in the clojure sense) that have different internal structure (i.e. maps with different keys). I could write a generic function that

Re: Could not locate clojure/data/json__init.class or clojure/data/json.clj on classpath

2012-10-25 Thread Jim foo.bar
On 25/10/12 18:01, larry google groups wrote: (:require clojure.string clojure.java.io who-is-logged-in.memory_display [clojure.data.json :as json]) I don't like this line... try: (:require [clojure.string :as st] [clojure.java.io :as io]

Re: Troubles working with nl.bitwalker.useragentutils

2012-10-24 Thread Jim foo.bar
On 24/10/12 14:41, AtKaaZ wrote: The error doesn't help you solve the problem... which is: don't pass a seq to :import You can easily pass seqs to :import...this works fine for me (importing 3 classes from the same package): (:import [encog_java.customGA CustomNeuralGeneticAlgorithm

Re: Troubles working with nl.bitwalker.useragentutils

2012-10-24 Thread Jim foo.bar
aaa sorry I can see from a previous post that you already tried that! this is strange! Jim On 24/10/12 14:48, Jim foo.bar wrote: On 24/10/12 14:41, AtKaaZ wrote: The error doesn't help you solve the problem... which is: don't pass a seq to :import You can easily pass seqs to :import

Re: Calling name on a keyword gives nil??

2012-10-22 Thread Jim foo.bar
A couple of issues: 1) 'name' is a fn in core so it's almost never a good idea to shadow it like this... 2) also it is not a good idea for a fn to start with 'def' unless it actually defines a top-level form inside it like in macros 3)If you need all your keys in capital I think it would be

Re: Calling name on a keyword gives nil??

2012-10-22 Thread Jim foo.bar
a pre-condition attached to your fn would be a nice and clean way to check for upper/lower case without 'polluting' the fn itself with if statements...just a thought ... :-) Jim On 22/10/12 16:16, Jim foo.bar wrote: A couple of issues: 1) 'name' is a fn in core so it's almost never a good

Re: Meta data access

2012-10-22 Thread Jim foo.bar
If I've understood correctly all you need is (meta form)... Jim On 22/10/12 15:30, Mamun wrote: Hi All, I've a application with following structure. Now I would like to access meta data of f1 and f2 within process function. (defn ^{:test true} f1 [] (println call f1 fn)) (defn ^{:test

Re: Meta data access

2012-10-22 Thread Jim foo.bar
well not quite! you need (- form var meta :test) or the same thing written differently (:test (meta (var form))) Hope that helps, Jim ps: basically the meta-data sit with the var not the function On 22/10/12 16:33, Jim

Re: Calling name on a keyword gives nil??

2012-10-22 Thread Jim foo.bar
On 22/10/12 16:45, JvJ wrote: The reason it starts with def (and ends in -fn) is because it is a function used by a macro, which has a global effect. well, if you mean that the macro (which you've not shown) is the one that creates the top-level form, then macro's name should be the one

Re: class name clashes on importing classes of same name from different Java packages into the same clojure namespace...

2012-10-18 Thread Jim foo.bar
On 18/10/12 16:27, Sunil S Nandihalli wrote: Hi Everybody, class name clashes on importing same named classes from different java-packages into same clojure namespace. Is this expected. I think that it should be possible to import them and can be used by completely qualifying the class name

Re: Clojure turns 5

2012-10-17 Thread Jim foo.bar
WOW! Has it been 5 years already? Thanks a lot Rich for this beautiful gift to all of us...You rock and Clojure rules!!! Jim On 17/10/12 02:54, Rich Hickey wrote: I released Clojure 5 years ago today. It's been a terrific ride so far. Thanks to everyone who contributes to making Clojure,

Re: Clojure turns 5

2012-10-17 Thread Jim foo.bar
On 17/10/12 15:41, Timothy Baldridge wrote: So thank you Rich...thank you for ruining all other languages for me. +1 very well put... 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: Evaluating an anonymous function with closure

2012-10-16 Thread Jim foo.bar
On 16/10/12 03:50, Michael Gardner wrote: On Oct 15, 2012, at 7:45 PM, Andy Fingerhut wrote: For the case of arithmetic on compile-time constants, I believe that many C, Java, etc. compilers already perform the arithmetic at compile time. Known as constant folding, yes. so you're saying

Re: Evaluating an anonymous function with closure

2012-10-16 Thread Jim foo.bar
On 16/10/12 11:49, Tassilo Horn wrote: One example that does things like constant-folding like macrology is the unit conversion macro in Let Over Lambda that compiles to constants if both value and unit are given literally (recursively). unit conversion! this is exactly what i had in mind!!!

Re: Evaluating an anonymous function with closure

2012-10-16 Thread Jim foo.bar
On 16/10/12 13:20, Michael Gardner wrote: On Oct 16, 2012, at 5:16 AM, Jim foo.bar wrote: so you're saying that if I write a for-loop in Java that populates an array with constants from 1-1 and then a 2nd loop to add them up, it would happen at compile-time and i would get the same

Re: Simple way to get image from url

2012-10-16 Thread Jim foo.bar
On 16/10/12 13:25, Zhitong He wrote: another way to solve this, from http://users.utu.fi/machra/posts/2011-08-24-2-reddit-clojure.html (ns myapp.app (:require [clojure.java.io :as io])) (defn copy [uri file] (with-open [in (io/input-stream uri) out

pmap performance degradation after 30-40 min of work?

2012-10-12 Thread Jim foo.bar
Hi all, I finally found an ideal use-case for pmap, however something very strange seems to be happening after roughly 30 minutes of execution! Ok so here is the scenario: I've got 383 raw scienific papers (.txt) in directory that i'm grouping using 'file-seq' and so I want to pmap a fn on

  1   2   >