Re: vs. Python

2009-08-30 Thread Jonathan
There are two styles of expression in higher level languages (including Python and Clojure). Functional programming (map, filter, reduce, fold) on one side and set (and list) comprehensions on the other. This is somewhat a matter of culture, not capability. Although slightly less convenient, funct

Re: :use feature requests

2009-03-05 Thread Jonathan Tran
going to make breaking changes at all, let's do them right, and not introduce yet more cruft with another function. Jonathan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To p

Clojure from JRuby (updated)

2009-04-08 Thread Jonathan Tran
I recently had a Rails project I was working on in JRuby. I also had a separate yet related project in Clojure. I thought it would be great to hook them together to provide a web interface for the Clojure project. I did some searching and found this code to evaluate Clojure code from JRuby: ht

Re: A website written using Clojure.

2009-06-26 Thread Jonathan Smith
On Jun 25, 3:59 pm, Berlin Brown wrote: > On Jun 25, 3:52 pm, Mike Hinchey wrote: > > > > > Instead of eval in the doseq, you could use a macro with a do block, > > something like: > > user> (defmacro deftags [tags] > >         `(do ~@(map (fn [tag] > >                       `(defn ~(symbol (str

Re: Is this unquote dangerous?

2009-07-07 Thread Jonathan Smith
On Jul 6, 6:00 pm, Chouser wrote: > On Mon, Jul 6, 2009 at 4:18 PM, Meikel Brandmeyer wrote: > > Hi, > > > Am 06.07.2009 um 22:00 schrieb Chouser: > > >> Or if you really do need a list: > > >>  (for [x [1 2 3]] (cons 'some-symbol (list x))) > > > o.O > > > *cough*(list 'some-symbol x)*cough* ;

Re: Passing primitives from an inner loop to an outer loop efficiently

2009-07-07 Thread Jonathan Smith
On Jul 7, 5:10 pm, John Harrop wrote: > Problem: Passing primitives from an inner loop to an outer loop efficiently. > Here is what I've found. > > The fastest method of result batching, amazingly, is to pass out a list and: > > (let [foo (loop ... ) > x (double (first foo)) > r1 (rest foo) > y

Re: Passing primitives from an inner loop to an outer loop efficiently

2009-07-08 Thread Jonathan Smith
On Jul 8, 4:57 pm, Frantisek Sodomka wrote: > So far it seems that vectors win in Clojure: > > (timings 3e5 >   (let [v (vector 1 2 3) a (nth v 0) b (nth v 1) c (nth v 2)] (+ a b > c)) >   (let [lst (list 1 2 3) a (nth lst 0) b (nth lst 1) c (nth lst 2)] (+ > a b c))) > > => >   680.63 ms   83.6%

Re: Passing primitives from an inner loop to an outer loop efficiently

2009-07-08 Thread Jonathan Smith
Seperate so it can be easily ignored: Changed in core.clj: (defn nth "Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for s

Re: Compilation troubles...

2009-07-13 Thread Jonathan Smith
On Jul 13, 5:51 pm, Morgan Allen wrote: > > It's definitely not necessary to implement the bulk of your code in Java to > > get performance. On the other hand, getting performance out of Clojure can > > be tricky. > > Well, yeah, that's the thing- getting maximal performance out of > clojure se

Re: binding issue

2009-07-17 Thread Jonathan Smith
On Jul 14, 5:12 pm, Stuart Sierra wrote: > On Jul 14, 3:01 pm, bgray wrote: > > > Ok, so *if* this is intended behavior, what have people been doing to > > bind variables dependant on other bindings?  I can't be the first to > > run into this. > > Just nest multiple binding forms: > (binding [

Re: cells questions

2009-07-20 Thread Jonathan Smith
On Jul 20, 1:27 am, kyle smith wrote: > I'm trying to use Stuart Sierra's implementation of cells.  I want to > sum the values of a large number of cells.  Rather than linearly > summing all the values, I would like to create a tree of cells whose > root contains the sum.  I added the function

Re: Newbie question: Writing a GUI with clojure

2009-08-05 Thread Jonathan Smith
I'll second the book recommendation, have the hacks sitting here on my desk and has been very useful so far. I've found that the easiest way for me to do UIs has been to write helper functions that make the components and stitch them together then return them inside hashmaps. Then I write a bunc

Re: Pure-functional N-body benchmark implementation

2009-08-10 Thread Jonathan Smith
1.) use something mutable 2.) unroll all the loops (mapping is a loop) 3.) try not to coerce between seq/vec/hash-map too much. in real world, stuff like the shootout is pretty useless, as generally you'd reach for a better algorithm rather than implementing the shackled, crippled, naive algorith

Re: How to write a macro that writes another macro?

2009-08-10 Thread Jonathan Smith
On Aug 10, 3:20 pm, Dragan Djuric wrote: > For example: > > (defmacro creator [param] >  `(defmacro created [p] `(the code...)) ;; note the nested quote... > how to resolve that? any examples? Although I wouldn't cite my own code as a necessarily *good* or easy to understand example, I'll pimp i

Re: Pure-functional N-body benchmark implementation

2009-08-10 Thread Jonathan Smith
On Aug 10, 11:08 pm, fft1976 wrote: > On Aug 10, 2:19 pm, Jonathan Smith wrote: > > > 1.) use something mutable > > 2.) unroll all the loops (mapping is a loop) > > 3.) try not to coerce between seq/vec/hash-map too much. > > Are you saying this w.r.t. my code or

Re: Pure-functional N-body benchmark implementation

2009-08-11 Thread Jonathan Smith
On Aug 11, 4:42 am, fft1976 wrote: > On Aug 10, 11:42 pm, Jonathan Smith > wrote: > > > The way your code is setup, you will spend a lot of time in funcall > > overhead just because you used a lot of functions instead of doing the > > calculation in bigger

Re: How to write a macro that writes another macro?

2009-08-11 Thread Jonathan Smith
so note that Clojure has the added wrinkle of namespace qualification. On Aug 11, 1:31 am, Jonathan Smith wrote: > On Aug 10, 3:20 pm, Dragan Djuric wrote: > > > For example: > > > (defmacro creator [param] > >  `(defmacro created [p] `(the code...)) ;; note the nested

Re: Pure-functional N-body benchmark implementation

2009-08-11 Thread Jonathan Smith
On Aug 11, 2:43 pm, fft1976 wrote: > On Aug 11, 4:50 am, Jonathan Smith wrote: > > > I don't think you have to put *everything* in the let, just your > > constants. (so days per year and solar mass, the bodies themselves). > > How will they "escape"

Re: Clojure Golf, episode 1

2009-08-14 Thread Jonathan Smith
On Aug 14, 3:43 pm, Fogus wrote: > Wanna play golf? ok... Not efficient or elegant, but certainly weird... (defn filter-collecting [p c & seqs] (let [fun #(if (apply p %1) (conj! %2 (apply c %1)) %2)] (loop [hs (map first seqs) ts (map rest seqs)

Re: Request for Discussion: user created reader macros

2009-08-14 Thread Jonathan Smith
On Aug 14, 11:46 am, Brian Hurt wrote: > On Thu, Aug 13, 2009 at 4:59 PM, Daniel Lyons wrote: > > > > > > > On Aug 13, 2009, at 2:30 PM, Brian Hurt wrote: > > > I'm just wondering what people's response would be to allow user-generated > > reader macros. I'm not sure, but I think the only chang

Re: XML vs. JSON

2009-08-25 Thread Jonathan Smith
On Aug 25, 11:28 am, B Smith-Mannschott wrote: > On Tue, Aug 25, 2009 at 16:24, Licenser wrote: > > > Hi everyone, > > I wonder what is the reason clojure uses XML standard wise and not > > JSON. In the past I've found that JSON is much cleaner to read, and > > much easier to represent data str

Re: Generation of random sequences

2009-08-25 Thread Jonathan Smith
Why not make a list of numbers from 0 to max, randomly shuffle it, and do a take on the resulting sequence until you have enough numbers. On Aug 25, 10:16 am, sebastien wrote: > What is the most efficient way to generate list of unique random > numbers? The function must look something like this

Re: Generation of random sequences

2009-08-25 Thread Jonathan Smith
umber-list [max dim] (take dim (shuffle-java (range 0 max user> (random-number-list 100 20) (38 70 73 57 10 81 32 99 92 19 77 39 27 24 47 17 86 8 58 76) On Aug 25, 1:30 pm, Jonathan Smith wrote: > Why not make a list of numbers from 0 to max, randomly shuffle it, > and do a ta

Re: Generation of random sequences

2009-08-25 Thread Jonathan Smith
I would have worried that if dim and max were close you'd get to the last number and keep calling #(rand-int) and never hit the last number. how does distinct work that it keeps that situation from occuring? On Aug 25, 12:26 pm, Christophe Grand wrote: > no, distinct uses a hash-set (nearly-con

Re: How about write clojure code like python mode?

2009-08-26 Thread Jonathan Smith
its not impossible, it just isn't terribly useful. On Aug 26, 6:04 pm, Laurent PETIT wrote: > "they didn't know it was impossible so they did it" :) > > 2009/8/26 Stuart Sierra > > > > > On Aug 24, 11:23 pm, wangzx wrote: > > > I think clojure may mix both the parenthese and python-like indent

Re: When to use macros

2009-08-30 Thread Jonathan Smith
On Aug 29, 3:48 pm, ronen wrote: > In a lot of cases its seems that macros are used even when a function > can do the same task, > Macros seems to be less readable than their functional counterparts & > more complex to write (to me at least). > > Its clear that there are special cases in which

Re: How to represents a Big text file using sequence?

2009-08-31 Thread Jonathan Smith
Look at clojure-contrib/duck_streams.clj (specifically the read-lines function) I think it should be sufficiently lazy to do the job that you are looking for. (although I don't have any 100mb txt files to test with handy right now...) On Aug 31, 10:44 am, wangzx wrote: > I just want to learn c

Re: How to represents a Big text file using sequence?

2009-08-31 Thread Jonathan Smith
Ooh, or maybe not. I just reread and line-seq and read-lines should implement pretty much the same thing. (In the demo code it isn't clear to me where you are using line-seq.) Are you holding on to the head of the sequence somewhere? On Aug 31, 12:52 pm, Jonathan Smith wrote: >

Re: from OO to Lisp style (a blog post)

2009-09-04 Thread Jonathan Smith
Hi Ralph, First off, nice post! We need more of these types of tutorials on GUI in clojure, they're very useful. On make-login-widget you can probably do a doto when you do this part: > (.addWidget layout (WLabel. "Login:") 0 0 ) > (.addWidget layout login-field 0 1 ) > (.addWidget layout (WLab

NPE calling clojure.lang.Compiler.load() from Java

2009-09-04 Thread Jonathan Tran
found to work is by simply moving the definition of LOADER just before the definition of SOURCE. Can someone please fix this in master? (I would have just fixed it myself, but I didn't know about the whole contributor agreement stuff...) Thanks, Jonathan --~--~-~--~~

Re: from OO to Lisp style (a blog post)

2009-09-07 Thread Jonathan Smith
Just out of curiosity, is there any technical reason that you decided to use signals instead of passing closures? (Modularity; Efficiency; more idiomatic to Java?) On Sep 6, 5:29 am, rb wrote: > On Sep 4, 8:30 pm, Jonathan Smith wrote: > > > Hi Ralph, > > > First off, ni

Re: Tight loop performance

2009-09-07 Thread Jonathan Smith
Are we sure that it is the aset-* operation that is causing a slowdown and not the fact that the aset-* operations are not being inlined, whereas the regular aset operation is? If so, the aset-* ops might be faster, and just in need of a small update! A lot of the time when something is slower t

Re: finding paths in clojure with Floyd-Warshall - ugly code

2009-09-14 Thread Jonathan Smith
Woah formatting! :-) This is just a formatting cleanup... Mostly I pressed ctrl+alt+q in emacs. I also removed some commas and made things more uniform in a couple places --- (defn create-graph [nodes distances] {:nodes nodes :distances distances}) (defn processed [k i j D P] (le

Re: loop-recur for string handling

2009-09-18 Thread Jonathan Smith
I find loop recur kind of hard to follow sometimes I was browsing through this pdf the other day: http://www.cs.umbc.edu/331/resources/papers/Evolution-of-Lisp.pdf And I found the tail recursive definition of common lisp/scheme style do. Thoroughly intrigued, I implemented it: (defmacro cl-

Re: OutOfMemoryError with loop/recur

2009-09-18 Thread Jonathan Smith
Hi! This is happening because you have integers saved to a global variable. (iterate inc 1) creates an infinite lazy seq. Def-fing it to a global says 'Hey, i might want this later!' to Clojure. This means that as you take numbers from integers; they get saved in memory rather than being garba

Re: OutOfMemoryError with loop/recur

2009-09-18 Thread Jonathan Smith
http://www.haskell.org/haskellwiki/Performance These are the performance tips I was referring to. (4. General techniques, laziness, space leaks.) On Sep 18, 5:03 pm, Jonathan Smith wrote: > Hi! > > This is happening because you have integers saved to a global > variable. > &

Re: OutOfMemoryError with loop/recur

2009-09-18 Thread Jonathan Smith
It would be kind of nice to have some sort of uniform identifier for laziness similar to ! for destructive and ? for predicate. On Sep 18, 5:10 pm, Raoul Duke wrote: > > Runs (in a nice constant memory) even though yours (which almost > > appears equivalent) will not! > > i am thinking ever more

Re: fastest aget and aset

2009-09-27 Thread Jonathan Smith
On Sep 27, 9:17 am, Timothy Pratley wrote: > As far as I can tell there is currently no way to hint 2d array access > fast > (def a (make-array Double/TYPE 100 100)) > (time (doseq [i (range 100), j (range 100)] (aget a (int i) (int j > "Elapsed time: 836.800335 msecs" > I can't find any comb

Re: fastest aget and aset

2009-09-27 Thread Jonathan Smith
ricky subject, and probably not worth worrying about for the minimal speed difference that it makes. Interesting though, -Jon. On Sep 28, 2:45 am, Jonathan Smith wrote: > On Sep 27, 9:17 am, Timothy Pratley wrote: > > > > > As far as I can tell there is currently no way to hint 2

Re: Timing, JIT, Heisen-code

2009-09-30 Thread Jonathan Smith
You need to use a bigger number than 1000 for these results to be meaningful. FWIW, I've run both on my Toshiba dual core laptop with ubuntu, and they return approximately the same values. (and there is some JIT trickery going on, as I got: user=> (myavgtime (+ 1 2 3) 1000 mytime1) (myavgtime (+

Re: Timing, JIT, Heisen-code

2009-10-01 Thread Jonathan Smith
On Sep 30, 1:18 pm, Matt Brown wrote: > Hi. > > Thanks all, for your comments. > > > You need to use a bigger number than 1000 for these results to be > > meaningful. > > Out of curiousity, why is this? > Does the JIT do something different after 1000 iterations? > Or is the concern simply tha

Re: immutable defs?

2009-10-02 Thread Jonathan Smith
I use a let at the top of the file to denote things that I want to have as captured and constant. ... you can do things like (let [x 1] (defn foo-that-uses-x [y] (function-here x y))) On Oct 2, 10:29 am, Mark wrote: > Is there a way to make a declaration in Clojure that cannot be rebound >

Re: api html page not working in firefox?

2009-10-11 Thread Jonathan Smith
its fine in firefox 3.0.14 on Ubuntu here. On Oct 11, 5:29 pm, Raoul Duke wrote: > it seems to get chopped off part way down the page for me, of late. > (it doesn't get chopped off in ie for me.) --~--~-~--~~~---~--~~ You received this message because you are subs

Re: Removing duplication of redis/with-server in every function?

2009-10-23 Thread Jonathan Smith
When figuring these things out it can sometimes help to look at the implementations of stuff like defn (in clojure.core). I'll leave it as an exercise to you, but you should note that you may want to name-space qualify the database (depending on what you are doing with it and where the database s

Re: Periodic tasks

2009-11-01 Thread Jonathan Smith
Maybe I'm confused, but can't you just do a regular java thread for this? (defn periodicly [fun time] "starts a thread that calls function every time ms" (let [thread (new Thread (fn [] (loop [] (fun) (Thread/sleep time) (recur] (.start thread) thread)) (periodicly #(println "foo

Re: why a defn- but not a def- ?

2009-11-17 Thread Jonathan Smith
On Nov 14, 1:50 pm, John Harrop wrote: > On Sat, Nov 14, 2009 at 8:55 AM, Albert Cardona wrote: > > On Fri, Nov 13, 2009 at 11:26 PM, Mike Hogye > > wrote: > > > Why is there an easy way to def a private function (defn-), but no > > > similarly easy way to def an arbitrary var as private? > > >

Re: swing: efficiently updating a listbox from a clojure list

2009-11-25 Thread Jonathan Smith
-- > is still slow, but dropping down to > > (def wlistdata (to-array (take 26 (words-with "..." > > (def update-wlist #(let [w (take 26 (words-with (current-word)))] >(. words setListData wlistdata))) > > leaves everything running smoothly. Is there a more e

Re: swing: efficiently updating a listbox from a clojure list

2009-11-25 Thread Jonathan Smith
On Nov 25, 2:09 pm, Martin DeMello wrote: > On Thu, Nov 26, 2009 at 12:31 AM, Jonathan Smith > > wrote: > > > I think a better way to do this is to not use a regex at all. > > Canonically I think this sort of thing is (would be?) implemented by > > constructing a

Re: Second Lisp to Learn

2009-12-20 Thread Jonathan Smith
Lisp Flavored Erlang is an extremely interesting lisp. in my opinion. You get Erlang, and you also get s-expressions and macros. Common Lisp and Scheme are the obvious choices, I suppose. Learning common lisp I would probably go towards clozure common lisp, or clisp. (SBCL is fine (great, even)

Re: Naming Functions...

2010-02-03 Thread Jonathan Smith
A function would be named based on what it is that it does. Difficulty naming functions would imply to me that the functions involved do not contain a clear functionality. The names of the functions should sort of be an 'emergent property' of a larger process of reasoning through the programming

Re: Clojure for financial applications

2010-03-08 Thread Jonathan Shore
Thanks for the reply. I could be wrong, but namespaces just provide a package / require mechanism, such that only required functionality is in the namespace of some code.This seems to be more of a mapping to the package / import mechanism of java or something similar in ruby or python. Ho

Clojure Implementation issues that may affect performance?

2010-03-08 Thread Jonathan Shore
rlooked something that mitigates or otherwise avoids dispatch. Jonathan -- 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 - please

Re: Clojure for financial applications

2010-03-08 Thread Jonathan Shore
On Mar 8, 2010, at 11:51 AM, Volkan YAZICI wrote: > On Mar 7, 6:35 pm, jshore wrote: >> Wondering whether anyone has done something very complex in the algo >> space or comparable so can get an idea of how this sort of stuff is >> structured idiomatically. I will also be concerned with perform

benchmarks on a poor-man's matrix concept

2010-03-08 Thread Jonathan Shore
Hi, I'm still trying to work out the best way to deal with operations on heterogenous data in clojure. I have a complex application which has such requirements. I wrote a simple toy matrix as a means to explore closure versus map based implementations. Note that in this case the "data str

Re: Clojure for financial applications

2010-03-09 Thread Jonathan Shore
:22, Jonathan Shore wrote: > >> For the sake of understanding, I'm not yet clear on how one *efficiently* >> binds multiple "pieces" of state together in clojure. How would one create >> a simple matrix for example where I want to bind dimension and a float-array

Re: benchmarks on a poor-man's matrix concept

2010-03-09 Thread Jonathan Shore
On Mar 9, 2010, at 1:28 AM, Per Vognsen wrote: > Which is preferable depends on the nature of the changes that your > matrices will undergo. For dense linear algebra, it's common for most > of a matrix to change with every operation. Hence you won't reap any > benefits from the persistence of Clo

Re: benchmarks on a poor-man's matrix concept

2010-03-09 Thread Jonathan Shore
On Mar 9, 2010, at 2:41 AM, Per Vognsen wrote: > By the way, I also noticed your logic is wrong. It should be (+ (* i > ncol) j) rather than (* i j). > > -Per Thanks -- I was just trying to explore how to deal with heterogeneous data. No plans to build my own matrix lib. Thanks for spotti

Re: Clojure Implementation issues that may affect performance?

2010-03-09 Thread Jonathan Shore
On Mar 9, 2010, at 1:19 PM, Richard Newman wrote: >> I suspect that on recursion > > If you use plain function-calling recursion, yes. If you use (loop ... > recur...) then (IIRC) locals are not boxed (as well as saving stack). > > Also bear in mind that JIT will come into play here; after a f

proposal for core arithmatic functions

2010-03-12 Thread Jonathan Shore
point in argument declarations as well? Thanks Jonathan -- 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 - please be patient with

Re: proposal for core arithmatic functions

2010-03-13 Thread Jonathan Shore
Thanks for your thoughtful reply, see below. On Mar 13, 2010, at 3:03 AM, Konrad Hinsen wrote: > On 13 Mar 2010, at 03:32, Jonathan Shore wrote: > >> Could + and other operators be changed to a macro mapping rather than the >> current defn, mapping the argument list to a

Re: Erlang like environment

2010-04-16 Thread Jonathan Smith
Actually I've got to disagree here, it is really easy to do. Here is one example of something esessoms did: http://github.com/esessoms/clj-interface And here is an example of the rewrite I did when I decided that his version didn't quite do what I wanted. http://gist.github.com/369114 On Apr 15

Re: Is this the good way to write get-percentage

2015-02-13 Thread Jonathan Winandy
Hi ! You could rewrite the code like that : (defn get-percentage ([place total-count] (get-percentage :normal place total-count)) ([mode place total-count] (let [mode-fn (case mode :highMath/ceil :low Math/floo

Re: Is this the good way to write get-percentage

2015-02-14 Thread Jonathan Winandy
"Unable to resolve symbol: ​ in this " I get this error when I have a non-breaking space in my code : http://en.wikipedia.org/wiki/Non-breaking_space Jon On Sat, Feb 14, 2015 at 3:21 PM, Matching Socks wrote: > A Clojure fn is an Object, but Math's ceil method is not an Object. The > Java-Int

Re: Help with Liberator POST route

2015-02-19 Thread Jonathan Barber
subscribed to the Google > Groups "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Jonathan Barber -- You received

Re: 2 way transform in single definition ? unification ?

2015-07-13 Thread Jonathan Winandy
To me it's a very good option. Given you example : (./pull '[org.clojure/core.logic "0.8.10"]) (ns yo (:refer-clojure :exclude [==]) (:use [clojure.core.logic])) (defne a-to-b [x y] ([ {:a {:b b :c c}} [b [c]] ])) (run* [a] (a-to-b a [1 [2]])) ;#=> ({:a {:b 1, :c 2}}) On 13 July

Re: Port of simple Scala match to Clojure core.match

2015-07-16 Thread Jonathan Winandy
Hello ! I think, this branch (without :<< empty?)) (match [l prefix] *[_ ([] :seq)] true* ​is already checking that prefix is empty. ​Have a nice day, Jon On 16 July 2015 at 23:06, Rastko Soskic wrote: > Hi, I am getting familiar with Clojure's core.match and > simply starting with some

Re: OT: Github Alternatives

2014-06-30 Thread Jonathan Abbey
We've been using GitLab in our laboratory for some time now, and I recommend it very highly indeed. Getting it set up was a bit of a pain because they did not have RedHat packages when we first installed it, and we were setting it up on a server that did not have Internet access. installation

Re: OT: Github Alternatives

2014-07-01 Thread Jonathan Winandy
I am feeling the same thing about git, while having no problems using it. I used mercurial before, to me, the command were simpler, as well as the model. For example, a branch can have several heads in mercurial, and it separates more easily fetch and merge. You don't have a origin/master and yo

Re: positional + keyword args

2014-07-21 Thread Jonathan Winandy
Hi, If I understand your pb correctly, and form what I have seen in the Scala world, there is maybe a simpler way to do it : (defn process-args [args fnkeys fndefault] (let [[positional-args named-args] (split-with (complement keyword?) args) named-args (into {} (map vec (partition

Re: behaviour of map

2014-10-18 Thread Jonathan Winandy
You can try in you repl with (take 1 (map (fn [_] (println "executed")) (vec (range 100 (take 32 (map (fn [_] (println "executed")) (vec (range 100 (take 33 (map (fn [_] (println "executed")) (vec (range 100 you will observe the 32 sized chunks. On Sat, Oct 18, 2014 at 7:36 PM,

Re: behaviour of map

2014-10-18 Thread Jonathan Winandy
nction used with "repeatedly" only prints once: > > (first (repeatedly 4 #(do (println "executed!") (inc 1 > > I guess because Clojure does not read-ahead in this scenario. Am I right? > > On Sat, Oct 18, 2014 at 1:41 PM, Jonathan Winandy < > jonathan

Re: Backslashes in Edn

2014-11-25 Thread Jonathan Winandy
http://www.ietf.org/rfc/rfc4627.txt var home = "c:\\temp"; Best regards, Jonathan On Tue, Nov 25, 2014 at 1:23 PM, Andy Dwelly wrote: > I've recently been serialising some data using Edn, and to date this has > caused no problems. During some tests today, I serialised a string

Re: Protocols for persistence - not sure about a few cases

2016-08-29 Thread Jonathan Fischer
Two options. The first, straightforward one: make the thing that's implementing the protocol the Storage, not in the individual things being stored. So something like: (defprotocol ItemStore (save-item [store item]) (load-items [store items])) etc. Second option: Clojure has multimethods t

Re: Protocols for persistence - not sure about a few cases

2016-08-29 Thread Jonathan Fischer
The most straightforward one: just make your protocols a thing that your storage medium implements, instead of your records. E.g.: (defprotocol ThingStore (load-item [store item-id]) (load-items [store item-ids]) (find-item [store item-name]) (save-item [store item])) (defrecord Databas

Re: Clojure version and quil

2016-09-08 Thread Jonathan Fischer
You're probably using the leiningen that's packaged in Ubuntu, right? On Ubuntu 14.04, that's pulling in version 1.7.x, which is positively ancient. Remove the apt packaged version of leiningen and follow the installation instructions on the website (http://leiningen.org) and you'll probably be

Re: multimethods, uberjar, and several namespaces

2016-11-23 Thread Jonathan Fischer
In your minimal case: nothing ever imports multitest.other, so the defmethod never gets loaded. On Wednesday, November 23, 2016 at 11:31:21 AM UTC-8, Erik Assum wrote: > > Hi, > > I’ve got a defmulti defined in a namespace and it’s corresponding > defmethods defined in other namespaces. > This

Re: multimethods, uberjar, and several namespaces

2016-11-23 Thread Jonathan Fischer
en would be, how do I make it load without > creating a circular dependency? > > Erik. > -- > i farta > > Den 23. nov. 2016 kl. 20.50 skrev Jonathan Fischer >: > > In your minimal case: nothing ever imports multitest.other, so the > defmethod never gets loaded.

Re: multimethods, uberjar, and several namespaces

2016-11-23 Thread Jonathan Fischer
d I say, closed? > > This would mean that you can't build a plugin system based on multi > methods, right? > > Erik. > -- > i farta > > Den 23. nov. 2016 kl. 22.16 skrev Jonathan Fischer >: > > Just move your defmulti form out of the namespace that'

Re: Clojure core documentation

2017-09-10 Thread Jonathan Shieh
Yeah, I saw the same video and wanted to do something to start help improving the documentation also. I remember the time when I was trying to get into clojure. It was hard to make heads or tails out of the official api docs. Regarding the syntactic format of the documentation, wouldn't somethi

Clojure CLI tool fails to resolve weird transitive dependencies.

2017-12-11 Thread Jonathan Fischer
I apologize, I'm not certain of the right name for this. I'm pulling in libgdx and its dependencies. In Leiningen, my dependencies vector looks like this: :dependencies [[org.clojure/clojure "1.8.0"] [com.badlogicgames.gdx/gdx "1.9.6"] [com.badlogicgames.gdx/

Re: Clojure CLI tool fails to resolve weird transitive dependencies.

2017-12-11 Thread Jonathan Fischer
Ha, I think that must’ve snuck in there during editing. Fixing that particular typo didn’t help any. :D > On Dec 11, 2017, at 12:22 PM, David Bürgin wrote: > > On 11/12/17 20:47, Jonathan Fischer wrote: >> com.badlogicgames.gdx/gdx {:mvn/versin "1.9.6"} >

Re: Clojure CLI tool fails to resolve weird transitive dependencies.

2017-12-11 Thread Jonathan Fischer
Yep, that looks like what I'm seeing. Thanks! -- 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 - please be patient with your first post. To un

Re: Data visualization workshops post-mortem

2015-11-21 Thread Jonathan Lin
Fantastic work! Thanks so much for the writeup. On Fri, Nov 20, 2015 at 7:52 AM, wrote: > For what sounds like it was a great success, I wouldn't call this a > "post-mortem", as though it's dead! Very useful notes > > > On Thursday, November 19, 2015 at 1:51:06 PM UTC, Karsten Schmidt wrote: > >

Why is Clojure faster than Java at this task?

2014-02-25 Thread Jonathan Barnard
I recently did a benchmark (admittedly in hindsight not a particularly good one) that involved comparison of an implementation of the same small program in Javaand in Clojure

Re: Why is Clojure faster than Java at this task?

2014-02-25 Thread Jonathan Barnard
t; optimisation - > http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/math/BigInteger.java#BigInteger.add%28java.math.BigInteger%29) > > > if the overhead of BigInteger is actually needed. > > If you use clojure.lang.BigInt in your Java code, I suspect J

Helmsman: Not another routing library?!

2014-04-23 Thread Jonathan Doane
Hello everyone, I've been working on a library for VLACS called Helmsman. It's designed to let you construct and compose your web application while having an emphasis on navigation and relative URI generation so you can use the data you use to define your routes to also generate your URIs. I al

Re: How to iterate over maps and drop one specific element each time?

2014-06-11 Thread Jonathan Winandy
Hi ! If you want to keep certain entries, there is also select-keys : (map #(select-keys % [:v :b :z]) [{:op :e :v 1} {:op :n :b 2} {:op :m :z 2.3}]) On Wed, Jun 11, 2014 at 3:12 PM, Di Xu wrote: > (map #(dissoc % :op) [{:op :e :v 1} {:op :n :b 2} {:op :m :z 2.3}]) > > 2014-06-11 21:09 GM

MyType cannot be cast to MyType?

2014-01-19 Thread Jonathan Barnard
For fun, I've been porting a very simple particle animation from Java to Clojure. It was somewhat slow so to see how fast I could make it I decided to try using mutation. I've defined a Particle type, and a PSlice type that contains an array of objects and a length (number of non-nil objects in

Re: MyType cannot be cast to MyType?

2014-01-22 Thread Jonathan Barnard
ious class definitions) other than just closing and re-opening it? On Wednesday, 22 January 2014 12:11:07 UTC+11, Stuart Sierra wrote: > > Hello Jonathan, > > In my experience, an error along the lines of "class Foo cannot be cast to > Foo" is usually caused by re-eval

Re: MyType cannot be cast to MyType?

2014-01-23 Thread Jonathan Barnard
Excellent, that looks quite useful, thank you. On Thursday, 23 January 2014 01:59:21 UTC+11, Mauricio Aldazosa wrote: > > Take a look at Stuart's tools.namespace ( > https://github.com/clojure/tools.namespace), although be wary of the > protocol issue as it is something that is pointed out in the

Slime Problems: Unable to compile via C-c C-k, C-c M-x and list callers via C-c C-w c

2010-08-22 Thread Jonathan Joseph
12) Compiling /home/jonathan/swdev/clojure/testproject/src/samples/testdest.clj... Compilation finished. (No warnings) [0.05 secs] Highlighting notes... Compilation finished. (No warnings) [0.05 secs] Preparing compilation log... Compilation finished. (No warnings) [0.05 secs] Fontifying *SLIME Comp

Re: Throwing an Exception with get

2011-03-21 Thread Jonathan Smith
Here is a way that should work. (let [missing (gensym)] (defn get-with-exception [map key] (let [res (get map key missing)] (if (= res missing) (throw (new Exception "my-exception")) res Gensyms are unique so you also don't have the problem of 'what happens if I

Re: Throwing an Exception with get

2011-03-21 Thread Jonathan Smith
Ah, interesting. You'll notice that the gensym is created outside the defn and captured, so I'm not sure speed is important. On Mar 21, 11:26 am, Mikhail Kryshen wrote: > On Mon, 21 Mar 2011 07:52:45 -0700 (PDT) > > Jonathan Smith wrote: > > Here is a way that should

Re: Deep recursion, continuation passing style, trampolining and memoization

2011-03-22 Thread Jonathan Smith
I'm wondering if it wouldn't be better to simply implement it using a mutable 2d Java array? (the standard imperative implementation). It wouldn't be a 'purely functional' answer, but the array wouldn't leak out of the levenshtein-distance function. On Mar 22, 3:09 am, Christian Schuhegger wrot

Re: using clojure for (java) code generation; advice sought

2011-03-29 Thread Jonathan Smith
You might want to read through the source of scriptjure: https://github.com/arohner/scriptjure For one way to do this sort of thing. Pretty much, you would make a basic recursive descent parser that operates on a tree of clojure primitives. You could then wrap this in a macro, and go from there.

Re: Closures in macros

2011-05-04 Thread Jonathan Smith
On May 3, 5:22 pm, André Thieme wrote: > Am 02.05.2011 23:14, schrieb David Nolen: > > > The relevant clojure-dev thread. > >http://groups.google.com/group/clojure-dev/browse_thread/thread/f4907... > > > It's not clear whether the core team and the various contributors are > > interested in suppor

Re: Closures in macros

2011-05-04 Thread Jonathan Smith
On May 4, 8:50 am, Simon Katz wrote: > > For example Common Lisp does support this. > > That's not true, or at least it's only partly true. > > Here's a translation of your example into Common Lisp (I added a use > of a# in the macro to avoid compiler optimization making the problem > go away): >

Re: I am new comer for clojure, I concern that when will clojure surpport Distribution function like erLang

2011-05-04 Thread Jonathan Smith
You can use the erlang-otp Java library from Clojure. I think there are bindings on github. If not, they are simple to generate. (I actually had clojure hooked up to a yaws webserver (yaws pattern matches requests, clojure generates pages) for a while, using LFE and the OTP libraries. Clojure wri

Re: Clojure Koans and others interactive exercises to learn clojure?

2011-07-05 Thread Jonathan Cardoso
Thanks for sharing this!! I didn't know that there was a Koans version for Clojure =D On 4 jul, 00:52, Antonio Recio wrote: > Clojure koans is awesome > to learn clojure. Do you know other projects with exercises to learn > clojure? -- You rec

Re: Clojure now officially supported on Heroku

2011-07-05 Thread Jonathan Cardoso
Amazing news!! Heroku is great and simple! On 5 jul, 14:54, Mark McGranaghan wrote: > I'm very excited to say that Clojure is now an officially supported > deployment option on Heroku: > >    http://blog.heroku.com/archives/2011/7/5/clojure_on_heroku/ > > A big thanks to everyone in the Clojure c

  1   2   3   4   >