Re: Addition of new a priori distinct element to a vector

2011-09-22 Thread F Lengyel
On Sep 23, 2:18 am, Andy Fingerhut wrote: > To be very precise, (conj v new-elem) is O(log n) in time and space, but it > is "constant-ish" because the base of the logarithm is something like 32, > rather than something like 2, so the constant factor multiplying the log n > is typically pretty s

Re: Addition of new a priori distinct element to a vector

2011-09-22 Thread Kevin Livingston
what's the actual use case where you want this? it seems pretty weird just on it's own. it may in practice be more clever than other solutions, but that's not clear yet. if you just want a unique symbol there's (gensym) regarding vectors, I found this a helpful read a while back, it's a few yea

Re: Addition of new a priori distinct element to a vector

2011-09-22 Thread Andy Fingerhut
To be very precise, (conj v new-elem) is O(log n) in time and space, but it is "constant-ish" because the base of the logarithm is something like 32, rather than something like 2, so the constant factor multiplying the log n is typically pretty small. Also, there is no difference in Clojure's beha

Re: Addition of new a priori distinct element to a vector

2011-09-22 Thread F Lengyel
On Sep 23, 1:39 am, Nathan Sorenson wrote: > Just to clarify, you want to conj a vector to itself? i.e. [1 2 3 4] --> [1 > 2 3 4 [1 2 3 4]] I'm curious what the application of this is. > > Regarding the overhead of conj-ing to a vector: Clojure's data structures > make use of structural sharing s

Re: Addition of new a priori distinct element to a vector

2011-09-22 Thread Nathan Sorenson
Just to clarify, you want to conj a vector to itself? i.e. [1 2 3 4] --> [1 2 3 4 [1 2 3 4]] I'm curious what the application of this is. Regarding the overhead of conj-ing to a vector: Clojure's data structures make use of structural sharing so conjoining an element to the end of a vector won'

Addition of new a priori distinct element to a vector

2011-09-22 Thread F Lengyel
Suppose I have a vector v. I would like to add a new element to v distinct from all of the elements of v, with the constraint that I assume nothing about v other than it is a vector. (There are cases where it is useful to do this with some algorithms involving reduce, for example.) One way to do

Re: How to attach debugger on clojure's repl ?

2011-09-22 Thread Glen Stampoultzis
On 22 September 2011 11:04, Scott Jaderholm wrote: > While that still works, ritz is really where it's at for awesome debugging > clojure in emacs. It allows stepping and stuff with a nice UI. > > https://github.com/pallet/ritz > > Video (only for overview, follow instructions at url above) > htt

Re: Spread work onto multiple threads (in pure Clojure)

2011-09-22 Thread Andy Fingerhut
pmap will limit the maximum number of simultaneous threads. So will the medusa library's medusa-pmap. The difference is that if one job early in the list takes, e.g., 100 times longer than the next 20, and you have 4 cpus available, pmap will start the first (4+2)=6 in parallel threads, let jobs

Re: 2011 Clojure Conj 'Scholarship' fundraiser

2011-09-22 Thread Ambrose Bonnaire-Sergeant
Thanks all, this is incredible! Ambrose On Fri, Sep 23, 2011 at 5:50 AM, Chas Emerick wrote: > A quick update: > > …thanks to the generosity and otherwise amazing character of the > Clojure community, the 2011 Conj scholarship fundraiser is over two- > thirds of the way to its goal. > > To thos

Re: using finger trees in two dimensions

2011-09-22 Thread Nathan Sorenson
What are your ideas? You can implement a balanced k-d tree on top a normal vector, so that would be my first thought. -- 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 n

Re: advantage of dynamic typing

2011-09-22 Thread Nathan Sorenson
Yes I am very hopeful progress is made on that front! I've been having great success with 'Constraint Handling Rules' (CHR), which serves as my basis for solving type constraints. https://github.com/nsorenson/Clojure-CHR contains my very preliminary crack at implementing this system. The trick wit

Re: Recursion/Algorithm Question

2011-09-22 Thread Nathan Sorenson
You're right on the doorstep again :) If you want to make a single, flat list out of two different lists, the function you're looking for is 'concat' You may find the "cheat sheet" helpful: http://clojure.org/cheatsheet. In this case you were looking for some operation on sequences which gave you

Re: Spread work onto multiple threads (in pure Clojure)

2011-09-22 Thread Kevin Livingston
if the list is quite large, is there anything preventing the option below from creating way too many threads? there is presumably an inflection point where this will cost you. pmap is trying to keep that in check, right? Kevin On Sep 21, 5:28 pm, Nathan Sorenson wrote: > Futures begin executing

emacs clojure.test and unmatched delimiter error

2011-09-22 Thread Kevin Livingston
I have some code in a test ns that uses clojure.test. When I open that code in emacs (with a slime connection) I get a slime error: "Unmatched delimiter: )" except my code is balanced just fine as far as I can tell. the tests all run just fine with maven, everything compiles. it's just emacs an

emacs clojure.test and unmatched delimiter error

2011-09-22 Thread Kevin Livingston
I have some code in a test ns that uses clojure.test. When I open that code in emacs (with a slime connection) I get a slime error: "Unmatched delimiter: )" except my code is balanced just fine as far as I can tell. the tests all run just fine with maven, everything compiles. it's just emacs an

Re: Changing behavior

2011-09-22 Thread Chas Emerick
On Sep 22, 2011, at 10:25 AM, Michael Jaaka wrote: > Hi! > > I would like to change behavior/semantic for my DSL. So instead of typing > this: > > (constraints (where-and (where :field > 123123) (where :field < 3242432))) > > I could type this: > > (where (and (:field > 123123) (:field < 3

Re: How does clojure class reloading work?

2011-09-22 Thread Chouser
On Thu, Sep 22, 2011 at 8:52 PM, Phil Hagelberg wrote: > On Thu, Sep 22, 2011 at 2:19 PM, Chouser wrote: >> It looks like each top-level form currently gets its own fresh >> DynamicClassLoader. >> >> [...] >> >> (do (def a #()) (def b #())) > > If you'll pardon a nit-pick, this example is somewha

Re: How does clojure class reloading work?

2011-09-22 Thread Alan Malloy
On Sep 22, 5:52 pm, Phil Hagelberg wrote: > On Thu, Sep 22, 2011 at 2:19 PM, Chouser wrote: > > It looks like each top-level form currently gets its own fresh > > DynamicClassLoader. > > > [...] > > > (do (def a #()) (def b #())) > > If you'll pardon a nit-pick, this example is somewhat misleadin

Re: How does clojure class reloading work?

2011-09-22 Thread Phil Hagelberg
On Thu, Sep 22, 2011 at 2:19 PM, Chouser wrote: > It looks like each top-level form currently gets its own fresh > DynamicClassLoader. > > [...] > > (do (def a #()) (def b #())) If you'll pardon a nit-pick, this example is somewhat misleading since do forms are special-cased by the compiler so th

Re: Using match library (latest snapshot) ns not found

2011-09-22 Thread ronen
Just did Ronen On Sep 23, 1:59 am, David Nolen wrote: > On Thu, Sep 22, 2011 at 6:56 PM, ronen wrote: > > Thanks David, the ns is found now (using lein checkouts), one of the > > reasons iv tried moving to latest snapshot was an error during > > compilation for the following fn: > > > (defn ema

Re: How does clojure class reloading work?

2011-09-22 Thread Brent Millare
Wow, using what you just explained, I am now able to reload .class files. (defn reload-class [classname] (.defineClass (clojure.lang.DynamicClassLoader.) classname (to-byte-array (io/file "/home/user/dj/usr/src/scratch/src/scratch/ hello.class"))

Re: Using match library (latest snapshot) ns not found

2011-09-22 Thread David Nolen
On Thu, Sep 22, 2011 at 6:56 PM, ronen wrote: > Thanks David, the ns is found now (using lein checkouts), one of the > reasons iv tried moving to latest snapshot was an error during > compilation for the following fn: > > (defn email-request [req] > (match [req] > [{:name _ :repo (r :w

Re: Using match library (latest snapshot) ns not found

2011-09-22 Thread ronen
Thanks David, the ns is found now (using lein checkouts), one of the reasons iv tried moving to latest snapshot was an error during compilation for the following fn: (defn email-request [req] (match [req] [{:name _ :repo (r :when (comp not nil?)) :email email}] (notify- user-constrain

Re: Recursion/Algorithm Question

2011-09-22 Thread ax2groin
Thanks, Nathan, that did help. I'm still stuck, however, figuring out how to return the values as a flat sequence of vectors. Maybe I'm just missing the right function from the API. Here's where I'm at right now: (defn get-paths ([n] (get-paths n [0 0] '())) ([n point path] (cond (points-equ

Re: Using match library (latest snapshot) ns not found

2011-09-22 Thread David Nolen
I'm temporarily bringing back project.clj until we get a proper release out the door (hopefully soon). Let me know if HEAD works for you. David On Thu, Sep 22, 2011 at 6:31 PM, ronen wrote: > Iv been using the cool match library right up until it was moved into > core, using the latest snapshot

Using match library (latest snapshot) ns not found

2011-09-22 Thread ronen
Iv been using the cool match library right up until it was moved into core, using the latest snapshot (match-0.2.0-20110809.143608-2.jar): $ lein compile Caused by: java.io.FileNotFoundException: Could not locate clojure/ core/match/core__init.class or clojure/core/match/core.clj on classpath: P

Re: 2011 Clojure Conj 'Scholarship' fundraiser

2011-09-22 Thread Chas Emerick
A quick update: …thanks to the generosity and otherwise amazing character of the Clojure community, the 2011 Conj scholarship fundraiser is over two- thirds of the way to its goal. To those that have already donated: thank you so very, very much. To those that haven't donated yet: please conside

Re: How does clojure class reloading work?

2011-09-22 Thread Chouser
On Thu, Sep 22, 2011 at 2:56 PM, Kevin Downey wrote: > most likely the compiler is creating a new DynamicClassLoader, it uses > a var clojure.lang.Compiler/LOADER and pushes and pops class loaders > from there. You nailed it. It looks like each top-level form currently gets its own fresh Dynamic

Re: How does clojure class reloading work?

2011-09-22 Thread Kevin Downey
On Thu, Sep 22, 2011 at 3:54 PM, Brent Millare wrote: > Hi Kevin, > > So when you say pushing and popping, you are painting the picture that > there is some basal loader, and every time a new class is compiled, a > new dynamic classloader is created and used to load the new class, > then the class

Re: How does clojure class reloading work?

2011-09-22 Thread Brent Millare
Hi Kevin, So when you say pushing and popping, you are painting the picture that there is some basal loader, and every time a new class is compiled, a new dynamic classloader is created and used to load the new class, then the class is stored by some context reference, instances of that class can

Re: Spread work onto multiple threads (in pure Clojure)

2011-09-22 Thread ronen
Sorry for my delayed reply (busy day), Andy: Ill check Medusa, the number of threads in pmap does impose a limit but in my case I can live with that. Nathan: Yes the reason I wanted futures because of the blocking IO, I don't know why I figured out that futures are lazy, this indeed makes pmap re

Re: How to attach debugger on clojure's repl ?

2011-09-22 Thread Timothy Washington
Np, I hope it helps. I'm an avid vim user. But I'm trying out emacs just to get this debugging feature in slime/swank. It's one of those tools that will keep rewarding you 10 years on. Let me know how you fare. Tim On Thu, Sep 22, 2011 at 7:56 AM, cran1988 wrote: > However can we integrate it

Re: Trying to use CDT on 1.3.0

2011-09-22 Thread Brent Millare
Hmm, I think it was a version mismatch for target repl and debug repl. So it works now. New issue though, I'm running through the breakpoint example and I'm getting an error. The source file doesn't load upon reaching a breakpoint. I have set cdt-dir and cdt-source-path (setq cdt-dir "/home/use

Re: StackOverflowError in prime function

2011-09-22 Thread Alan Malloy
FWIW there's a lot of prior threads about this problem in various guises. The one I like to refer people to is on stackoverflow, and is for exactly what you're doing: http://stackoverflow.com/questions/2946764/recursive-function-causing-a-stack-overflow On Sep 22, 9:36 am, Alf Kristian Støyle wro

Re: How does clojure class reloading work?

2011-09-22 Thread Kevin Downey
most likely the compiler is creating a new DynamicClassLoader, it uses a var clojure.lang.Compiler/LOADER and pushes and pops class loaders from there. On Thu, Sep 22, 2011 at 1:52 PM, Brent Millare wrote: > Hi, > > An update to this question. While Chouser gave a good explanation > about the det

Re: How does clojure class reloading work?

2011-09-22 Thread Brent Millare
Hi, An update to this question. While Chouser gave a good explanation about the details behind proxy, reify, and gen-class, I feel that the explanation behind deftype is incomplete. It's not clear how clojure is able to reload deftype defined classes. Calling deftype eventually leads to a call to

Re: StackOverflowError in prime function

2011-09-22 Thread Alf Kristian Støyle
Well, why reinvent the wheel :) https://github.com/richhickey/clojure-contrib/blob/78ee9b3e64c5ac6082fb223fc79292175e8e4f0c/src/main/clojure/clojure/contrib/lazy_seqs.clj#L66 Cheers, Alf On Thu, Sep 22, 2011 at 19:20, Wilker wrote: > Alf, I mean it will be even better if you just generate an

Re: clojurescript closure problem?

2011-09-22 Thread Mark Nutter
I stand corrected. I guess I'm *too* familiar with JS. I'll have to re-learn a few things. m On Thu, Sep 22, 2011 at 8:34 AM, Meikel Brandmeyer (kotarak) wrote: > Hi, > > Disclaimer: I haven't touched ClojureScript a single time up to now, I only > know the talk of Rich about it. Neither am I J

Re: StackOverflowError in prime function

2011-09-22 Thread Wilker
Alf, I mean it will be even better if you just generate 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: > Jup, that

Re: Help bring a lead core.match and core.logic developer to the Conj

2011-09-22 Thread Devin Walters
(inc) for Ambrose and for your insight on Sussman's talk. On Thursday, September 22, 2011 at 10:54 AM, David Nolen wrote: > Just making sure this post doesn't get lost in the shuffle. Ambrose's > contributions to core.match have been incredible and his continuing > contributions on core.logic

Trying to use CDT on 1.3.0

2011-09-22 Thread Brent Millare
Hi I'm trying to use the clojure debugging toolkit but I'm getting an exception when I reach a breakpoint. exception in event handler java.lang.RuntimeException: java.util.zip.ZipException: error in opening zip file. You may need to restart CDT Anyone know what's going on? Best, Brent -- You r

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

Help bring a lead core.match and core.logic developer to the Conj

2011-09-22 Thread David Nolen
Just making sure this post doesn't get lost in the shuffle. Ambrose's contributions to core.match have been incredible and his continuing contributions on core.logic in terms of tutorials and documentation are an essential resource. It would be a serious loss if Ambrose doesn't make it to the Conj

Re: StackOverflowError in prime function

2011-09-22 Thread Meikel Brandmeyer (kotarak)
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 > StackOverflowError when used incorrectly? > Yes. You pile lazy seq on lazy seq on lazy seq on and then realise the first element. This kicks off a c

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: clojurescript closure problem?

2011-09-22 Thread David Nolen
On Thu, Sep 22, 2011 at 11:12 AM, Michael Fogus wrote: > > the body of loop in a function to preserve bindings if other fns are > > discovered that close over them so as to avoid introducing a perf hit. > > It would be interesting to see if GClosure is smart enough to deal > with the naive implem

Re: clojurescript closure problem?

2011-09-22 Thread Michael Fogus
> the body of loop in a function to preserve bindings if other fns are > discovered that close over them so as to avoid introducing a perf hit. It would be interesting to see if GClosure is smart enough to deal with the naive implementation. I know what I'll experiment on tomorrow. :-) -- You

Changing behavior

2011-09-22 Thread Michael Jaaka
Hi! I would like to change behavior/semantic for my DSL. So instead of typing this: (constraints (where-and (where :field > 123123) (where :field < 3242432))) I could type this: (where (and (:field > 123123) (:field < 3242432))) The catch is that macro "where" shouldn't interpret its conten

Re: clojurescript closure problem?

2011-09-22 Thread David Nolen
There's a patch there but I think it's too simplistic. It should only wrap the body of loop in a function to preserve bindings if other fns are discovered that close over them so as to avoid introducing a perf hit. David On Thu, Sep 22, 2011 at 8:46 AM, David Nolen wrote: > It's a known issue:

Re: clojurescript closure problem?

2011-09-22 Thread Chouser
On Thu, Sep 22, 2011 at 8:46 AM, David Nolen wrote: > It's a known issue: > http://dev.clojure.org/jira/browse/CLJS-39 I somehow missed that one and had filed this one as well: http://dev.clojure.org/jira/browse/CLJS-59 --Chouser -- You received this message because you are subscribed to the

Re: clojurescript closure problem?

2011-09-22 Thread David Nolen
It's a known issue: http://dev.clojure.org/jira/browse/CLJS-39 David On Wed, Sep 21, 2011 at 2:34 PM, Eric Harris-Braun wrote: > Check out this little bit of code: > > (doseq [hid ["a" "b" "c"]] > (goog.dom.appendChild (goog.dom.$ "some-element-id") > (goog.dom.createDom "div" (.strobj {"id" h

Re: clojurescript closure problem?

2011-09-22 Thread Meikel Brandmeyer (kotarak)
Hi, Disclaimer: I haven't touched ClojureScript a single time up to now, I only know the talk of Rich about it. Neither am I JavaScript developer. Too me this smells like a bug. ClojureScript is not JavaScript. It tries to bring (where possible) Clojure semantics to the JavaScript VM. The first

Re: clojurescript closure problem?

2011-09-22 Thread Mark Nutter
No, because that might not be what you want your code to do. As a JavaScript programmer you have to understand what function scope means, and how to use it appropriately. If "hid" is a variable that's in scope when you define an anonymous function, your functions will refer to that specific variabl

Re: How to attach debugger on clojure's repl ?

2011-09-22 Thread cran1988
However can we integrate it on the repl using (clojure.main/repl :eval function ) ? It is very cool debugger!! On Sep 22, 4:04 am, Scott Jaderholm wrote: > While that still works, ritz is really where it's at for awesome debugging > clojure in emacs. It allows stepping and stuff with a nice UI.

Re: How to attach debugger on clojure's repl ?

2011-09-22 Thread cran1988
Thanks !! but i am not using emacs i will watch it and i will try to integrate it on the IDEAJ On Sep 22, 4:04 am, Scott Jaderholm wrote: > While that still works, ritz is really where it's at for awesome debugging > clojure in emacs. It allows stepping and stuff with a nice UI. > > https://githu

Future plans for clojurescript and node.js

2011-09-22 Thread Javier Neira Sanchez
Hi folks, i have been playing with clojurescript and nodejs and i have some questions about the future of that awesome combination: 1.- Is there any plan to add node.js console as target for cljs repl? 2.- Use of node.js module system to compile cljs files: Is it possible that the clojurescript.c

Re: advantage of dynamic typing

2011-09-22 Thread Javier Neira Sanchez
i am surprised nobody mentioned gradual/optional typing, typed racket and the possible type checker to be built by *some clever hacker* on core.logicsome day. -- You recei