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 prob

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 struc

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 h

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 lo

: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 abstractions.clj...at

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

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 in...H

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

Re: assertion-forms inside macros without using eval?

2013-02-21 Thread Jim foo.bar
name ~co)) it looks 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 <mailto:jimpil1...@gmail.com>> wrote: On 21/02/13 14:07, Jim foo.bar wrote: Hi all,

Re: assertion-forms inside macros without using eval?

2013-02-21 Thread Jim foo.bar
alid IComponent (runtime.q/component? "a") runtime.q/eval6572 (NO_SOURCE_FILE:1) => (defcomponent a 1) #'runtime.q/a => (defcomponent a (+ 1 3)) #'runtime.q/a On Thu, Feb 21, 2013 at 3:11 PM, AtKaaZ <mailto:atk...@gmail.com>> wrote: or you could place

Re: assertion-forms inside macros without using eval?

2013-02-21 Thread Jim foo.bar
hough, => (defmacro a [] `(println 1) `(println 2) ) #'runtime.q/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 <mailto:jimpil1...@gmail.com>&

Re: assertion-forms inside macros without using eval?

2013-02-21 Thread Jim foo.bar
unbound 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/

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? # ;;yes it was! Jim On 21/02/13 14:42, Meikel Brandmeyer (kotarak) wrote: (defmacro defcompo

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 fo

Re: assertion-forms inside macros without using eval?

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

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 mor

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 be

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 would

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 me

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 Google

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" java.lang.VerifyE

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 compi

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

Re: what on earth is happening?

2013-02-28 Thread Jim foo.bar
threw)... 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:

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 cr

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

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 feedbac

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" <mailto:jimpil1...@gmail.com>> wrote: how come your project depends on the problematic version 1.5.0? 1.5.0 is problemati

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

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. http://illegalargument.com/illegal-argument-epi

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 co

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

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... http://w

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 bec

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

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

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

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

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 keywords...different

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 moderat

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

clojure-opennlp

2012-02-11 Thread Jim foo.bar
HI everyone, I was just wondering whether anyone has used the clojure-opennlp wrapper for multi-word named entity recognition (NER)? I am using it to train a drug finder from my private corpus and even though i get correct behavior when using the command line tool of apache openNLP when trying to

Re: Question: Looking at Noir code - hey, are those singletons?

2012-09-12 Thread Jim foo.bar
defonce simply means "do not bind the var if it already has a root value"... I think it only applies when reloading your namespace...to be honest, I'm not sure why Chris has coded it like that (creating an atom is not really expensive), but i find it hard to believe that you can' t have 2 Noir

Re: Question: Looking at Noir code - hey, are those singletons?

2012-09-12 Thread Jim foo.bar
then mean they share the same routes, among other things. Or am I missing something? On Wednesday, September 12, 2012 4:49:34 PM UTC+2, Jim foo.bar wrote: defonce simply means "do not bind the var if it already has a root value"... I think it only applies when reloading your

nested parallel execution...is that even possible?

2012-09-20 Thread Jim foo.bar
Hi all, this may sounds like a silly question but I have to ask it! Let's assume there are 2 nested opportunities for parallel execution of some code...so for example I've got a genetic algorithm (scoring the organisms can be run in parallel) and some reducers code that does the actual minima

Re: nested parallel execution...is that even possible?

2012-09-21 Thread Jim foo.bar
Hi Herwig, Your suggestion doesn't really apply to my problem because the GA and the minimax are completely separate...The GA runs in a fixed-size thread pool which I'm in control of so i can easily set how many threads I want the GA to spawn, so that is solved (at least theoretically!)...Now,

Re: nested parallel execution...is that even possible?

2012-09-21 Thread Jim foo.bar
On 21/09/12 16:54, Herwig Hochleitner wrote: So if you're asking how to control the number of threads used for folding: That's a constructor argument of ForkJoinPool, which defaults to the number of available processors. It's not currently exposed in the reducers API, but you could hack it with

Re: nested parallel execution...is that even possible?

2012-09-21 Thread Jim foo.bar
Ok I can see there is a 'var-set' fn that seems to behave exactly as i need...this is good stuff! I can now do: (var-set clojure.core.reducers/pool (ForkJoinPool. 6)) Jim On 21/09/12 17:14, Jim foo.bar wrote: On 21/09/12 16:54, Herwig Hochleitner wrote: So if you're asking

Re: nested parallel execution...is that even possible?

2012-09-21 Thread Jim foo.bar
On 21/09/12 17:42, Herwig Hochleitner wrote: Sorry for the nitpick, but that would just have been (.setParallelism pool 6), were it possible. aaa yes of course... my brain has turned into mash! (alter-var-root #'clojure.core.reducers/pool (constantly (ForkJoinPool. 6))) awesome! :-) :-) :-

Re: Clojure : a good start for non-programmers?

2012-09-26 Thread Jim foo.bar
On 26/09/12 14:04, Lee Spector wrote: Having taught Clojure as a first language so, reading the above statement, can I infer that Hampshire college offers a Clojure course to 1st year undergrads? I'm trying to promote the same concept for Manchester University (UK) but all the 'important' pe

Re: Clojure : a good start for non-programmers?

2012-09-26 Thread Jim foo.bar
ecome problem-solvers first and programmers after...Java is too grounded in most schools! Jim On 26/09/12 14:29, Jim foo.bar wrote: On 26/09/12 14:04, Lee Spector wrote: Having taught Clojure as a first language so, reading the above statement, can I infer that Hampshire college offers a Cl

Re: Clojurejs: a lightweight clojure to javascript compiler

2012-10-08 Thread Jim foo.bar
On 08/10/12 07:18, Hoàng Minh Thắng wrote: Clojurejs started by [kriyative](https://github.com/kriyative) is an amazing project that compile clojure to javascript. Now I'm confused! Isn't clojureScript exactly that? Jim -- You received this message because you are subscribed to the Google Gro

Re: Clojurejs: a lightweight clojure to javascript compiler

2012-10-08 Thread Jim foo.bar
On 08/10/12 14:47, Mark Rathwell wrote: ClojureScript is a Clojure implementation that targets Javascript (meaning that Clojure core, et al, is also necessarily converted to Javascript in the build process and a part of what you ship). I'm assuming this project is a straight translator from Cloj

Re: bug in clojure.lang.ASeq

2012-10-10 Thread Jim foo.bar
I can confirm I am seeing the behavior you describe under Clojure 1.4... user=> (serialize! [1 2 3 4 5] "TEST") nil user=> (.hashCode (deserialize! "TEST.ser")) 29615266 user=> (serialize! ["a" "b" "c" "d"] "TEST2") nil user=> (.hashCode (deserialize! "TEST2.ser")) 3910595 user=> (serialize! '("a

Re: bug in clojure.lang.ASeq

2012-10-10 Thread Jim foo.bar
Lazy-seqs also seem to behave: user=> (serialize! (map inc [1 2 3 4]) "TEST4") nil user=> (.hashCode (deserialize! "TEST4.ser")) 986115 Jim On 10/10/12 15:14, Jim foo.bar wrote: I can confirm I am seeing the behavior you describe under Clojure 1.4... user=>

Re: bug in clojure.lang.ASeq

2012-10-10 Thread Jim foo.bar
Hmmm...It turns out this is not exclusive to Clojure... user=> (java.util.Collections/unmodifiableList '(1 2 3 4 5)) # user=> (def l *1) #'user/l user=> l # user=> (serialize! l "TEST5") nil user=> (.hashCode (deserialize! "TEST5.ser")) 0 Jim

Re: bug in clojure.lang.ASeq

2012-10-10 Thread Jim foo.bar
r, result in an UnsupportedOperationException." Elements are NOT copied to the unmodified list. So yes, it seems that Clojure lists are the culprit after all...I would use vectors until this is sorted. :-) Jim On 10/10/12 15:26, Jim foo.bar wrote: Hmmm...It turns out this is not exclusive

Re: ANN: codeq

2012-10-10 Thread Jim foo.bar
On 10/10/12 15:27, Rich Hickey wrote: I released a little app today that imports Git repos into Datomic. My hope is that it can be used as the underpinnings of some interesting Clojure tooling. More info here: http://blog.datomic.com/2012/10/codeq.html Rich Good stuff! :-) Jim -- You rece

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 e

Re: pmap performance degradation after 30-40 min of work?

2012-10-12 Thread Jim foo.bar
p slurping? Jim On 12/10/12 15:28, Adam wrote: Have you tried running jconsole to monitor the memory usage? It sounds like maybe you're running out of heap space and you're mainly seeing the garbage collector doing it's thing vs your actual program. ~Adam~ On F

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

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

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 (io/out

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

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

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 fas

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

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 ^{:tes

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,

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 start

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 CustomG

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

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 times

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 ope

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] [clojure.data.json

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 b

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

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

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 ...). hop

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 pass

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 exampl

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 fo

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

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 Leininge

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

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

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 persisten

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 subs

  1   2   >