Re: thinking parallel programming

2011-01-16 Thread Ken Wesson
On Sun, Jan 16, 2011 at 2:50 AM, Benny Tsai benny.t...@gmail.com wrote: In the Hacker News discussion about that talk, someone posted a link to another talk by Guy Steele on the same topic: http://vimeo.com/6624203 ... where he covers the material in somewhat greater depth (the downside

check if something can be coerced to a seq

2011-01-16 Thread Jürgen Hötzel
Hi, I came across this issue while implementing a lazy, efficient flatten that also uses the whole sequence abstraction (flatten java arrays). The problem with (seq x) is, that it will throw an Exception if called on something, that cannot be coerced to sequence, so I just used sequencial?

Re: check if something can be coerced to a seq

2011-01-16 Thread Ken Wesson
On Sun, Jan 16, 2011 at 6:22 AM, Jürgen Hötzel juer...@hoetzel.info wrote: Hi, I came across this issue while implementing a lazy, efficient flatten that also uses the whole sequence abstraction (flatten java arrays). The problem with (seq x) is, that it will throw an Exception if called

Re: Enhanced Primitive Support Syntax

2011-01-16 Thread Sam Roberton
On 16 January 2011 05:35, Jason Wolfe ja...@w01fe.com wrote: (a) unsafe/incorrect value on overflow/fastest/unifiable* vs. (b) safe/error on overflow/fast/unifiable vs. (c) safe/promoting on overflow/slow/not-unifiable If I understand correctly, the issue with auto-promotion is that we have

Typos in (doc add-watch)

2011-01-16 Thread Jacek Laskowski
Hi, I think there're two typos in http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/add-watch - I believe 'if' should become 'of': The watch fn will be called synchronously, on the agent's thread if an agent, before any pending sends if agent or ref. should become The watch

Why does (.foo (new Bar)) use a different method invocation mechanism than (def bar (new Bar)) (.foo bar)?

2011-01-16 Thread Robert Campbell
I've been trying to understand exactly how these two statements are evaluated by tracing execution through Compiler.java, Reflector.java, etc of tag 1.2.0. The second form - (.foo bar), expanded to (. bar foo) - eventually calls Reflector.invokeNoArgInstanceMember. The first form - (.foo (new

Re: Typos in (doc add-watch)

2011-01-16 Thread Stuart Halloway
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. Cheers, Stu Hi, I think there're two typos in http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/add-watch - I

list* does not make a list?

2011-01-16 Thread Brian Marick
movies.core (list? (apply list (map identity [1 2 3]))) true Makes sense to me! movies.core (list? (list* (map identity [1 2 3]))) false Huh? - Brian Marick, Artisanal Labrador Contract programming in Ruby and Clojure Author of /Ring/ (forthcoming; sample:

Re: Why does (.foo (new Bar)) use a different method invocation mechanism than (def bar (new Bar)) (.foo bar)?

2011-01-16 Thread Rasmus Svensson
2011/1/16 Robert Campbell rrc...@gmail.com: The second form - (.foo bar), expanded to (. bar foo) - eventually calls Reflector.invokeNoArgInstanceMember. For that form, the clojure compiler cannot infer the type of bar, and does not know which exact method (class + type signature) .foo

Re: list* does not make a list?

2011-01-16 Thread Alan
list* consumes its last argument lazily, which means it can't count it (a requirement to be a real list). Both functions return objects that are seqs, though, so you can (seq?) them if you want. user= (def x (list* (range))) #'user/x user= (def x (apply list (range))) java.lang.OutOfMemoryError:

Re: thinking parallel programming

2011-01-16 Thread Tim Daly
Steele is advocating binaries trees as an way of doing parallel computation. I think that this idea is reasonable but might be more effectively applied in Clojure. The idea of binary could be expanded in a very simple way to use log32 instead which is a natural mapping to the Clojure data

Re: list* does not make a list?

2011-01-16 Thread Sean Allen
the documentation on that could be improved. the doc string for that is basically the same as for list. but they return different types. rather surprising when you first see it. On Sun, Jan 16, 2011 at 1:55 PM, Alan a...@malloys.org wrote: list* consumes its last argument lazily, which means

Re: Clojure Quizzes?

2011-01-16 Thread Randy J. Ray
On 01/12/2011 11:50 PM, Robert McIntyre wrote: They seem to allow you to include anything in a lib directory that you'd want. I sometimes include apache commons-io and clojure-contrib1.2 without any problems. I also included a sql connection library for one of the problems, so it seems fine :)

Re: Clojure Quizzes?

2011-01-16 Thread Benny Tsai
Hi Randy, You can access a seq of the command line args via the *command-line- args* var. On Jan 16, 3:03 pm, Randy J. Ray randy.j@gmail.com wrote: On 01/12/2011 11:50 PM, Robert McIntyre wrote: They seem to allow you to include anything in a lib directory that you'd want. I

Re: Enhanced Primitive Support Syntax

2011-01-16 Thread Armando Blancas
Then again, how often do you write code that might be doing maths with numbers that big and not realise it?  For that matter, how often do you write code that might be doing maths with numbers that big and not spend time thinking carefully about its performance anyway? This reminds me of a

Re: Enhanced Primitive Support Syntax

2011-01-16 Thread Jason Wolfe
(a) unsafe/incorrect value on overflow/fastest/unifiable* vs. (b) safe/error on overflow/fast/unifiable vs. (c) safe/promoting on overflow/slow/not-unifiable If I understand correctly, the issue with auto-promotion is that we have to box the output of an operation even if it turns out

Re: Enhanced Primitive Support Syntax

2011-01-16 Thread Sean Corfield
On Sun, Jan 16, 2011 at 3:50 PM, Jason Wolfe ja...@w01fe.com 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: essentially, one with the unprimed

Re: Clojure Quizzes?

2011-01-16 Thread John Svazic
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 rdr))) (defn my-func [col] ; Do something interesting

Re: Enhanced Primitive Support Syntax

2011-01-16 Thread chris
Is it insane to suggest that perhaps clojure should work with scala such that we can write both languages in the same file? Use scala to do you strongly typed work and things where you are really concerned that auto-promotion. Let the language made for helping a programmer lots of information

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 justi...@gmail.com wrote:

Tagless-final Interpretations in Clojure (can it be done better than this?)

2011-01-16 Thread Nathan Sorenson
After reading Oleg's lecture Typed tagless-final interpretations ( http://okmij.org/ftp/tagless-final/course/ ), I decided to see if this was possible, or made any sense, to follow this style in Clojure. The idea is that, instead of representing a DSL syntax as a data structure that you

Re: thinking parallel programming

2011-01-16 Thread Alex Miller
There was some discussion about this topic after David Liebke's talk at the conj about the prototype fork/join filter/map/etc work that Rich did. The talk isn't out on video yet but slides are here: http://incanter.org/downloads/fjclj.pdf and I wrote up some of these notes here:

Re: thinking parallel programming

2011-01-16 Thread Tim Daly
Excellent. I am taking notes on Steele's talk and adding them to the CiSP parallel section. In Clojure it might be possible to dynamically change the number of processes. With the bit-partition idea is might even be convenient. There was some discussion about this topic after David Liebke's

I don't understand this exception

2011-01-16 Thread Stefan Rohlfing
Hi all, I am trying to implement the function 'group-by' from Clojure.Core using my current knowledge of Clojure but cannot get pass a java.lang.Exception. This is the code so far: (defn key? [key coll] (some #{key} (keys coll))) (defn my-group-by [f coll] (let [test (fn [m x]

Re: I don't understand this exception

2011-01-16 Thread Meikel Brandmeyer
Hi, The exceptions stems from the call to vec. vec turns a collections (read: seqable thing) into a vector. The right function calls is vector. (defn my-group-by [f coll] (let [test (fn [m x] (let [res (f x)] (if (key? res m) (conj (m res)

Re: I don't understand this exception

2011-01-16 Thread Ken Wesson
On Mon, Jan 17, 2011 at 1:47 AM, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: Hi all, I am trying to implement the function 'group-by' from Clojure.Core using my current knowledge of Clojure but cannot get pass a java.lang.Exception. This is the code so far: (defn key? [key coll]