Re: Method overloading & proxy method

2009-05-05 Thread Alex Osborne
On Mar 23, 9:55 am, ronen wrote: > [... what] I actually need is a way of overriding specific methods (like the > visit > (MethodDeclaration n, A arg) and not all of them. I keep running into this problem again and again myself, so I thought I might post some notes. The short of it: doing anyt

Re: Unable to use contrib

2009-10-06 Thread Alex Osborne
vishy wrote: > user=> (require 'clojure.contrib.math) > nil > user=> (lcm 4 5) > java.lang.Exception: Unable to resolve symbol: lcm in this context > (NO_SOURCE_FILE:2) The problem is that "require" only loads the math library, it doesn't "refer" to it. This means that you have to qualify lcm w

Re: Basic questions

2009-10-08 Thread Alex Osborne
vishy wrote: > How can I find out all the namespaces in a library like > clojure.contrib. I assume you mean doing this at the REPL or OS shell. I don't know how to do it for non-loaded libs, aside from manually walking the classpath, but (all-ns) might be what you want for loaded namespaces.

Re: Duplicated keys in maps

2009-10-11 Thread Alex Osborne
On Oct 12, 11:55 am, Angel Java Lopez wrote: > I just discovered that maps support duplicated keys: > What is the rationale behind this behaviour? No, maps don't support duplicate keys. What you're seeing is due to an implementation detail in how array-maps are created from literals. You'll not

Re: Unable to resolve var

2009-10-11 Thread Alex Osborne
gL wrote: > The solution only works with a var name that equals to a Clojure name > (here "max"). That's because (binding) only works with a var that already exists, it doesn't create a new one. To create your own var (instead of abusing a clojure core one) just use "with-local-vars" instead o

Re: JVM Language Summit talk on state, identity, time

2009-10-16 Thread Alex Osborne
Garth Sheldon-Coulson wrote: > In his blog post Rich mentioned his JVM Language Summit talk > on state, identity, value, time, etc. > > Does anyone know if audio or video was recorded, or (if Rich is reading > this) if there are more comprehensive notes to be gotten? The conclusion of it is her

Re: difference between into & concat

2009-10-18 Thread Alex Osborne
DemAS wrote: > I'm just wondering if there is any difference between 'into' and > 'concat' ? There are actually more differences than similarities in my opinion. For starters, 'concat' can take more than 2 arguments: (concat [1 2] [3 4] [5 6]) => (1 2 3 4 5 6) 'into' returns whatever col

Re: Best way to run multiple filters on the same [lazy] collection?

2009-10-18 Thread Alex Osborne
Meikel Brandmeyer wrote: > Maybe you can do: > > (reduce (fn [[sales upgrades demo :as v] data] >(cond > (is-sales? data) [(conj sales data) upgrades demo] > (is-upgrade? data) [sales (conj upgrades data) demo] > (is-demo? data)[sales upgra

Re: Best way to run multiple filters on the same [lazy] collection?

2009-10-18 Thread Alex Osborne
Alex Osborne wrote: > If the three output lists themselves are too large, I'd just explicitly > sum your units with reduce: > > (reduce > (fn [counts data] > (let [type (record-type data)] > (assoc counts type (+ (units data) >

Re: ANN: Clojure live-repl

2009-10-18 Thread Alex Osborne
David Powell wrote: > It uses the Java Attach API to let you connect a Clojure REPL to any running > Java or Clojure process, without them requiring any special startup. Exceedingly cool! > It probably requires a Sun 1.6 JDK. And currently the startup script is a > batch file, so if anyone ca

Re: Best way to run multiple filters on the same [lazy] collection?

2009-10-18 Thread Alex Osborne
Dmitry Kakurin wrote: > I actually like your "tag them then group them" approach. > But what if the same record can have multiple tags? > E.g. :sales and :upgrades? > Hmmm. the first way that occurred to me is just make your tagging function return a set: (defn record-types [x] (disj #{(w

Re: Using synchronized keyword

2009-10-18 Thread Alex Osborne
Gorsal wrote: > I was wondering how to used the java keyword synchronized in clojure? http://clojure.org/api#locking Java: synchronized(foo) { ... } Clojure: (locking foo ...) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Googl

Re: Printing to *out* in another thread

2009-10-18 Thread Alex Osborne
mbrodersen wrote: >> Using atoms is not a good idea. Unless you don't mind if the same >> message is sometimes printed more than once. Atoms are implemented >> using spin locks with automatic retry. > > Hmmm...unless add-watch => observer is called only once. Looking in clojure/lang/Atom.java:

Re: agents swallowing exceptions?

2009-10-19 Thread Alex Osborne
Raoul Duke wrote: > apparently one has to manually write ones agents to log the exceptions > out to stderr or stdout? i guess my personal principle of least > surprise implementation would have been to at least spit out the first > exception once. The problem is where do you throw the exceptions?

Re: data structures for efficient range queries

2009-10-19 Thread Alex Osborne
nchubrich wrote: > I need to make a data structure for a query such as "find everything > that is priced $3.27 - $6.12" (and perhaps sum up the total revenue > for all items in that price range). That's one of the things sorted maps are for: (let [objects-by-price (sorted-map 0.50 :cookie, 5.0

Re: data structures for efficient range queries

2009-10-19 Thread Alex Osborne
Alex Osborne wrote: > nchubrich wrote: >> I need to make a data structure for a query such as "find everything >> that is priced $3.27 - $6.12" (and perhaps sum up the total revenue >> for all items in that price range). > > > That's one of the thin

Re: Redirecting Output

2009-10-19 Thread Alex Osborne
Gorsal wrote: > I'm trying to redirect the input i receive from a BufferedInputStream > to the repl. I'm trying something like this: > > (defmacro with-thread [nm & body] > `(let [thread# (Thread. (fn [] (do ~...@body)))] > (if ~nm (.setName thread# ~nm)) > (.start thread#) > thread#

Re: sequence manipulation question

2009-10-19 Thread Alex Osborne
Dmitri wrote: > I notice that certain sequence operations such as concat and cons will > not retain the original type of sequence, for example if you combine > two vectors together a list will be returned: > > user=> (concat [1 2] [3 4]) > (1 2 3 4) > > is this intentional behavior, and wo

Re: sequence manipulation question

2009-10-19 Thread Alex Osborne
Oops, looks like the end of my message got cut off. Appended below. Alex Osborne wrote: > Dmitri wrote: > > I notice that certain sequence operations such as concat and cons will > > not retain the original type of sequence, for example if you combine > > two vectors to

Re: b:vimclojure_namespace does not exist

2009-10-19 Thread Alex Osborne
I'm not really a vim user, but I just tried this out as I was curious to see what vimclojure was like. It sounds like the nailgun server can't find clojure.jar, try checking the classpath you're using to launch the server. I get the exact same error if I set a bad classpath on purpose. eyeri

Re: Redirecting Output

2009-10-20 Thread Alex Osborne
John Harrop wrote: > On Tue, Oct 20, 2009 at 12:07 AM, Alex Osborne <mailto:a...@meshy.org>> wrote: > > Gorsal wrote: > > However, this raises the CPU to about 50 percent. This is due to the > > infinite recursion, I'm assuming? > >

Re: Best way to run multiple filters on the same [lazy] collection?

2009-10-20 Thread Alex Osborne
Dmitry Kakurin wrote: > Thanks Alex, this is a VERY elegant solution. Hehe. I think I got a bit carried away generalising mine, but I found it interesting. :-) I think your way or Meikal's juxt (which is really neat, I didn't know about juxt) is much better for this specific problem. I gues

Re: Best way to run multiple filters on the same [lazy] collection?

2009-10-20 Thread Alex Osborne
Dmitry Kakurin wrote: >> Stylistic: you should not put the closing parens on dedicated lines. >> They are normally collected on the last line. While this is only a >> style issue, you should get used to it, since 99.9% of all code at in >> the wild will use that style... > > I've read it many tim

Re: Private multimethods possible?

2009-10-22 Thread Alex Osborne
samppi wrote: > Are private multis possible? I notice that clojure.contrib.def does > not have a defmulti-, which doesn't bode well, but it's still worth a > question at the mailing list. Yes, you can make any symbol private. If you look at the definition of defn- you'll see all it does is set

Re: Private multimethods possible?

2009-10-22 Thread Alex Osborne
> So you could do the same when defining a multimethod, just give the > name (symbol) of the method the metadata ":private" with the value > "true": > > (defmulti #{:private true} my-multi my-dispatch) I'm having a bad day for typos, the example should of course be: (defmulti #^{:private true}

Re: Private multimethods possible?

2009-10-22 Thread Alex Osborne
John Harrop wrote: > I think we need some notion of semi-private as well. It would be ignored > by :use and by automation like tab-completion of symbols, doc > generation, and the like (except it would show in tab-completion inside > of its namespace) but would not actually be illegal to invoke

Re: invoking macros from Java

2009-10-27 Thread Alex Osborne
Jeff Brown wrote: > I can invoke a function using Java code that looks something like this... > > Reader reader = new FileReader("clj/demo.clj"); > Compiler.load(reader); > Var var = RT.var("demo", "add_numbers"); > Object result = var.invoke(4, 7); > System.out.println("Result: " + result); >

Re: Infinite sequences hang sets and maps

2009-10-28 Thread Alex Osborne
John Harrop wrote: > Probably the seq .hashCode should consider only the first N elements > for some maximum N and if two longer (or even infinite) sequences > collide so be it. I strongly disagree. Choosing some arbitrary magic cutoff point just seems cause for trouble and much confusion. Put

Re: Constructing Java Interop calls

2009-10-28 Thread Alex Osborne
Tiago Antão wrote: > Again, the point here is to be able to construct method names (full > call signatures, really) on runtime. > > I am lost. As in newbie clueless :( As others have suggested you need to use either Java's reflection or Clojure's eval. Here's some examples: Using reflection:

Re: cannot cast error java char-array to java string

2009-10-28 Thread Alex Osborne
Chick Corea wrote: > What is wrong with this code? I want to instantiate a Java String > from a Java character-array. > But I want it to be fast, hence the need to cast per the "warn on > reflection" message. > > user=> (set! *warn-on-reflection* true) > true > user=> (new String #^

Re: ANN: Clojure live-repl

2009-10-28 Thread Alex Osborne
David Powell wrote: > >> Under Linux I had to fix the paths in liverepl.sh to include the >> build folder: >> >> java -cp "$LIVEREPL_HOME/build/*:$JDK_HOME/lib/tools.jar" >> net.djpowell.liverepl.client.Main "$CLOJURE_JAR" >> "$LIVEREPL_HOME/build/liverepl-agent.jar" >> "$LIVEREPL_HOME/build/

Re: Java 7, nio, and createFile

2009-10-28 Thread Alex Osborne
youngblood.carl wrote: > When I try and call createFile from clojure: > (.createFile path) > > I get an exception that there is no field named createFile. If I remember correctly variable argument Java methods, which is what that "..." syntax means: abstract Path createFile(FileAttribute...

Re: Infinite sequences hang sets and maps

2009-10-29 Thread Alex Osborne
John Harrop wrote: > On Wed, Oct 28, 2009 at 9:35 PM, Alex Osborne wrote: > > Choosing some arbitrary magic cutoff point just > seems cause for trouble and much confusion. > > For the specific case of hashCode, no; identical values must have > identical hashes but

Re: Newcomer's question about Clojure's compatibility with common lisp

2009-10-29 Thread Alex Osborne
Daniel Simms wrote: > On Thu, Oct 29, 2009 at 4:34 PM, Rayne wrote: >> but I would highly recommend that you just pull it from the github >> repository. > > Especially if you're going to use clojure-contrib ...or is there some > "release" of contrib synch'd to clojure releases that I missed > so

Re: How to make lazy seq from socket input?

2009-10-30 Thread Alex Osborne
timc wrote: > I think I know how to do fileLines, but not socketLines. (Each > received packet should contain one line as it would have been written > to a file, I think). Something like this? (use 'clojure.contrib.duck-streams) (read-lines (.getInputStream socket)) > My problem is not how to

Re: Implementation of zipmap

2009-10-30 Thread Alex Osborne
John Harrop wrote: > Was something wrong with this?: > > (defn my-zipmap > "Returns a map with the keys mapped to the corresponding vals." > [keys vals] > (into {} (map vec (partition 2 (interleave keys vals) > > :) One reason might be that the original zipmap is 5-10 times faster for

Re: Implementation of zipmap

2009-10-30 Thread Alex Osborne
Chouser wrote: > On Fri, Oct 30, 2009 at 11:30 AM, Alex Osborne wrote: >> John Harrop wrote: >>> Was something wrong with this?: >>> >>> (defn my-zipmap >>> "Returns a map with the keys mapped to the corresponding vals." >>> [

Re: idiom questions

2009-10-30 Thread Alex Osborne
Chick Corea wrote: > Is everything in Clojure immutable? Most things. Clojure tries very hard to be thread-safe by default. > how does one modify the value of 'x' ? > > (let [x nil] (def x true)) One does not, at least not in a let-binding. If you really want a lexical variable you

Re: idiom questions

2009-10-30 Thread Alex Osborne
Alex Osborne wrote: > Chick Corea wrote: >> If I understand correctly, the "(binding ...)" macro specifically >> applies to >> "Variables", one of Clojure's STM types, thus has dynamic, thead-local >> scope. Is that right? In which case, it ma

Re: can I make this faster (and leaner) ?

2009-10-30 Thread Alex Osborne
Chick Corea wrote: > The corresponding Java code (w/ the hash-insert omitted in the clojure > version) > runs in 5.5sec and uses 290MB. > > This code runs (which omits the hash-insert) runs in 17.8sec and uses > 353MB. > > I thought that I added all of the casts and "warn-on-reflections" that >

Re: Infinite sequences hang sets and maps

2009-10-31 Thread Alex Osborne
Luke VanderHart wrote: > On Oct 29, 4:01 am, Mark Engelberg wrote: >> I see your point that hashCode could be made to work on infinite >> sequences, but since hashing is almost always a prelude to testing for >> equality, I'm hard pressed to think of an example of why you'd want to >> be able to

Re: update-proxy doc - what is "this" ?

2009-11-01 Thread Alex Osborne
msappler wrote: > user=> (doc update-proxy) > > It says:"the first arg corresponding to this" > > What is meant with "this"? "this" means the proxy object itself (like the "this" keyword in Java). --~--~-~--~~~---~--~~ You received this message because you are s

Re: clojure parser

2009-11-01 Thread Alex Osborne
nchubrich wrote: > Is there any way to access the clojure parser, i.e. something that > gives you all the elements contained in an expression? I.E. (parse (+ > 1 2)) would give you something like [:list [[:symbol +] [:literal 1] > [:literal 2]]]. Do you mean the reader? user=> (read-string "(+

Re: A couple questions about the language

2009-11-01 Thread Alex Osborne
Andrew wrote: > 1. Can I have compile time evaluation forms like in Lisp? For example, > I want to obtain current namespace during macro expansion, or make > Java imports in compile time. Is it possible? Unless I'm misunderstanding what you want, sure. Just access *ns* or (import 'whatever) in

Re: Generalizing -> & ->>

2009-11-02 Thread Alex Osborne
Sean Devlin wrote: > This is slightly unrealted, but how does one pronounce ->, ->> and the > like? Is this documented? The doc-strings usually give you a nice hint. I usually use "thread" for -> and "thread last" for ->>. The actual symbols I think of as "arrow" and "double arrow". Then -?

Re: Running out of memory when using loop/recur and destructuring

2009-11-02 Thread Alex Osborne
Paul Mooser wrote: > Good job tracking down that diff -- upon looking at it, unfortunately, > I obviously don't understand the underlying issue being fixed (the > inter-binding dependencies) because the "old code" basically matches > what I would think would be the way to avoid introducing this in

Re: Adding meta data to a function (from a macro)

2009-11-07 Thread Alex Osborne
Stefan Arentz wrote: > > I'm trying to do this: > > (defmacro my-defn [name & body] >`(defn- #^{ :foo-tag "blah" } ~name [] > ~...@body)) > > The idea is that foo will be defined and that {:foo-tag "blah"} is > added to its meta-data. > > But that does not seem to work: Try this:

Re: Functions and vars and meta-data

2009-11-07 Thread Alex Osborne
Stefan Arentz wrote: > I must admin that I don't fully understand the difference between foo > and #'foo. That is probably why I'm making this beginner mistake :-) The difference takes some explanation. So without further ado... Functions and Metadata: in Vivacious Gory Detail ==

Re: equivalent to Haskell's group function

2009-11-08 Thread Alex Osborne
Wilson MacGyver wrote: > Does Clojure have a function like Haskell's group? > > In Haskell, > Input: group [1,2,2,1,1,1,2,2,2,1] > Output: [[1],[2,2],[1,1,1],[2,2,2],[1]] (use 'clojure.contrib.seq-utils) (partition-by identity [1 2 2 1 1 1 2 2 2 1]) => ((1) (2 2) (1 1 1) (2 2 2) (1)) --~--~---

Re: Consistency of the API

2009-11-09 Thread Alex Osborne
Mark Engelberg wrote: > 2009/11/9 Tiago Antão : >> What is the rationale for even? and contains? having different >> behaviors for the exact same error (ie, one throws the other works >> fine and just returns false on a type error)? > I imagine the rationale is efficiency. Here's the function

Re: How to convert java Complex type to Clojure type?

2009-11-09 Thread Alex Osborne
Michael Jaaka wrote: > How to convert HashMap to Clojure map, sorted-map, > tree-map > > How far I'm able only to do it with > > (let [a (HashMap. { "abc" "def"}) ] >(zipmap (keys a) (vals a))) > > Note that HashMap. { ... } is here only as example, cause in fact it > is a result from J

Re: Understanding Clojure Closures

2009-11-11 Thread Alex Osborne
mbrodersen wrote: > In this simple recursive expression: > > (def t (fn [x] (if (zero? x) 0 (+ x (t (dec x)) > > The fn special form is evaluated within a context where t is not yet > bound. > > t is only bound AFTER fn has captured its environment. > > In other words, the closure captured

Re: How to print without spaces?

2009-11-11 Thread Alex Osborne
John Ky wrote: > How to I print without spaces? (println (str "a" "b" "c")) -- 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 patie

Re: How to write a macro

2009-11-11 Thread Alex Osborne
John Ky wrote: > Hi all, > > I'm looking for a way to write a defkw macro so that (defkw ABSENT) > expands to > (def ABSENT (kw "ABSENT" :ABSENT )). > Just use `(...) as a template and use ~ to unescape, like so: (defmacro defkw [sym] `(def ~sym (kw ~(str sym) ~(keyword sym (defkw ANSE

Re: How to write a macro

2009-11-11 Thread Alex Osborne
John Ky wrote: > I had to ~(keyword (str sym)) instead of ~(keyword sym), but now it > works well. Hmm, odd. Must have changed since Clojure 1.0. (keyword 'some-symbol) works for me on the "new" branch. -- You received this message because you are subscribed to the Google Groups "Clojure" gr

Re: clojure event handling

2009-11-11 Thread Alex Osborne
nchubrich wrote: > I'm curious what the best idiomatic way of handling events is (e.g. > receiving a series of messages and dispatching functions on the basis > of the messages). One could use the 'experimental' add-watch(er) > functions. But it might also be nice to do something stream-oriented,

Re: Datatypes and Protocols - early experience program

2009-11-13 Thread Alex Osborne
Mark Engelberg wrote: > Protocols: > > I don't understand whether there's any way to provide a partial > implementation or default implementation of a given > protocol/interface, and I believe this to be an important issue. > > For example, a protocol for < and > that provides a default > impleme

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-15 Thread Alex Osborne
ajuc wrote: > I would like to somehow hide the global hilbert-map into my function, > but I can't see how to do that. > > Is this possible? I know that I can just inert literal into my let, > but that degrades performance, when function is called many times. > > I would like to have something lik

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-15 Thread Alex Osborne
John Harrop wrote: > On Sun, Nov 15, 2009 at 7:32 PM, Alex Osborne <mailto:a...@meshy.org>> wrote: > > ajuc wrote: > > I would like to somehow hide the global hilbert-map into my function, > > but I can't see how to do that. > > Cloj

Re: Proposal: Extend behavior of hash-map

2009-11-17 Thread Alex Osborne
Sean Devlin wrote: > Hey everyone, > I was working with an object that implements java.util.Map today, and > I had to turn it into a Clojure map. > > http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html > > I cam up with this utility fn > > (defn read-map > "Designed to turn a java.util.

Re: Proposal: Extend behavior of hash-map

2009-11-17 Thread Alex Osborne
Sean Devlin wrote: > Okay golfers. Is there a better way to do this? > > (defn put-all! > [java-map clj-map] > (do > (doseq [entry clj-map] > (.put java-map (key entry) (val entry))) > java-map)) > > user=>(put-all (java.util.HashMap. ) {:a 1 :b 2 :c 3}) > # > > I already

Re: Proposal: Extend behavior of hash-map

2009-11-17 Thread Alex Osborne
Alex Osborne wrote: > Sean Devlin wrote: >> Okay golfers. Is there a better way to do this? >> >> (defn put-all! >> [java-map clj-map] >> (do >> (doseq [entry clj-map] >> (.put java-map (key entry) (val entry))) >> java-map

Re: Stack overflow while processing XML

2009-11-18 Thread Alex Osborne
mkrajnak wrote: > I am processing a very large xml file, 13MB, using clojure.xml.parse > and clojure.contrib.zip-filter.xml with clojure 1.0.0. clojure.xml.parse loads the whole document into memory at once so it's only really suitable for small (at most a megabyte or two) XML documents. Have a

[ANN] Clojars - a Clojure community jar repository

2009-11-19 Thread Alex Osborne
I've been working on an easy to use open source community repository to complement Leiningen in making building and dependency management easier for Clojure projects. http://clojars.org/ It's inspired by the fantastic Gemcutter.org website that the Ruby community uses. The repository is in th

Re: [ANN] Clojars - a Clojure community jar repository

2009-11-19 Thread Alex Osborne
Alex Osborne wrote: > But if even that's too long and complicated for you I wrote a Leiningen > plugin which makes it just: > > lein push Looks like JSch library that the lein-clojars plugin uses doesn't work with ssh-keygen's DSA keys and I overlooked adding passp

Re: [ANN] Clojars - a Clojure community jar repository

2009-11-19 Thread Alex Osborne
Laurent PETIT wrote: > Hello, > > Just an idea out of my head : could it be possible for the pom.xml to be > included in the jar, in the META-INF/ directory ? > > This would even further simplify the process, wouldn't it ? :) That's a great idea! Can't believe it didn't occur to me. :-) I loo

Re: leiningen - a Clojure build tool

2009-11-19 Thread Alex Osborne
meb wrote: > Was the name Leiningen inspired by the Esquire short story "Leiningen > vs. Ants"? That would be a brilliantly obscure way to challenge the > predominance of ant. Or did you have another reference in mind. From the Leiningen README: "Leiningen!" he shouted. "You're insane! They're

Re: positions

2009-11-19 Thread Alex Osborne
ajuc wrote: > On 20 Lis, 01:49, nchubrich wrote: >> While we're on the topic, where is something like (subtract [1 2 3 3 4 >> 4 5 6] evens) -> (1 3 3 5)? Doesn't seem to be in seq-utils or API. >> Seems like there should be a parallel "multiset" library for colls, to >> clojure.set. (I guess the

Re: positions

2009-11-19 Thread Alex Osborne
John Harrop wrote: > On Thu, Nov 19, 2009 at 7:00 PM, Sean Devlin > wrote: > > That's why there are two separate functions do do what you suggest > > user=>(interleave [1 2 3 4] [1 2 3 4]) > (1 1 2 2 3 3 4 4) > > user=> (concat [1 2 3 4] [1 2 3 4

Re: positions

2009-11-19 Thread Alex Osborne
John Harrop wrote: > This is just (sort (concat [1 2 3 4 5 6 7] [3 2 7])) though. > > > I think he also wants the original order of the first input coll to be > preserved, though. Sort wouldn't do that. Hmmm.. that's a pretty weird set of requirements. Usually a multiset/bag is unordered

Re: Weird Java Interop Behaviour

2009-11-20 Thread Alex Osborne
Matt Brown wrote: > Why does (. System getProperty "java.version") work when > (. (identity System) getProperty "java.version") does not work, given > that > (identity System) should be the same as System ? It's because the . special form treats class names specially. In Java there's unfortunat

Re: One place where interop needs improvement

2009-11-21 Thread Alex Osborne
John Harrop wrote: > 1: Improvements to the ns macro, such as described in a previous thread. > Particularly I'd like to see > > (:import package class class class) > > work. This fits with normal Clojure syntax. Right now it wants an extra > pair of parentheses, does not accept a vector(!), a

Re: One place where interop needs improvement

2009-11-21 Thread Alex Osborne
John Harrop wrote: > On Sat, Nov 21, 2009 at 9:03 PM, Alex Osborne > (:import package1 class class class) (:import package2 class class) > > > I am. Especially since the latter already works. > > Alternatively, force (or at least allow!) square brackets, like > els

Re: leiningen - a Clojure build tool

2009-11-22 Thread Alex Osborne
bOR_ wrote: > What is the normal way to let Leiningen know about local jars? I am > using brics automaton in one of my projects, and that jar is only > downloadable after confirming the bsd licence (http://www.brics.dk/ > automaton/), so I have it locally on my disk, but it isn't in clojars > or mv

Improving Clojure startup time with -Xbootclasspath

2009-11-22 Thread Alex Osborne
We were discussing Clojure startup time (in the context of Leiningen) and Phil Hagelberg asked some JRuby people about startup time. They suggested using -Xbootclasspath. Check this out: % time (echo | java -client -cp clojure.jar clojure.main) 0.84s user 0.04s system 96% cpu 0.908 total % ti

Re: leiningen - a Clojure build tool

2009-11-23 Thread Alex Osborne
Krukow writes: > On Nov 18, 8:29 am, Phil Hagelberg wrote: >> I'm pleased to announce the initial release of Leiningen. >> >> Leiningen is a build tool for Clojure designed to not set your hair on fire. > > I really like it so far - particularly the combination of lein and > clojars! > > I'm not

Re: Functions and vars and meta-data

2009-11-27 Thread Alex Osborne
Stefan Kamphausen writes: > On Nov 8, 3:46 am, Alex Osborne wrote: > As far as the documentation says, Vars can't have metadata: > > "Symbols and collections support metadata," -- http://clojure.org/metadata > > "Symbols, Lists, Vector, Sets and Maps can

Re: combining vimclojure, classpaths and leiningen

2009-11-27 Thread Alex Osborne
bOR_ writes: > I think I cannot escape spelling out the ~/.m2/paths to clojure.jar > and clojure-contrib.jar in vimclojures' local.properties file, but is > there any way I can get start the nailgun server from my projects' > directory and it just takes ./lib as its classpath? java -cp 'src:clas

Re: Functions and vars and meta-data

2009-11-27 Thread Alex Osborne
Stefan Kamphausen writes: >> I don't think the documentation is *wrong* per se, it just only seems to >> cover the immutable types. > > Which is kind of wrong, isn't it? I strongly believe that this should > be changed. Indeed. > While I understand that the mutating functions will not apply to

Re: Functions and vars and meta-data

2009-11-27 Thread Alex Osborne
Stefan Kamphausen writes: >>   (meta '#^{a 1} greet) > > To be honest, I think it looks even worse. There is some reader macro > which by happy accident works in a certain way together with the other > read syntax. No, I don't think it should work. I agree this is ugly and unintuitive and I wo

Re: 'cheap' embedded dbs?

2009-11-30 Thread Alex Osborne
Raoul Duke wrote: > what do people use for doing in-memory simple dbs? like, do people > just use persistent maps, or do they go out and use derby or > something? > Sean Devlin's suggested a contrib library which adds a bunch of functions for working with maps. Have a look at this thread on the

Re: Leiningen Run ?

2009-11-30 Thread Alex Osborne
Hi David, David Nolen wrote: > So my Java ignorance once again rears it's ugly head. It turns out > that JNI dynamic libs can't really be part of a .jar. I can't say I know much about JNI but I've used some libraries like SQLiteJDBC and Qt Jambi which bundle the native libraries in the jar, so th

Re: clojars and licences

2009-12-01 Thread Alex Osborne
bOR_ writes: > How in clojars do I attach a licence to the jar? I'm about to > redistribute a BSD-licensed jarfile to clojars, but I'm not sure how I > can make sure that the licence also gets redistributed. Are these > things embedded in jar files by default? I think it's quite common to put th

Re: clojars and licences

2009-12-01 Thread Alex Osborne
bOR_ writes: > How in clojars do I attach a licence to the jar? I'm about to > redistribute a BSD-licensed jarfile to clojars, but I'm not sure how I > can make sure that the licence also gets redistributed. Are these > things embedded in jar files by default? > > (the jar in question is automato

Re: Clojure as a first programming language?

2009-12-01 Thread Alex Osborne
I think it's hard for anyone experienced in subject to give a recommendation on how to get started, as there's just so much knowledge you always assume. Maybe if you've tried teaching programming using a variety of languages you can. I'm a little younger than the C64 guys, I first taught mysel

Re: Modeling a relation: maps or vectors, one ref or many refs

2009-12-04 Thread Alex Osborne
samppi writes: > I want to create a little Clojure library that creates cached > relational systems in the style of Ben Moseley's "Out of the Tar > Pit" (http://web.mac.com/ben_moseley/frp/paper-v1_01.pdf), which is > something that I think would serve me better than just nested maps for > someth

Re: Hooks library. (Is this clojure-y?)

2009-12-06 Thread Alex Osborne
Allen Rohner writes: > I started playing with the idea of a hooks library for Clojure, > similar to Emacs hooks. > > You can see the code at http://gist.github.com/250575 > > Does this library have the Tao of Clojure? > > If hooks aren't a clojure-y way of doing things, what is? Have you seen Ja

Re: how 'bout a debug-repl?

2009-12-09 Thread Alex Osborne
George Jahad writes: > Every time I stick a println into some Clojure code to debug it, I > think to myself, "This is Lisp! I should be able to insert a repl > here!" > > The problem is of course that Clojure's eval function doesn't know > about the surrounding lexical scope. So I started asking

Re: zipper for JSON data?

2009-12-12 Thread Alex Osborne
Paul_B_Hansen writes: > I tried to simply get a zipper working for nested > maps but I didn't succeed. My attempt is below: > > (defn map-zip [root] > (zip/zipper map? > seq > (fn [node children] (with-meta (hash-map children) (meta > node))) > root))

Re: zipper for JSON data?

2009-12-12 Thread Alex Osborne
"Alex Osborne" writes: > (-> (map-zip {:foo {:bar {:baz 2}}}) > zip/down > zip/down > (zip/insert-right [:greeting "Hello!"]) > zip/down > (zip/edit (val-editor inc)) > zip/root) > > ;; => [:root {:foo {:greeting &qu

Re: boolean-array in clojure

2009-12-12 Thread Alex Osborne
Michael Wood writes: > I don't think boolean-array exists in 1.0. Try this instead: > > user=> (into-array Boolean [true true false true]) > # > > although that gives you an array of Booleans instead of booleans. (into-array Boolean/TYPE [true false]) ;; => # -- You received this message beca

Re: Boggle solver

2009-12-14 Thread Alex Osborne
james writes: > Using the -Xprof switch seems to indicate java.lang.Character.hashCode > is called a lot and i guess that's to do with the nested maps that > represent the trie. > > Using jvisualvm doesn't help much either as it's not giving me a call > graph. > Just self counts for each function

Re: Clojure analysis

2009-12-17 Thread Alex Osborne
Santhosh G R writes: >> > Clojure is a multi-paradigm language >> no it's not, and it's most certainty not an OOP >> language:http://clojure.org/rationale > > I hear about this everywhere. Is Clojure not a multi-paradigm language > because that is the rationale for the language? For me - It supp

Re: mapmap

2009-12-17 Thread Alex Osborne
Avital Oliver writes: > My experience is that you should only use filter/map if you either have a > pre-existing function or you want to use a _very_ short closure (using #()). > For any other case the code becomes unmanageable and then I feel that using > for > is the wiser choice. I agree, bu

Re: Parenthesis Inference

2009-12-18 Thread Alex Osborne
Martin Coxall writes: > My question is this: why can't we introduce a simple and importantly, > optional 'off-side rule' (much simpler than Haskell's) that allows the > reader to infer many of the parentheses? If you haven't seen them before, check out sweet expressions. This guy has put a lot

Re: leiningen with latest clojure

2009-12-18 Thread Alex Osborne
defn writes: > On Dec 18, 7:00 am, Andrea Tortorella wrote: >> I'd like to ask how to use leiningen with the latest clojure >> development new branch, is this possible? > This will pull down 1.1.0-master-SNAPSHOT per the settings in > project.clj which is as new as Dec. 18th, 16:00 at the time o

Re: Parenthesis Inference

2009-12-18 Thread Alex Osborne
Anniepoo writes: > What's hostile to most programmers is that Clojure demands a lot more > thinking per line of code. I remember when OO came in, and then when > design patterns came in - each decreased the amount of thinking about > code and increased the amount of typing. *shudder* Yes, this

Re: new fn: juxt - Theory & application

2009-12-18 Thread Alex Osborne
Just tossing up some non-juxt alternatives for comparison's sake, so we can see where it is an improvement. Sean Devlin writes: > Notice that juxt creates a closure. The most straightforward case is > to *predictably* access multiple values from a map. > > user=>(def test-map {:a "1" :b "2" :c

Re: Maven2 repo URL required for Clojure 1.1 RC

2009-12-19 Thread Alex Osborne
Shantanu Kumar writes: > Could anybody please give me a Clojure 1.1 Maven2 repo URL? It's not > there on Maven central repo yet, and (surprise!) clojars.org doesn't > seem to have it either. http://build.clojure.org/snapshots/ -- You received this message because you are subscribed to the Goog

Re: Parenthesis Inference

2009-12-19 Thread Alex Osborne
Martin Coxall writes: > I trust the many, many more people that have rejected Lisp for its > hostile syntax and delusions of importance than the statistically > insignificant minority who have actually stuck with it. Sometimes people are just looking for excuse to criticize. Before it was cons

  1   2   3   >