Do not understand why loop takes 3 arguments who are all the same

2014-05-03 Thread Roelof Wobben
Hello, Im now at the last exercise of the beginners exercise of 4clojure. I figured out that this solution works. (fn [default lijst1] (loop [lijst lijst1 d {}] (if (empty? lijst) d (recur (rest lijst) (assoc d (first lijst) default) But as I see it lijst lijst 1 and d

Re: Do not understand why loop takes 3 arguments who are all the same

2014-05-03 Thread Bob Hutchison
Hi Roelof, On May 3, 2014, at 3:09 AM, Roelof Wobben wrote: > Hello, > > Im now at the last exercise of the beginners exercise of 4clojure. nice! > > I figured out that this solution works. > > (fn [default lijst1] > (loop [lijst lijst1 d {}] > (if (empty? lijst) >d >

NoClassDefFoundError when AOT compiling namespace using protocol

2014-05-03 Thread Colin Fleming
Hi all, I'm having a strange problem when AOT compiling some code I just added. I have a namespace that, amongst other things, returns qualified names of things: (ns plugin.names ...) (defprotocol QualifiedNamed (qualified-name ^String [this])) (extend-protocol QualifiedNamed nil (quali

Re: Do not understand the -> macro here

2014-05-03 Thread Michael Wood
That whole form is not something you would be likely to write. I think the exercise is just trying to demonstrate that the version with the -> is equivalent to the version without the arrow and perhaps also that (= a b c) can be used instead of (and (= a b) (= b c)). -- Michael Wood On 01 May 201

Re: Do not understand why loop takes 3 arguments who are all the same

2014-05-03 Thread Roelof Wobben
> > > (fn [default initial-keys] > (loop [remaining-keys initial-keys > result-map {}] > (if (empty? remaining-keys) >result-map >(let [key (first remaining-keys) > remaining-keys' (rest remaining-keys) > result-map' (as

Re: Do not understand why loop takes 3 arguments who are all the same

2014-05-03 Thread Bob Hutchison
On May 3, 2014, at 6:42 AM, Roelof Wobben wrote: > > (fn [default initial-keys] > (loop [remaining-keys initial-keys > result-map {}] > (if (empty? remaining-keys) >result-map >(let [key (first remaining-keys) > remaining-keys' (rest

Re: [ANN] packthread 0.1.0

2014-05-03 Thread Jason Felice
Hi! I'm pretty familiar with legal license stuff (though IANAL). I wouldn't mind considering changing it at the point where someone wants to use it but can't - because that would carry with it a specific reason we can think about. -Jason On Fri, May 2, 2014 at 3:03 PM, James Reeves wrote: >

Re: Managing State Changes, using Component

2014-05-03 Thread Timothy Washington
Hey, thanks for responding. My responses are inlined. On Thu, May 1, 2014 at 1:34 AM, Atamert Ölçgen wrote: > I am not an expert on Component. But AFAIK it is not for managing mutable > state but for assembling and configuring components, that might or might > not be mutable themselves, in an i

Re: Converting sequence from sort into a list

2014-05-03 Thread Dave Tenny
After nosing around all I've come up with via clojure mechanisms is to use (apply list (sort ...)). It seems to work well enough for lists of arbitrary size (subject to usual memory/size limitations of large lists). I also considered some native java abuse such as java.util.Arrays.asList(Enumerati

Re: difference in behavior for :let modifiers in "for" vs. "doseq"

2014-05-03 Thread Xfeep Zhang
user> (for [ b '(1 2 3) :let [a 1] ] (println a b)) is OK. On Thursday, May 1, 2014 12:39:22 PM UTC+8, Yuri Niyazov wrote: > > Hello everyone, > > In Clojure 1.6: > > user> (doseq [:let [a 1] b '(1 2 3)] (println a b)) > 1 1 > 1 2 > 1 3 > nil > user> (for [:let [a 1] b '(1 2 3)] (println a b))

Clojure equivalent of special common lisp vars: still looking for that zen place...

2014-05-03 Thread Dave Tenny
I'm still struggling with how to write the most readable, simple clojure code to deal with dynamically bindings. What is the graceful clojure equivalent of common lisp special variables for the following scenario. If I were writing common lisp I'd just do something like (pardon if my lisp is r

Re: [ANN] packthread 0.1.0

2014-05-03 Thread James Reeves
Some software companies, particularly larger ones, are careful about the licenses of software they use in their products. With a standard open source license it's often easy to get approval, because licenses like MIT are very common. Software with a custom license is trickier, because it's not a c

Re: [ANN] packthread 0.1.0

2014-05-03 Thread Jozef Wagner
Thanks for releasing this library. How does it compare to the synthread library [1] [2] ? Seems like both libraries have the same goal. Jozef [1] https://github.com/LonoCloud/synthread [2] http://www.infoq.com/presentations/Macros-Monads -- You received this message because you are subscribed

Re: Clojure equivalent of special common lisp vars: still looking for that zen place...

2014-05-03 Thread Bob Hutchison
On May 3, 2014, at 9:45 AM, Dave Tenny wrote: > I'm still struggling with how to write the most readable, simple clojure code > to deal with dynamically bindings. > > What is the graceful clojure equivalent of common lisp special variables for > the following scenario. > > If I were writing c

Re: Clojure equivalent of special common lisp vars: still looking for that zen place...

2014-05-03 Thread Lee Spector
On May 3, 2014, at 9:45 AM, Dave Tenny wrote: > > The way I'm tempted to do this in clojure is > > (def ^{:dynamic true} *x* (atom 1)) > ... do stuff with @*x* ... > (reset! *x* 2) > ... do stuff with @*x* ... > (binding [*x* (atom 3)] (do stuff with @*x*)) Having also come from Common Lisp a

Re: Clojure equivalent of special common lisp vars: still looking for that zen place...

2014-05-03 Thread Dave Tenny
On Sat, May 3, 2014 at 10:53 AM, Bob Hutchison wrote: > You can also just use ‘def’ to redefine the global binding. Thanks, though in this case it's a mixed use. In some cases I want to change the root of the global binding, in others I want to rebind to a new value in some context without cha

Re: Clojure equivalent of special common lisp vars: still looking for that zen place...

2014-05-03 Thread Dave Tenny
re: binding behavior, I've only been using clojure since 1.5.1, but in my travels I get the impression that the binding form didn't always enforce the variable to be declared dynamic, and so maybe didn't behave the way you'd expect if the ^:dynamic was missing from the target of the binding form.

How aliased "require" is different?

2014-05-03 Thread Petr
Hello. I experienced non obvious behavior of "require namespace as alias" when using clojure.tools.namespace.repl/refresh. If I use aliased namespace then after changing source files and call to refresh I seem to have old values in that alias. If I use plain require all seem to work as expected

Code Genres

2014-05-03 Thread Gregg Reynolds
The recent threads on documentation lit a small fire under my butt so I started a Code Genres repo. For the moment it is there mainly for the wiki, which I offer as a place for any interested parties to contribute ideas, requirements, etc. I've posted a l

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-03 Thread Val Waeselynck
All right, I'll give it a try, here are some thoughts : I think it's too hard make precise requirements for advanced features in advance; I'd rather find a way to let usage drive us in the right direction. However, there are a few principles that we know will be wise to follow : - encouragi

Basic question: metadata reader

2014-05-03 Thread Angel Java Lopez
I'm trying to implement in my clojure interpreter (in c#) the metadata reader. I read in core.clj something like (ns ^{:doc "The core Clojure language." :author "Rich Hickey"} clojure.core) I just read: http://clojure.org/reader - Metadata (^) Metadata is a map associated with s

Re: Basic question: metadata reader

2014-05-03 Thread James Reeves
The metadata is attached to the symbol, before the form is evaluated. You can see this with a macro: (defmacro foo [x] (meta x)) (foo ^:bar baz) ;=> {:bar true} The with-meta function attaches metadata to the value the symbol evaluates to. - James On 3 May 2014 22:10, Angel Java Lopez w

Re: Basic question: metadata reader

2014-05-03 Thread Andy Fingerhut
Note that if you try the same sequence you gave in your examples *without* metadata, you would get very similar results: (def one 1) one ;; evaluates to 1 bar ;; exception with message "Unable to resolve symbol: bar" The exception is because bar has not been def'd before. Andy -- You received

Re: Basic question: metadata reader

2014-05-03 Thread Stephen Gilardi
> I just read: > > http://clojure.org/reader > > Metadata (^) > Metadata is a map associated with some kinds of objects: Symbols, Lists, > Vector, Sets, Maps, tagged literals returning an IMeta, and record, type, and > constructor calls. The metadata reader macro first reads the metadata and >

Re: Basic question: metadata reader

2014-05-03 Thread Angel Java Lopez
Ah! Thanks to all. Yes, I was a bit confused, thinking ^ expands as ' (quote), to use (with-meta..). But there is not expansion. It really applies the map to the next read form, expecting the read form implements IObj: public interface IObj extends IMeta { public IObj withMeta(IPersistentMa

Achieving structural sharing when composing data

2014-05-03 Thread Mike Fikes
Are there common techniques or idioms for achieving structural sharing when composing data where equivalences exist? (My motivation is to reduce heap usage for a particular problem I'm working on that involves a lot of repeated data.) As a specific example, consider sharing equivalent map value

deep thinking

2014-05-03 Thread Tim Daly
I read Simon Parent's thesis, "How Programmers Comment When They Think Nobody's Watching". Simon is analyzing comments in source files. Simon quotes two other sources about comments to try to find a classification scheme. I've quoted the summaries Simon quoted from the sources [1] and [2]. I've in