Re: I don't understand this exception

2011-01-17 Thread Stefan Rohlfing
Dear Meikel and Ken, Thank you very much for your corrections and suggestions! I admit it took a while for me to understand the more sophisticated parts of your code, but on the way I learned quite a lot about the correct usage of conj, assoc, update-in, and fnil! Best regards, Stefan On Jan 17

Re: list* does not make a list?

2011-01-17 Thread LordGeoffrey
The docs don't say that it is lazy. How (as a newbie) can i tell that it is lazy? Docs: "Creates a new list containing the items prepended to the rest, the last of which will be treated as a sequence." On 17/01/11 06:27, Sean Allen wrote: the documentation on that could be improved. the doc

Re: list* does not make a list?

2011-01-17 Thread Meikel Brandmeyer
Hi, On 17 Jan., 11:28, LordGeoffrey wrote: > The docs don't say that it is lazy. How (as a newbie) can i tell that it > is lazy? By the words "the last of which will be treated as a sequence". A sequence is (in general) lazy. Hence, what list* returns is actually a sequence and not a list. As m

Re: Enhanced Primitive Support Syntax

2011-01-17 Thread nicolas.o...@gmail.com
On Mon, Jan 17, 2011 at 3:10 AM, chris wrote: > Is it insane to suggest that perhaps clojure should work with scala > such that we can write both languages in the same file? > A lot of reasons for which it is not possible: - it would mean coordinating two implementations/implementers. - it would

Re: Typos in (doc add-watch)

2011-01-17 Thread Jacek Laskowski
On Sun, Jan 16, 2011 at 5:37 PM, Stuart Halloway wrote: > The 'if' is terse, but correct: call is on agent's thread only when reference > is an agent, and before pending sends only when reference is an agent or ref. Ah, it makes sense now. Thanks. I believe it'd be more comprehensible with your

Re: Clojure Quizzes?

2011-01-17 Thread Robert McIntyre
Taking a page out of the python book , I like to include a statement at the end that checks to see if the program is being run as a command-line program and then respond accordingly. As an example, (if (command-line?) (your-awesome-function (read-integer (first *command-line-args* Might

Re: check if something can be coerced to a seq

2011-01-17 Thread Stuart Sierra
The problem with a "seq-able?" predicate is that the definition of what is seq-able is often context-dependent. `seq` works on Strings, but you probably don't want `flatten` to turn a String into a sequence of characters. -S clojure.com -- You received this message because you are subscribed

HPC in scala ..

2011-01-17 Thread Sunil S Nandihalli
Hello Everybody, not directly related to clojure .. but it is interesting to know that scala people got a huge funding to further the state of the art in HPC... http://www.scala-lang.org/node/8579 Sunil. -- You received this message because you are subscribed to the Google Groups "Clojure" gro

Re: check if something can be coerced to a seq

2011-01-17 Thread Jürgen Hötzel
2011/1/17 Stuart Sierra > The problem with a "seq-able?" predicate is that the definition of what is > seq-able is often context-dependent. `seq` works on Strings, but you > probably don't want `flatten` to turn a String into a sequence of > characters. > > Good point. There is no static atom/lis

Euler 14

2011-01-17 Thread Andreas Liljeqvist
Hi. I am using max-key to get the longest sequence from a couple of sequences. (defn cseq [n] (if (= 1 n) [1] (cons n (cseq (if (even? n) (/ n 2) (+ (* 3 n) 1 )) (apply max-key count (map cseq (range 1 100))) This gives me a heap error. To my understan

Create a map from two seqs

2011-01-17 Thread Stuart Popejoy
Greetings, Apologies if this seems like a pointless question but a) searches were fruitless and b) hopefully this is interesting to consider ... I'm wanting to create a map from two seqs (:keys and values), and it seems surprisingly tricky. I would rather not use hash-map, but if I did the follo

Re: Create a map from two seqs

2011-01-17 Thread Sam Aaron
Hi Stuart, I believe you might looking for zipmap: - clojure.core/zipmap ([keys vals]) Returns a map with the keys mapped to the corresponding vals. This is used as follows: user=> (zipmap [:a :b :c] [[1 2] [3 4] [5 6]]) {:c [5 6], :b [3 4], :a [1 2]} There are a lot

Re: Enhanced Primitive Support Syntax

2011-01-17 Thread chris
Yeah yeah! http://www.google.com/search?q=lisp+type+inference Chris On Jan 17, 5:55 am, "nicolas.o...@gmail.com" wrote: > On Mon, Jan 17, 2011 at 3:10 AM, chris wrote: > > Is it insane to suggest that perhaps clojure should work with scala > > such that we can write both languages in the same

Re: Create a map from two seqs

2011-01-17 Thread Michael Ossareh
On Mon, Jan 17, 2011 at 10:14, Sam Aaron wrote: > > There are a lot of handy functions like this in core but you really need to > know they exist before you can use them. Discovering new ones is always > exciting! > I've found lurking in #clojure on irc to be a great way to find out about the fun

Re: Euler 14

2011-01-17 Thread Mark Engelberg
Your cseq is not lazy, and some of the sequences can be quite long, so it wouldn't surprise me if that's the source of your problem. You can test if this is the problem by doing something like: (dorun (map cseq (range 1 100))) which removes the max-key from the computation entirely. You'll pr

Re: Euler 14

2011-01-17 Thread Andreas Liljeqvist
I don't see why the cseq's have to be lazy, they are at the most 525 elements long. shouldn't each sequence only be produced when it is reduced in max-key and then discarded? But it makes a difference: (defn cseq [n] (if (= 1 n) [1] (lazy-seq (cons n (cseq (if (even? n)

Re: HPC in scala ..

2011-01-17 Thread Tim Daly
Hello Everybody, not directly related to clojure .. but it is interesting to know that scala people got a huge funding to further the state of the art in HPC... http://www.scala-lang.org/node/8579 Sunil. -- You received this message because you are subscribed to the Google Groups "Clojure"

Re: Enhanced Primitive Support Syntax

2011-01-17 Thread Bob Hutchison
Hi Stuart, On 2011-01-15, at 4:06 PM, Stuart Halloway wrote: >> In my experience, errors are the problem and we should be avoiding them, >> almost at all costs. > > This debate always starts by conflating three things into two, and then goes > downhill from there. :-( It isn't > > (a) safe/

best way to define alias for all publics in ns?

2011-01-17 Thread Seth
I have this function which takes all of the publics from one ns and exports them in the current ns. My question is, is this the best way to do it? Is there another method which doesnt use eval? I know eval is supposed to be 'evil ' :) (defn ns-export [from-ns] (map (fn [[sym var]] (let

Re: Enhanced Primitive Support Syntax

2011-01-17 Thread Jason Wolfe
On Jan 16, 6:18 pm, Sean Corfield wrote: > On Sun, Jan 16, 2011 at 3:50 PM, Jason Wolfe wrote: > > Moreover, we do not need to redefine the class at run-time.  A simple > > way to do this: when you compile a function with arithmetic > > operations, concatenate bytecode for two versions: essenti

Re: Enhanced Primitive Support Syntax

2011-01-17 Thread Mark Engelberg
On Mon, Jan 17, 2011 at 1:05 PM, Bob Hutchison wrote: > Numerical correctness, for some of us, is an overwhelming issue. This is > purely from experience... bad experience... 30+ years of bad experience in my > case :-) From my point of view, the approach Clojure is taking isn't > persuasive, n

Re: Euler 14

2011-01-17 Thread Mark Engelberg
On Mon, Jan 17, 2011 at 11:55 AM, Andreas Liljeqvist wrote: > I don't see why the cseq's have to be lazy, they are at the most 525 > elements long. > shouldn't each sequence only be produced when it is reduced in max-key and > then discarded? You're right, the chains aren't as long as I thought.

Re: best way to define alias for all publics in ns?

2011-01-17 Thread Seth
woops, mistake (defn ns-export [from-ns] (count (doall (map (fn [[sym var]] (let [v (if (.hasRoot var) (var-get var)) var-obj (if v (intern *ns* sym v))] (when var-obj

Re: best way to define alias for all publics in ns?

2011-01-17 Thread Laurent PETIT
Taking the risk to be ridiculous in the front of all my peers : how is your function different from the "clojure.core/use" function, exactly ? 2011/1/17 Seth > woops, mistake > > (defn ns-export [from-ns] > (count (doall (map (fn [[sym var]] >(let [v (if (.hasRoot var)

Re: best way to define alias for all publics in ns?

2011-01-17 Thread Meikel Brandmeyer
Hi Laurent, Am 17.01.2011 um 22:32 schrieb Laurent PETIT: > Taking the risk to be ridiculous in the front of all my peers : how is your > function different from the "clojure.core/use" function, exactly ? It's more like immigrate from earlier compojure versions. When you use this namespace it

Re: Enhanced Primitive Support Syntax

2011-01-17 Thread Brian Goslinga
On Jan 17, 3:17 pm, Jason Wolfe wrote: > I think you can.  Let me elaborate on my simplistic example.  Compile > the code for a function twice -- once where everything works within > primitives, and once where everything works with Objects -- and > concatenate the bytecode together.  Start by runn

Clojure/JVM languages internal presentation

2011-01-17 Thread Robert Campbell
Hey guys, This past summer I gave a presentation on JVM langauges at our company's worldwide developer summit. I tried to get approval for Clojure but had to settle for Scala because its syntax didn't frighten management. I figured I'd share it in case any of the slides can be of use elsewhere. o

Re: Enhanced Primitive Support Syntax

2011-01-17 Thread Jason Wolfe
On Jan 17, 3:24 pm, Brian Goslinga wrote: > On Jan 17, 3:17 pm, Jason Wolfe wrote:> I think you can.   > Let me elaborate on my simplistic example.  Compile > > the code for a function twice -- once where everything works within > > primitives, and once where everything works with Objects -- an

Re: Enhanced Primitive Support Syntax

2011-01-17 Thread Brian Goslinga
I'll also add that type inference wouldn't solve the problem, it would just move the pain the the design of the type system and details relating to it. The type system would probably be at least as complex as Java generics to be something worthwhile if you do the type inferencing for perf primarily

Book on Ring - reviewers needed

2011-01-17 Thread Brian Marick
I'm working on a short book on Ring for the Pragmatic Bookshelf. The first two chapters are here: http://exampler.com/tmp/ring.pdf If you'd like to be a reviewer, send me mail. - Brian Marick, Artisanal Labrador Contract programming in Ruby and Clojure Author of /Ring/ (forthcoming; sample:

Re: best way to define alias for all publics in ns?

2011-01-17 Thread Seth
if you 'use' ns A in ns B, ns C which uses B will not see the functions of A. Im trying to create a ns which collects functions from various other ns and exports them so that all you have to do is use that one uber ns. -- You received this message because you are subscribed to the Google Groups "

Re: best way to define alias for all publics in ns?

2011-01-17 Thread Ken Wesson
On Mon, Jan 17, 2011 at 10:47 PM, Seth wrote: > if you 'use' ns A in ns B, ns C which uses B will not see the > functions of A. Im trying to create a ns which collects functions from > various other ns and exports them so that all you have to do is use > that one uber ns. And, Clojure being a lan

Re: Clojure Quizzes?

2011-01-17 Thread Alan
On Jan 17, 7:42 am, Robert McIntyre wrote: > You can then actually run your program by making a shell script with > something like > #!/bin/bash > java -Xmn500M -Xms2000M -Xmx2000M -server -cp ./lib/*:./src > clojure.main your-namespace-file.clj  $@ > > A little known fact is that the above can ac

Testing if a sequence is lazy

2011-01-17 Thread Nick Brown
Hi, I'm wondering if there is a good way to test if a given sequence is lazy, and if so, how much of it has been evaluated. I know the fact that it is lazy should be transparent, but I'm thinking in the context of unit testing knowing that could be valuable. For instance if you know a particular

Re: Clojure Quizzes?

2011-01-17 Thread Robert McIntyre
Because there is a limit on the length of the shebang line to as short as 80 characters in some distributions (notably ubuntu), and the posix standard for the shebang line does not allow you to pass any arguments to the interperter to modify its behaviour --- so no classpath or anything else for yo

Re: HPC in scala ..

2011-01-17 Thread Tim Daly
Hello Everybody, not directly related to clojure .. but it is interesting to know that scala people got a huge funding to further the state of the art in HPC... http://www.scala-lang.org/node/8579 Sunil. -- You received this message because you are subscribed to the Google Groups "Clojure"