Re: Beginner: performance of vector creation/"modification"

2009-10-19 Thread Stuart Campbell
2009/10/19 Danny Woods > > harto wrote: > > Hello, > > > > I've just started learning Clojure, so I'm trying to figure out the > > correct way of doing things. I've been trying to create and 'modify' a > > large vector for an online programming exercise, but I'm running into > > some performance

Re: Beginner: performance of vector creation/"modification"

2009-10-19 Thread Stuart Campbell
2009/10/19 Christophe Grand > Hi, > > On Mon, Oct 19, 2009 at 7:59 AM, harto > wrote: > >> I've just started learning Clojure, so I'm trying to figure out the >> correct way of doing things. I've been trying to create and 'modify' a >> large vector for an online programming exercise, but I'm run

Re: Slime and stuff

2009-10-21 Thread Stuart Campbell
Jeffrey, did this work for you? I followed the instructions on the screencast and I couldn't get a REPL to open in Aquamacs. (The only thing I did differently was put the contents of customizations.el into ~/.emacs.) Do I have to install SLIME separately... ? 2009/10/21 Jeffrey Straszheim > Tha

Re: Slime and stuff

2009-10-22 Thread Stuart Campbell
if you also use other versions of > emacs on the same box and want to avoid duplication. > > Hope that helps. > > -Brian Cooley > > On Oct 21, 6:31 am, Stuart Campbell > wrote: > > Jeffrey, did this work for you? I followed the instructions on the > > screencast an

Re: "Interesting" integer behavior

2010-03-11 Thread Stuart Campbell
I took a look at the code for Clojure 1.1, in clojure.lang.Numbers, and it seems that results of numerical ops on BigIntegers (BigIntegerOps) are passed to a 'reduce' method, which appears to return the most economical representation of a number: static public Number reduce(BigInteger val)

Re: Can't call public method of non-public class

2010-03-23 Thread Stuart Campbell
Hi Konstantin, >From JDK docs ( http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ProcessBuilder.html#environment%28%29 ): The behavior of the returned map is system-dependent. A system may not allow > modifications to environment variables or may forbid certain variable names > or values. For th

Re: Can't call public method of non-public class

2010-03-23 Thread Stuart Campbell
Whoops... I completely glazed over the fact that the equivalent Java code worked perfectly :( On 24 March 2010 11:19, Armando Blancas wrote: > You want Clojure to treat 'env' as a Map instead of its implementation > class, which is not public. Just add the type hint #^Map to 'env''s > def: > > u

Re: any downside to putting everything into CLASSPATH?

2010-05-23 Thread Stuart Campbell
> > JVM newbie question here. Aside from the clojure & clojure-contrib jars, is > there any downside to automatically setting up my CLASSPATH so that all jars > on my box are available - even if I might only be using 1 or 2 for the code > I'm working on at the moment? > The problem with such a sch

cljs.test :after fixture not called if test errors

2020-11-24 Thread Stuart Campbell
Hello, I'm experimenting with fixtures and it seems like :after fixtures aren't run if a test unexpectedly errors. E.g.: (use-fixtures :once {:before #(println "before") :after #(println "after")}) (deftest a-test (raise (js/Error. "oops"))) In this example I expected to

Re: cljs.test :after fixture not called if test errors

2020-11-24 Thread Stuart Campbell
That unfortunately doesn't work for async tests, which require the map fixture style (with :before/:after keys). On Tue, 24 Nov 2020 at 21:23, Estevo U. C. Castro wrote: > Try > > (use-fixtures :once > (fn [f] > (println "before") > (try (f) > (finally (println "after") > > O

Re: cljs.test :after fixture not called if test errors

2020-11-27 Thread Stuart Campbell
gt; David > > On Wed, Nov 25, 2020 at 1:19 AM Stuart Campbell wrote: > >> That unfortunately doesn't work for async tests, which require the map >> fixture style (with :before/:after keys). >> >> On Tue, 24 Nov 2020 at 21:23, Estevo U. C. Castro

clojure.tools.logging / log4j / lein2

2013-01-29 Thread Stuart Campbell
Hello, I'm working on a library that uses clojure.tools.logging, and I'm using Leiningen 2 to build it. If I include log4j in my project's :dev-dependencies, I get weird logging output, e.g.: Jan 29, 2013 8:45:31 PM clojure.tools.logging$eval373$fn__377 invoke INFO: Hello But if I include log4j

Re: clojure.tools.logging / log4j / lein2

2013-01-29 Thread Stuart Campbell
Hmm, perhaps I should RTFM. Apparently :dev-dependencies no longer exists in lein2. Adding this to my project.clj resolves the issue: :profiles {:dev {:dependencies [[log4j "1.2.17"]]}} On 29 January 2013 21:24, Stuart Campbell wrote: > Hello, > > I'm workin

Re: Log SQL in clojure.contrib.sql

2010-07-29 Thread Stuart Campbell
On 29 July 2010 15:17, ngocdaothanh wrote: > I found: > http://code.google.com/p/log4jdbc/ > > That looks useful - 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

Re: Unexpected FileNotFoundException

2010-08-19 Thread Stuart Campbell
On 20 August 2010 11:52, Tim McIver wrote: > Hello everyone. Clojure noob here. I apologize in advance for what > may turn out to be a dumb question. When trying to (use > '[clojure.contrib.seq]) I get the following error: > > java.io.FileNotFoundException: Could not locate clojure/contrib/ >

Re: Unexpected FileNotFoundException

2010-08-22 Thread Stuart Campbell
On 21 August 2010 08:39, Tim McIver wrote: > Can someone help clear up my confusion? > > My problem started while working through Stuart Halloway's book (p. > 52) where he builds up his 'index-filter' function. This function > uses an 'indexed' function which he states is in clojure-contrib. The

Re: NullPointerExecption after Java class import

2010-08-29 Thread Stuart Campbell
Hello, I don't know this library specifically, but the NPE is probably occurring in a static initialisation block. I believe static initialisation occurs when the class is first loaded. Regards, Stuart On 30 August 2010 06:42, zm wrote: > > I am using GATE java libs in my clojure code and beha

Re: NullPointerExecption after Java class import

2010-08-31 Thread Stuart Campbell
} > > > > } > > > > Then in clojure: > > > > (ns x (:import (aaa Test)) > > > > Results in: > > > > Exception in thread "main" java.lang.ExceptionInInitializerError > > (core.clj:1) > > > > Why does this happen in clojure? If you

Using macro to generate part of fn

2010-09-17 Thread Stuart Campbell
Hello, In the following contrived example, I get an error when macroexpanding (defn foo ...): (defmacro special-fn-spec [] '([bar baz] (println bar baz))) (defn foo ([bar] (foo bar :default)) (special-fn-spec)) The error is: Parameter declaration special-fn-spec should be a vector [Thro

Re: Using macro to generate part of fn

2010-09-18 Thread Stuart Campbell
> > Macroexpansion is part of the expression evaluation mechanism. In your > example > > >(defn foo > ([bar] (foo bar :default)) > (special-fn-spec)) > > the whole defn-form is macroexpanded first, yielding something like > >(def foo (fn ([bar] (foo bar :default))

Re: Idiomatic Way to Build String or Simply Use StringBuilder

2010-09-29 Thread Stuart Campbell
On 30 September 2010 12:48, HiHeelHottie wrote: > > Is there an idiomatic way to build up a string over different lines of > code? Or, should one simply use StringBuilder. > > I would just use (str) - it uses a StringBuilder when given more than one argument: user> (source str) (defn str "Wit

Re: using reduce instead of loop recur

2011-05-31 Thread Stuart Campbell
For this particular case, you could also use regexps: user> (require '[clojure.string :as s]) nil user> (s/replace " bb cc" #" +" " ") " bb cc" Regards, Stuart On 31 May 2011 08:15, iz bash wrote: > so clojures like my first programming language. most of the time > now ,i

Re: Wisdom sought for functional iterative processing

2011-06-14 Thread Stuart Campbell
On 14 June 2011 12:37, Matthew Phillips wrote: > The only way I can think of to write it in Clojure is: > > (reduce > (fn [items op] >(let [items1 (if (:delete op) (drop-index (:delete op) items) > items)] > (if (:insert op) (cons (:insert op) items1) items1))) > items ops) > > i.e. I'

Re: help with some code

2011-07-12 Thread Stuart Campbell
If you use vectors instead of lists, you can avoid quoting altogether: user> (def alist [1 (fn [x y] (+ x y))]) #'user/alist user> (apply (second alist) [1 3]) 4 Regards, Stuart On 13 July 2011 08:09, Joop Kiefte wrote: > Didn't try, but shoudn't (def alist `(1 ~(fn [x y] (+ x y be better?

ClojureScript: browser REPL omitting namespace in generated JS

2012-03-02 Thread Stuart Campbell
Hello, I'm encountering a problem where the browser REPL sometimes omits the ClojureScript namespace in its generated JavaScript, e.g. (def x 42) compiles to ".x = 42" instead of "foo.x = 42". I've put together a minimal project, with steps to reproduce, on GitHub: https://github.com/harto/cljs-e

Re: Clojurescript One: (def fiv 5) compiles to ".fiv = 5;\n" ?

2012-03-02 Thread Stuart Campbell
Hi, I've come across this too. Please see my message "ClojureScript: browser REPL omitting namespace in generated JS". Regards, Stuart On 16 January 2012 08:14, Indy wrote: > Having the same issue and the only way I've resolved it is by having both > the server and the cljs-repl running in the

Re: ClojureScript: browser REPL omitting namespace in generated JS

2012-03-02 Thread Stuart Campbell
Done! http://dev.clojure.org/jira/browse/CLJS-157 On 3 March 2012 01:15, David Nolen wrote: > Please open a ticket in JIRA. Thanks! > > On Fri, Mar 2, 2012 at 4:50 AM, Stuart Campbell wrote: > >> Hello, >> >> I'm encountering a problem where t

Re: Clojurescript: named/numbered releases?

2012-03-08 Thread Stuart Campbell
Hello, According to a past thread ( https://groups.google.com/forum/?fromgroups#!topic/clojure/L4e8DtzdThY): ClojureScript has no "release" versions yet. Instead we have a > revision number, calculated as the number of commits on the master > branch since the beginning of the project. ClojureScri

Re: ClojureScript: browser REPL omitting namespace in generated JS

2012-03-14 Thread Stuart Campbell
ght be here: > > > https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/repl.clj#L117 > > I'll dig into this this weekend. > > On Mar 2, 6:30 pm, Stuart Campbell wrote: > > Done!http://dev.clojure.org/jira/browse/CLJS-157 > > > > On 3 March 2012

Re: 'contains?' on 'sorted-set-by' based on the comparator only? (possible bug?)

2012-03-15 Thread Stuart Campbell
Actually, sorted-map-by does behave the same way, but in your example you tried to lookup a value instead of a key: user> (def m (sorted-map-by #(< (%1 0) (%2 0)) [1 :a] [2 :b])) #'user/m user> (get m [1 :foo]) [2 :b] It looks like PersistentTreeMap.entryAt

Re: Resolving vars and quoting

2012-03-15 Thread Stuart Campbell
Almost, but you do need to resolve the symbols to functions when you evaluate the operation: (defn arith [x y] (map (fn [op] [((resolve op) x y) (list op x y)]) '[+ - / *])) Regards, Stuart On 16 March 2012 02:52, Jack Moffitt wrote: > > If I apply the following function to 4 and 6 > > > > (

Re: Problems with map of empty collections

2012-04-03 Thread Stuart Campbell
I think quoting plays a part here: Clojure 1.3.0 user=> {(list 1 2 3) :list [1 2 3] :vec} IllegalArgumentException Duplicate key: (1 2 3) clojure.lang.PersistentArrayMap.createWithCheck (PersistentArrayMap.java:70) Stuart On 3 April 2012 22:41, JuanManuel Gimeno Illa wrote: > More examples in

ClojureScript function params shadow top-level namespace segments

2012-04-13 Thread Stuart Campbell
Given the following ClojureScript: (ns foo) (defn bar [] 42) (ns baz (:require [foo :as x])) (defn quux [foo] (x/bar)) baz.quux compiles to: baz.quux = function quux(foo) { return foo.bar.call(null) }; i.e. the parameter name shadows the top-level "foo" namespace. Is that a bug? Regar

Re: ClojureScript function params shadow top-level namespace segments

2012-04-13 Thread Stuart Campbell
Done: http://dev.clojure.org/jira/browse/CLJS-180 On 13 April 2012 22:14, David Nolen wrote: > Yes. Please open a ticket in JIRA. > > Thanks! > > On Fri, Apr 13, 2012 at 3:40 AM, Stuart Campbell wrote: > >> Given the following ClojureScript: >> >> (ns fo

Re: Typed Clojure 0.1-alpha2

2012-04-21 Thread Stuart Campbell
The ClojureScript compiler doesn't seem to do those kinds of checks, but the Clojure compiler does. On 21 April 2012 09:18, Casper Clausen wrote: > Looks interesting. > > Personally I always thought clojure's handling of function arity is a > bit strange. I don't understand why calling a functio

Re: Help with #'

2012-04-22 Thread Stuart Campbell
Hi Dave, If you write (run-jetty routes ...) then the current value of "routes" is looked-up and passed to run-jetty. You won't see any change if you subsequently redefine "routes", because the original definition is what was passed to run-jetty. On the other hand, (run-jetty #'routes ...)

ClojureScript: can't (:use) protocol in another namespace

2012-04-27 Thread Stuart Campbell
Hello, I'm not sure if what I'm doing is supported or whether I'm doing it incorrectly. I have two ClojureScript namespaces: (ns foo) (defprotocol SomeProtocol (some-function [this])) (ns bar (:use [foo :only (SomeProtocol)])) (defrecord SomeRecord SomeProtocol (some-function [_] :quu

Re: ClojureScript: can't (:use) protocol in another namespace

2012-04-29 Thread Stuart Campbell
It does. Ticket opened: http://dev.clojure.org/jira/browse/CLJS-216 Cheers, Stuart On 28 April 2012 01:30, David Nolen wrote: > Does this work in Clojure? If so file a ticket in JIRA. > > David > > On Fri, Apr 27, 2012 at 5:09 AM, Stuart Campbell wrote: > >> Hello, &g

Re: ClassCastException clojure.lang.Var$Unbound Help

2012-04-30 Thread Stuart Campbell
Hi Travis, > (def get-id > (session/get :uid)) > > (defn set-user! [user] > (session/put! :uid {:_id user})) > Only set-user! is a function here. The value of get-id is evaluated at compile-time. I don't know about the implementation of noir.session/get, but the error message suggests that it

Re: apply a function to every item in a sequence without realizing the sequence

2012-05-01 Thread Stuart Campbell
On 2 May 2012 14:44, Baishampayan Ghose wrote: > You can't use `map` because `map` will return a sequence of the same > size and that can blow your heap. > Isn't `map` lazy too? Regards, Stuart -- You received this message because you are subscribed to the Google Groups "Clojure" group. To po

cljs-clj interop

2012-12-29 Thread Stuart Campbell
Hi all, I'm toying with a way to use Clojure objects from a Rhino-based ClojureScript environment (https://github.com/harto/rhino-bridge). I've been able to export a Clojure function into the ClojureScript environment without too much difficulty. Ideally, I'd like to be able to call that function

Re: cljs-clj interop

2012-12-30 Thread Stuart Campbell
> ([this a] (.invoke this a))) > ) > > > On Sat, Dec 29, 2012 at 8:22 PM, Stuart Campbell wrote: > >> Hi all, >> >> I'm toying with a way to use Clojure objects from a Rhino-based >> ClojureScript environment (https://github.com/harto/rhin

Re: cljs-clj interop

2012-12-30 Thread Stuart Campbell
IFn "prototype" (js/Object.)) :as "(Packages.clojure.lang.IFn[\"prototype\"] = (new Object()));\n" org.mozilla.javascript.EvaluatorException: Java class "clojure.lang.IFn" has no public instance field or method named "prototype". (#9) at :9 (anonymous) at :9 On

Re: cljs-clj interop

2013-01-03 Thread Stuart Campbell
In case anybody's interested, I'm messing around with a ClojureScript wrapper type that can implement various core protocols, e.g.: (deftype ClojureObject [o] IFn (-invoke [_] (.invoke o)) (-invoke [_ a] (.invoke o a)) ;; etc ) On 31 December 2012 09:56, Stuart Campbell wr

Re: ClojureScript def, vars, and binding

2013-01-14 Thread Stuart Campbell
Sorry to dig up such an old thread. I'd also like to maintain the bindings of dynamic vars across asynchronous function calls. Is there a workaround that people use in the absence of bound-fn, etc? Cheers, Stuart On Friday, 27 January 2012 16:49:10 UTC+11, Brandon Bloom wrote: > > The ClojureS

Re: Another ClojureScript app in the wild

2011-08-21 Thread Stuart Campbell
Ha! I was considering doing this exact same thing. I'm working on a vanilla js version that I was considering porting to cljs. It might be interesting to compare implementations: https://github.com/harto/pacman Thanks for sharing, Stuart On 18 August 2011 08:00, Matthew Gilliard wrote: > I've b

ClojureScript keywords

2011-09-02 Thread Stuart Campbell
Hi, When I compile the following to JavaScript, I expected it to output "foo" in the console log: (.log js/console (name :foo)) However, it outputs "ï· 'foo". Is that right? Regards, Stuart -- You received this message because you are subscribed to the Google Groups "Clojure" group. To pos

Re: ClojureScript keywords

2011-09-02 Thread Stuart Campbell
characters long. Is this just some encoding issue in my setup? I'm on Mac OS X 10.5, and I got the same result in FF 6 and Chrome 13. On 2 September 2011 17:41, Stuart Campbell < stuart.william.campb...@gmail.com> wrote: > Hi, > > When I compile the following to JavaScript, I ex

Re: ClojureScript keywords

2011-09-02 Thread Stuart Campbell
compiler, it will escape everything > to ascii so you won't get these encoding issues. > > There is a jira issue to make the unoptimised path do the same encoding as > the advanced compiler, but this isn't fixed yet. > > -- > Dave > On 2 Sep 2011 09:28, "Stuart Campbell&

Re: run clj file get user/counter-app error?

2011-09-13 Thread Stuart Campbell
That line is the string representation of a Var. It isn't an error - it's just the return value of the expression you entered. (load-file) evaluates all expressions in a file and returns the value of the last one. In your case, it's the value of (defn counter-app [] ...), which defines the counter

Re: N00b alert! - A question on immutable/mutable data structures...

2011-09-13 Thread Stuart Campbell
Hi Trevor, I hope I've understood your problem correctly. You can modify nested structures using e.g. update-in: (let [k "user1" v 1234] (swap! user-queues update-in k conj v)) That's assuming that a user queue already exists in the map. If it doesn't, you could do something like: (let

Re: N00b alert! - A question on immutable/mutable data structures...

2011-09-13 Thread Stuart Campbell
I knew there must be a nicer way to write that :) On 14 September 2011 16:22, Meikel Brandmeyer (kotarak) wrote: > Or: > > (swap! user-queues update-in [k] (fnil conj > clojure.lang.PersistentQueue/EMPTY) v) > > Sincerely > Meikel > > -- > You received this message because you are subscribed to

ClojureScript auto-recompile option

2011-09-15 Thread Stuart Campbell
Hello, I've written a small hack for the ClojureScript compiler that is useful for working with static HTML projects. When invoked with the :watch option, the cljsc program watches a source directory and recompiles sources whenever a change is detected. https://github.com/harto/clojurescript/comm

Re: ClojureScript auto-recompile option

2011-09-18 Thread Stuart Campbell
Cool - wasn't aware of that. On 16 September 2011 15:07, Chris Granger wrote: > FWIW there's also cljs-watch: > > http://github.com/ibdknox/cljs-watch > > On Sep 15, 6:35 am, Stuart Campbell wrote: > > Hello, > > > > I've written a small hack for

JavaScript `debugger' statement

2011-11-10 Thread Stuart Campbell
I'm trying to enter the Firebug debugger when an exception is caught: (try ; ... (catch js/Error e js/debugger)) This doesn't work, because js/debugger compiles to debugger$; per cljs.compiler/munge. Any ideas how I can get around this? Thanks, Stu -- You received this message because

Re: Where can I inqure about bugs?

2011-11-20 Thread Stuart Campbell
I think you might be using comparator incorrectly. It appears to expect a function that returns a true/false value: user> (source comparator) (defn comparator "Returns an implementation of java.util.Comparator based upon pred." {:added "1.0"} [pred] (fn [x y] (cond (pred x y) -1 (p

Re: ANN: j18n 1.0.0 – taming ResourceBundles

2011-11-24 Thread Stuart Campbell
Hi Meikel, Thanks for this library. I noticed that each bundle's keyset is cached via memoization. I believe this prevents adding more bundle properties at runtime (e.g. during interactive development). Is there a way to "reset" a resource bundle? Is this something that you might consider in a f

Re: ANN: j18n 1.0.0 – taming ResourceBundles

2011-11-24 Thread Stuart Campbell
Ah, I see. Thanks. On 24 November 2011 23:06, Meikel Brandmeyer (kotarak) wrote: > Hi, > > the ResourceBundles themselves are memoized by the Java runtime. You can > reset this cache with ResourceBundle/clearCache. Then the underlying > ResourceBundle will be retrieved again on the next access.

Re: Problem with Korma and clj-soap

2011-11-26 Thread Stuart Campbell
Libraries probably shouldn't ship with a log4j configuration. The logging configuration should be left entirely to the application IMO. On 26 November 2011 19:37, Ivan Koblik wrote: > I'm pretty sure this is because of log4j.xml [1] in src directory of > Korma. I think it's take from here [2]. I

Re: casting spels in clojure problem

2011-12-11 Thread Stuart Campbell
Hello, You'll need to include the source of the spel-print function, i.e. the (defn spel-print ...) part of the code. The error means that you're calling spel-print with either too many or too few arguments. But we can't tell unless you provide the code for that function :) Regards, Stuart On 1

Re: How to get the vector?

2011-12-20 Thread Stuart Campbell
Those return values are native Java arrays. user> (def x (int-array '(1 2 3))) #'user/x user> x # You can convert them to Clojure vectors using (vec): user> (vec x) [1 2 3] Regards, Stuart On 21 December 2011 11:59, Antonio Recio wrote: > When I try to get the position of two variables I get

Re: Calling all Melbourne, Australia, Clojure users

2012-02-07 Thread Stuart Campbell
Hi James, I'm currently only using Clojure for side projects, but I'm very keen to catch up! Stu On 7 February 2012 22:23, James Sofra wrote: > Hi all, > > I have been discussing recently possibly starting a Melbourne Clojure > meetup. > We have a possible location scouted out already but I re

Re: sql utilities

2010-10-14 Thread Stuart Campbell
Thanks Kyle. Looks useful! On 15 October 2010 09:25, Saul Hazledine wrote: > On Oct 14, 9:16 pm, "Kyle R. Burton" wrote: > > I've written some sql helper functions that will do things like list > > the objects in the database and describe a table. I've found these > > handy when doing interact

Re: SQLAlchemy in Clojure?

2010-10-19 Thread Stuart Campbell
On 19 October 2010 02:18, Sean Devlin wrote: > Okay, I just finished a Python app for work. Using SQLAlchemy was a > joy. Has anyone ported this yet? > I've never used SQLAlchemy. How does it compare with e.g. Django's ORM? Regards, Stuart -- You received this message because you are subscr

Re: Let usage question

2010-10-19 Thread Stuart Campbell
On 20 October 2010 14:19, Dave Ray wrote: > Hey, > > I'm parsing a file with a chain of filter and map operations. To make > it a little more readable (to me), I put the steps in a let like this: > > (defn parse-dictionary > [reader] > (let [lines(read-lines reader) >trimmed (map #

Re: challenge with vectors

2010-10-26 Thread Stuart Campbell
On 27 October 2010 12:54, Glen Rubin wrote: > I have a sequence like this: > > [ [a b] [a b] [a b] [a b] ] > > where a and b are numbers. I would like to return the vector and its > index for which b is the least in this collection. > > For example, if my data is as follows > > [ [22 5] [56 8] [

Re: Fastest way to generate comma-separated list

2010-10-27 Thread Stuart Campbell
On 28 October 2010 13:22, andrei wrote: > > I was seeking `interpose` function, thanks. But it still doesn't work > for strings - they are not wrapped by "\"\. E.g. > > (apply str (interpose ", " (list 1 2 3 4 5))) ==> "1, 2, 3, 4, 5" > > and > > (apply str (interpose ", " (list "1" "2" "3" "4"

Re: *warn-on-reflection* broken in 1.2?

2010-11-03 Thread Stuart Campbell
I get the expected result in my REPL via SLIME: user> *clojure-version* {:major 1, :minor 2, :incremental 0, :qualifier ""} user> (set! *warn-on-reflection* true) true user> (defn foo [s] (.charAt s 1)) Reflection warning, NO_SOURCE_FILE:1 - call to charAt can't be resolved. #'user/foo Regards, S

Re: macro debugger

2010-11-09 Thread Stuart Campbell
On 10 November 2010 02:50, Moritz Ulrich wrote: > I don't think there's a full-featured macro debugger for clojure, but > clojure has two simple functions called "macroexpand" and "macroexpand-1": > > user> (doc macroexpand-1 ) > - > clojure.core/macroexpand-1 > ([form]) >

Re: max-key taking a list rather than different number of args

2010-11-14 Thread Stuart Campbell
On 15 November 2010 14:17, Tom Hall wrote: > Hi, > > I think a better usage for max-key would be > (max-key f someseq) > rather than passing the values as args. > > I used > (defn max-key-seq [f someseq] > (apply max-key (into [f] someseq))) > to make it do what I wanted > > Is there a better wa

Re: fastest way to remove nils

2010-11-16 Thread Stuart Campbell
On 17 November 2010 12:37, wrote: > user=> (time (filter identity [ nil 1 2 nil 4])) > "Elapsed time: 0.053219 msecs" > (1 2 4) > > user=> (time (remove nil? [ nil 1 2 nil 4])) > "Elapsed time: 0.065092 msecs" > (1 2 4) > > Choose the flavor your prefer... > > Luc P. > Those aren't exactly equiv

Re: ANN: ClojureQL 1.0.0 finally released as public beta

2010-11-18 Thread Stuart Campbell
On 19 November 2010 06:10, LauJensen wrote: > Hi gents, > > For those of you who have followed the development > of ClojureQL over the past 2.5 years you'll be excited > to know that ClojureQL is as of today being released > as 1.0.0 beta1. > > That means that the significant primitives from Rela

Re: every-nth

2010-11-24 Thread Stuart Campbell
On 25 November 2010 16:56, Ken Wesson wrote: > Eh. This is weird. It seems that (partition n coll) drops the last > part of coll if it's not a multiple of n in size; e.g. (partition 3 [1 > 2 3 4 5]) yields ((1 2 3)) and not ((1 2 3) (4 5)). (partition n n [] > coll) does do that though. > See al

Re: Ring startup processing?

2010-11-28 Thread Stuart Campbell
On 28 November 2010 16:51, wrote: > We use a dedicated servlet for every web app to make sure all prerequisites > are met. Since it's loaded first, we can find problems by looking at a > single > piece of the log files just after the container messages announcing that > it's loading the app. > T

Re: Ring startup processing?

2010-11-28 Thread Stuart Campbell
n-startup flag. > > Of course if you know your app server's behavior regarding this feature, > it might not be a problem. > > I got caught once so I prefer a safer mechanism, we are not always using > the same app server here. Might work in dev and not in prod... oups... >

Re: Clojure Quizzes?

2011-01-12 Thread Stuart Campbell
On 12 January 2011 14:07, Robert McIntyre wrote: > You can use the latest version of clojure if you include it as a > dependency in your submission, so even though they say they only > support clojure1.0 they really support all of them. > Are other 3rd-party libs allowed, too? Cheers, Stuart -

Re: Clojure Quizzes?

2011-01-16 Thread Stuart Campbell
On 17 January 2011 13:48, John Svazic wrote: > Benny already answered, but here's the common block that I'm using for > my Clojure submissions: > > (import '(java.io BufferedReader FileReader)) > (defn process-file [file-name] > (let [rdr (BufferedReader. (FileReader. file-name))] >(line-seq

Re: Grabbing Rotten Tomatoes movie ratings in clojure

2011-01-16 Thread Stuart Campbell
Hi, Have you used Enlive[1]? It's a nice tool for HTML scraping and templating - it might be more robust than your regexp-based solution. It takes a bit of learning, though. Regards, Stuart [1] https://github.com/cgrand/enlive On 16 January 2011 05:57, justinhj wrote: > Sharing my first usefu