Re: tools.cli and required arguments

2014-01-22 Thread Alf Kristian Støyle
Ok, thanks for the reply guys :) Cheers, Alf On 22 January 2014 16:04, guns wrote: > On Wed 22 Jan 2014 at 02:21:51PM +0100, Alf Kristian Støyle wrote: > > > Would be nice to be able to specify that an option "must be specified > > in every invocation" though. I t

Re: tools.cli and required arguments

2014-01-22 Thread Alf Kristian Støyle
hassle when doing it yourself. Haven't looked too hard at the source though, but any chance of contributing a patch to something like that? E.g. [["-p" "--port PORT" "Port number" :mandatory true]] Cheers, Alf On 22 January 2014 14:04, guns wrote: > O

tools.cli and required arguments

2014-01-22 Thread Alf Kristian Støyle
Hi all! Trying to use clojure.tools.cli to help us parse command line arguments. However we are having trouble understanding how to specify required arguments. The following example taken from the documentation ( https://github.com/clojure/tools.cli#quick-start) should give a required argument (b

Re: WAT? BigInt instead of Long?

2013-04-01 Thread Alf Kristian Støyle
Reading the source, Ratios are actually represented as java.math.BigIntegerobjects. ( https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang /Ratio.java) Asking for denominator and numerator returns these values directly. user=> (class (denominator (/ 1 2))) java.math.BigInteger user=

Re: Rich Hickey quote on immutability

2013-04-01 Thread Alf Kristian Støyle
Thanks guys. Exactly what I was looking for. Cheers, Alf On 2 April 2013 01:28, Michael Ball wrote: > It might be his Clojure/West 2012 presentation on Datomic near the very > end. > > "Choose immutability and see where it takes you." > > http://www.infoq.com/presentations/The-Design-of-Datomi

Re: Attempt at rethrow macro

2013-04-01 Thread Alf Kristian Støyle
Hey Bill. I am guessing the problem is that the rethrow macro is expanded and passed to the reader/compiler before the handle-ex macro is. And at that point the compiler sees catch as a "standalone-symbol", not as part of the try special form. Macro-experts, please correct me :) Tried to quickly

Rich Hickey quote on immutability

2013-04-01 Thread Alf Kristian Støyle
Hey everyone! I am doing presentation on Clojure and immutability, and I am looking for a quote. I think I remember Rich saying something along the lines of: "Try going immutable and see where it takes you". Anyone remember where (or if at all), he said this? And of course, what the exact quote

Re: (load "hello") can't see hello.clj in the current directory.

2013-03-27 Thread Alf Kristian Støyle
MC Andre, if you put hello.clj in the src folder you should be able to do (load "hello"). (load-file ) should work for files not on the classpath, so (load-file "hello.clj") means look for hello.clj in the current working dir. Pretty easy to inspect the classpath in the repl, e.g: (filter #(= (ke

Re: Debug prints don't execute on multimethod dispatch functions

2013-03-25 Thread Alf Kristian Støyle
println works fine in this example at least: Clojure 1.5.1 user=> (defn meta-type "Gets the metadata type." [o] (when-let [m (meta o)] (:type m))) #'user/meta-type user=> (defn debug-switch [o & rest] (println "Received switch args : " o ", " rest) (meta-type o)) #'user/debug-swit

Re: The rationale behind mutable namespaces?

2012-03-29 Thread Alf Kristian Støyle
Thanks Herwig, makes sense. Cheers, Alf On Mar 29, 2012 1:37 PM, "Herwig Hochleitner" wrote: > 2012/3/29 Alf Kristian Støyle : > > So, long story short, why are namespaces in Clojure mutable? What is > > the rationale behind this? > > It's for REPL developmen

The rationale behind mutable namespaces?

2012-03-29 Thread Alf Kristian Støyle
Hi guys. First off, love Clojure and it has been a hobby of mine for several years. When first learning Clojure, one thing I didn't like, was the ability to actually change a Var at any point in time. Either through several def/defn's pointing to the same namespace/symbol or by something like alter

Re: (.containsKey {:one 1} :one) throws Exception

2012-03-04 Thread Alf Kristian Støyle
Thanks for the feedback guys. I have submitted a jira issue for the bug: http://dev.clojure.org/jira/browse/CLJ-944 By the way, tried this with Clojure 1.2.1, and there it works fine. Cheers, Alf On Sat, Mar 3, 2012 at 16:11, Herwig Hochleitner wrote: > Looks like the type inferencer inserts

(.containsKey {:one 1} :one) throws Exception

2012-03-03 Thread Alf Kristian Støyle
Hi guys, I am wondering why this does not work: (.containsKey {:one 1} :one) ;=> ClassCastException clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.PersistentHashMap The map is a: (class {:one 1}) ;=> clojure.lang.PersistentArrayMap And a PersistentArrayMap does have a containsKe

Re: clojure.contrib.io, clojure.contrib.http.agent and clojure.contrib.http.connection for Clojure 1.3

2011-09-26 Thread Alf Kristian Støyle
Looks really good. However it does not seem to support asynchronous calls, which was really what we were looking for. We thought http-agent was a cool idea. Guess it wouldn't be too much work to use agents to store results of clj_http though, I will definitely give it a try! Cheers, Alf On Mon

Re: clojure.contrib.io, clojure.contrib.http.agent and clojure.contrib.http.connection for Clojure 1.3

2011-09-26 Thread Alf Kristian Støyle
> Most of clojure.contrib.io was moved into Clojure itself, as > clojure.java.io. There is no future plan for functions from > clojure.contrib.io which have not already been copied into clojure.java.io. Guess I should have noticed that :) We certainly had no problems replacing clojure.contrib.io w

clojure.contrib.io, clojure.contrib.http.agent and clojure.contrib.http.connection for Clojure 1.3

2011-09-25 Thread Alf Kristian Støyle
Hi guys, not really sure if this is of any interest, since I am sure you have plans for all the contrib libraries. However I needed a version of clojure.contrib.io, clojure.contrib.http.agent and clojure.contrib.http.connection for a workshop that we are doing, and we really want to use 1.3, so I

Re: StackOverflowError in prime function

2011-09-22 Thread Alf Kristian Støyle
an infinite lazy > sequence that generates primes, I mean will be really more cool :) > --- > Wilker Lúcio > http://about.me/wilkerlucio/bio > Kajabi Consultant > +55 81 82556600 > > > On Thu, Sep 22, 2011 at 1:36 PM, Alf Kristian Støyle > wrote: >> >>

Re: StackOverflowError in prime function

2011-09-22 Thread Alf Kristian Støyle
Jup, that solved the problem. Lesson learned. Thanks :) Alf On Thu, Sep 22, 2011 at 17:54, Meikel Brandmeyer (kotarak) wrote: > Hi, > > Am Donnerstag, 22. September 2011 17:43:30 UTC+2 schrieb Alf: >> >> What am I doing wrong here, will filter/remove or something else give >> StackOverflowErr

StackOverflowError in prime function

2011-09-22 Thread Alf Kristian Støyle
Hi guys, playing around with different ways of creating primes. The following implementation is probably not very efficient, but it does seem to be correct. The problem is that when run it gives a java.lang.StackOverflowError. (defn primes[num] (let [possible (range 2 num)] (loop [current 2

Re: Small bug in clojure.core/bases?

2011-08-15 Thread Alf Kristian Støyle
Thanks. Submitted an issue to Jira, and I guess I will just see how it goes. http://dev.clojure.org/jira/browse/CLJ-828 Cheers Alf On Mon, Aug 15, 2011 at 16:26, Armando Blancas wrote: >> I think a function should generally return the same types for >> different input. A seq and a Java array

Re: Small bug in clojure.core/bases?

2011-08-15 Thread Alf Kristian Støyle
I think a function should generally return the same types for different input. A seq and a Java array are two very different things even though Clojure often lets us pass both to the same functions. It seemed like a small fix, but I guess not everyone agrees. Like a wrote, I think this is small bu

Small bug in clojure.core/bases?

2011-08-10 Thread Alf Kristian Støyle
I think I found a small bug in clojure.core/bases. Extending the existing unit test reveals it: (deftest test-bases (are [x y] (= x y) (bases java.lang.Math) (list java.lang.Object) (bases java.lang.Integer) (list java.lang.Number java.lang.Comparable) ) (is (seq?

java.lang.IllegalArgumentException: More than one matching method found: submit - when "letting" an ExecutorService

2011-07-16 Thread Alf Kristian Støyle
Hi guys. Experimenting a bit with code from "The joy of Clojure", and I ran into a little problem. Trying to run this in the REPL gives the following error: user=> (import [java.util.concurrent Executors]) java.util.concurrent.Executors user=> (let [*pool* (Executors/newFixedThreadPool (+ 2 (.ava

Re: Clojure 1.3: Integrating clj-stacktrace?

2010-08-25 Thread Alf Kristian Støyle
I am a newcomer to the language, and to lisps in general, and having to interpret Clojure's stacktraces is really hard. It is one of those things that made me not want to use the language at all. It also makes it hard for me to recommend the language to others. It is not just the stacktraces, but

Re: clojure.string namespace missing from API page?

2010-08-20 Thread Alf Kristian Støyle
Hi guys. If you google "Clojure API", the first hit gets you the following page: http://clojure.org/api Which again leads to: http://richhickey.github.com/clojure/ http://richhickey.github.com/clojure-contrib/ As I understand these pages are not the correct ones. I have finally bookmarked the co