Re: Concerns About Pushing Clojure 1.0.0 to Maven Central Repo?

2009-05-12 Thread ataggart
I use Maven indirectly via Ivy, so I just wanted to request that, whatever the choice of naming, the artifact and module names should parallel. The reason for this request is that Ivy can resolve dependencies in maven by creating URLs from a pattern. For example: pulls from org/clojure/clojur

Re: integer overflow behavior multiply

2009-05-30 Thread ataggart
Yes, the reason the larger one works is because the parameters to * just happen to overflow to values that let the result of * not go out of bounds. As for doing bounds checking during (int), I think that would be a net loss. Generally speaking, casting to a primitive is intended to aid performa

Re: "Currying" / Partial Application macro

2009-05-31 Thread ataggart
On May 30, 12:58 pm, eyeris wrote: > The ubiquity of these anonymous functions > in clojure code is evidence that partial application is just as needed > in clojure as it is in haskell. Doesn't that depend entirely on whether or not the anonymous functions are being used for partial applicatio

Re: "Currying" / Partial Application macro

2009-05-31 Thread ataggart
On further consideration, having partial so the arity handling in non- trivial cases is where it trumps an anonymous function. On May 31, 2:04 am, ataggart wrote: > On May 30, 12:58 pm, eyeris wrote: > > > The ubiquity of these anonymous functions > > in clojure code is evi

Re: "Currying" / Partial Application macro

2009-05-31 Thread ataggart
On May 31, 5:20 am, Meikel Brandmeyer wrote: > Am 31.05.2009 um 11:11 schrieb ataggart: > > (partial f a b) is equivalent to #(apply f a b %&). So anonymous > functions are the more general, more powerful concept. Ah, beautiful! Somehow I missed the %& form w

Where does the language end and the libraries begin?

2009-06-03 Thread ataggart
Tonight Rich made a comment (related to distributed computing) about not wanting to include things in the language that should belong in libraries. This led me to wonder (only after leaving the meeting), where does that boundary live? Is clojure.core "language" or "library"? Is it the java impl

Re: Clojure, GridGain and serialization error

2009-06-09 Thread ataggart
What was the solution? On Jun 9, 1:03 pm, prhlava wrote: > > I am playing with GridGainhttp://www.gridgain.comfrom Clojure and I > > am getting > > exception related to serialization. > > Never mind, I tool a wrong approach at first. Now I have it running, > apologies for the noise... > > Kind r

Re: (Simple) Neural Net Simulation

2009-06-09 Thread ataggart
On Jun 9, 11:07 am, "alfred.morgan.al...@gmail.com" wrote: > Thanks for the advice, but at present I'm simply aiming to get the > very basics of a neural net up and running without having to worry > about a training algorithm at all.  Here's what I have so far (again, > very basic) > > ;; Net0

Re: why is io! not enforced?

2009-06-22 Thread ataggart
On Jun 20, 4:59 pm, Rowdy Rednose wrote: > On a side-note: I actually think it can make sense to do io in > transactions in Clojure, and I believe (knowing that transactions can > be replayed) it is possible to use that to e.g. implement a > transaction log written to disk that could be used to

Re: The API docs are gone!

2009-06-26 Thread ataggart
On Jun 26, 9:12 pm, Four of Seventeen wrote: > Not that it really matters why it is/was down. The API docs going down > for any amount of time longer than a minute or so is bad bad news. ... > By contrast, in over a decade of usinghttp://java.sun.com/javase/6/docs/api/ > and its predecessors I

Re: executing tasks on a schedule

2009-06-26 Thread ataggart
What do you need that a cron job wouldn't provide? On Jun 26, 8:43 am, Stuart Halloway wrote: > I am working on a Clojure project that is becoming more and more   > schedule-oriented. So far I have been using Clojure's native   > concurrency constructs, but I am becoming tempted to use Java's  

Re: sanity check needed

2009-07-05 Thread ataggart
A set might be better to hold the player-refs, then you can just call (disj player-refs player-ref) without doing any extra checking. Also you can access ref values without needing to be in a dosync. Things being immutable, the value you get from, say, @team-ref won't change once you have it. On

Re: sanity check needed

2009-07-05 Thread ataggart
I should have been more clear when I said to use (disj ...); I meant sending that via an alter. On Jul 5, 6:05 pm, ataggart wrote: > A set might be better to hold the player-refs, then you can just call > (disj player-refs player-ref) without doing any extra checking. > > Also yo

Re: Dependency management

2009-07-07 Thread ataggart
Phil, it might be worthwhile to look at Ivy (http://ant.apache.org/ ivy). It has real good interop with ant and can easily pull from a maven repo and read pom files. On Jul 7, 9:28 pm, Phil Hagelberg wrote: > I've been noodling on the problem of dependency management for a while > now. It's def

Does anyone need any clojure work done?

2009-07-07 Thread ataggart
After having spent the last decade doing server-side java, lots of infrastructure level code which I enjoy), and going blind on xml, I'd really like to get more into clojure. I've been playing with it off and on for about a year now, reading whatever FP-related material I can get my hands on, but

Re: Simple data structure access macro

2009-07-20 Thread ataggart
How about: (get-in nestedDS [1 "hello" 0]) http://clojure.org/api#toc279 On Jul 20, 1:31 pm, Moses wrote: >   I come primarily from a perl programming background, but am trying > to learn Clojure. > >   I'm looking for a clojure equivalent to the following. > >   Perl: > >    my $nestedDS = [

Logging functions delegated to java logging systems

2009-07-21 Thread ataggart
I've written up a small set of logging functions to output from clojure what I'm already doing from my production java code. Currently it checks for the presence of commons-logging, log4j, and finally java.util.logging. The clojure code doesn't actually do any logging itself; instead everything

Re: Logging functions delegated to java logging systems

2009-07-22 Thread ataggart
logged-future   -> I find handy for long running threads > debug          -> its nice to be able to log an expression and what > its evaluated to while leaving it in place (+ (debug (+ 1 2)) 3) > current-function-name (Stephen C. Gilardi posted)  -> optionally > including t

Re: Logging functions delegated to java logging systems

2009-07-23 Thread ataggart
. log-capture! [log-name] Redirects writes of System.out and System.err to the logs log-uncapture! Restores the System.out and System.err to their defaults. with-logs [log-name & body] Evaluates the body with *out* and *err* redirected to the logs On Jul 22, 11:53 am, ataggart wrote:

Re: Logging functions delegated to java logging systems

2009-07-23 Thread ataggart
logic as the original statement, but > > if the logging level is :fine then it will additionally log the > > intermediate part. I find both forms useful. Unfortunately the naming > > gives no clue as to the differences between them. > > > Regards, > > Tim

Re: Logging functions delegated to java logging systems

2009-07-23 Thread ataggart
Hmm, I like "spy" since it doesn't mimic a logging level like "debug" and "trace" do. Making the change now, thanks. On Jul 23, 11:01 am, Laurent PETIT wrote: > What about 'spy instead of 'debug ? Or 'trace ? > > 2009/7/23 ataggar

Re: Logging functions delegated to java logging systems

2009-07-27 Thread ataggart
Ok the patch file has been languishing on assembla for a few days, so I've uploaded it to the files section here if anyone wants to use the latest version. logging.clj at http://groups.google.com/group/clojure/files http://groups.google.com/group/clojure/files On Jul 23, 11:20 am, ata

Re: Clojure performance tests and clojure a little slower than Java

2009-07-27 Thread ataggart
On Jul 27, 10:06 am, BerlinBrown wrote: > So far I have found that clojure is about > 5-10 times as slow as comparable code in Clojure. I infer you mean clojure execution times are about 5-10 times longer than in java. It depends on what you're doing, but that sounds plausible. Here's are so

Re: Parallel garbage collection worthwhile?

2009-07-29 Thread ataggart
I threw this together, how does it measure up? (defn prime? [x primes] (not (first (filter #(zero? (rem x %)) primes (defn next-prime [xs primes] (lazy-seq (let [xs (drop-while #(not (prime? % primes)) xs) prime (first xs) primes (conj primes prime)] (cons

Re: struct-map niggle

2009-07-30 Thread ataggart
The problem is you aren't quoting the forms fed to eval. This: (eval (struct foo 1 2)) mean this: (eval {:bar 1 :baz 2}) And small literal maps are eval'd as a PersistentArrayMap Now if instead you do: (eval '(struct foo 1 2)) then eval is eval'ing the form (struct foo 1 2), thus t

Re: Converting seqs to vectors & caching lazyseqs

2009-08-01 Thread ataggart
On Aug 1, 9:37 am, Garth Sheldon-Coulson wrote: > Hi there, > > I have a program that produces multidimensional LazySeqs, i.e. seqs of seqs > of seqs of... > > I would like to write a function to convert these multidimensional LazySeqs > to vectors. This is in case a user needs constant lookup

Re: What happened to clojure.contrib web site ?

2009-08-03 Thread ataggart
Here's the well-hidden, auto-generated docs for clojure-contrib: http://richhickey.github.com/clojure-contrib/ On Aug 3, 5:41 pm, James Sofra wrote: > I think he may mean > thishttp://code.google.com/p/clojure-contrib/wiki/OverviewOfContrib > Is it still being updated? > It says "Updated Jun

Re: Reflection warning: reference to field getClass can't be resolved.

2009-08-05 Thread ataggart
On Aug 4, 4:46 pm, Vagif Verdi wrote: > When reflection warning is on, i get 2 warnings on every my file: > > reference to field getClass can't be resolved. > reference to field getClassLoader can't be resolved. > > Is this something i should be worried about ? Probably not. It appears to be in

gen-class not capturing the expected *ns*

2009-08-05 Thread ataggart
In testing out clojure.contrib.logging within a generated servlet, I noticed that the value of *ns* is always clojure.core, and not the ns of the code. I just wanted to make sure I wasn't missing something obvious. The servlet code: (ns com.example.servlet (:require (clojure.contrib [logging

Re: gen-class not capturing the expected *ns*

2009-08-05 Thread ataggart
On Aug 5, 9:11 pm, Richard Newman wrote: > > In testing out clojure.contrib.logging within a generated servlet, I > > noticed that the value of *ns* is always clojure.core, and not the ns > > of the code. > > I have observed this too (running in SailFin, which is based on   > GlassFish). > > >

Re: gen-class not capturing the expected *ns*

2009-08-05 Thread ataggart
On Aug 5, 11:24 pm, Richard Newman wrote: > > Bah! I tried to simplify the example code, and missed conveying the > > actual problem.  Your example code (and sadly, mine) pulls *ns* at > > runtime, the logging macro doesn't; it writes the value of the *ns* at > > macro-expansion-time precisely

Re: with-out-str assumes Unix line ends

2009-08-06 Thread ataggart
Anne, please don't threadjack. Now my original subject appears missing, since you renamed it. On Aug 6, 1:03 am, Anne Ogborn wrote: > (use 'clojure.contrib.duck-streams) > (spit "C:\\test.txt" >     (with-out-str >       (println "foo") >       (println "bar") >       (flush))) > > On my XP Tab

Re: gen-class not capturing the expected *ns*

2009-08-06 Thread ataggart
Restoring this thread's original subject. On Aug 6, 10:40 am, ataggart wrote: > Anne, please don't threadjack.  Now my original subject appears > missing, since you renamed it. > > On Aug 6, 1:03 am, Anne Ogborn wrote: > > > > > (use 'clojure.con

Re: gen-class not capturing the expected *ns*

2009-08-06 Thread ataggart
Ok, yes, I will blame my idiocy on sleep deprivation. In every case the name used by the log is the runtime *ns*, which really defeats the purpose of naming the specific usages of log. I'm surprised no one mentioned this (imo wrong) behavior. I'll get to work on fixing it so it behaves properly.

Re: gen-class not capturing the expected *ns*

2009-08-06 Thread ataggart
Ah, very well. I find it useful to print out so I know which code is doing the logging, since stack inspection is very expensive, and in the case of clojure, looks like a mess of underscores and dollar signs. ;) On Aug 6, 12:31 pm, Richard Newman wrote: > > In every case the name used by the lo

Re: gen-class not capturing the expected *ns*

2009-08-06 Thread ataggart
Restoring subject again On Aug 6, 12:48 pm, Anniepoo wrote: > Sorry for the confusion - I read this list on an email feed. Turns out > replying to a message from there and changing the subject isn't > sufficient to start a new thread. Apparently it renames the thread. > (suboptimal). > > ori

Re: Can Clojure be as fast as Java?

2009-08-11 Thread ataggart
On Aug 11, 11:55 am, fft1976 wrote: > I feel that this question is important enough to warrant its own > thread. http://groups.google.com/group/clojure/search?group=clojure&q=%22as+fast+as+java%22&qt_g=Search+this+group > > If you use Java's arrays and declare all types, should Clojure be as

Re: minor grievance with arithmetic on characters

2009-09-10 Thread ataggart
I'd like to second all of this. The very first time I had to fix someone else's bug was when the dev used "a.compareTo(b) == -1". On Sep 9, 1:37 am, B Smith-Mannschott wrote: > On Tue, Sep 8, 2009 at 23:35, Stephen C. Gilardi wrote: > > > On Sep 8, 2009, at 2:14 AM, Timothy Pratley wrote: > >

Re: How can a clojure script recognise it is running as a script?

2009-09-18 Thread ataggart
Just for my own edification (not being versed in python), what's the point of knowing that? On Sep 18, 3:46 am, Kelvin Ward wrote: > java -cp clojure.jar clojure.main foo.clj > > I'm wondering if the code in foo.clj has anyway to know it is being > executed as a script. In python there's the id

Re: Finding elements in 2 sequences that match (indexwise)

2009-10-14 Thread ataggart
How about something like this: (filter #(not= % :nomatch) (map #(if (= %1 %2) %1 :nomatch) [1 2 3 4] [1 3 3 3])) Or cleaned up for general use: (defn filter-map "Returns the results of map, but filtered to contain only those items whose inputs to f have satisfied pred. pred takes the same ar

Re: Finding elements in 2 sequences that match (indexwise)

2009-10-14 Thread ataggart
s within the compared > seqs :-( > > 2009/10/14 ataggart > > > > > > > How about something like this: > > > (filter #(not= % :nomatch) (map #(if (= %1 %2) %1 :nomatch) [1 2 3 4] > > [1 3 3 3])) > > > Or cleaned up for general use: > >

Re: feedback on this code

2009-10-28 Thread ataggart
I second Tim's comment regarding holding onto calculated values. That's at best a performance optimization, and likely an unnecessary one. Also, by using the product itself as a key simplifies the case where you try to "add" the same product as multiple line-items (though this may be what you wan

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

2009-10-28 Thread ataggart
Also you can substitute #^"[C" with the more legible #^chars. On Oct 28, 7:27 pm, Alex Osborne wrote: > 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 o

Re: Applying static java method to seq

2009-11-02 Thread ataggart
If (Integer/parseInt "5") works, then not all functions need be an implementation of IFn; or perhaps more precisely, clojure knows when a call is being made to an IFn vs a static java method. It would be nice for consistency if whatever makes that work also treated Integer/ parseInt as a function

Re: Applying static java method to seq

2009-11-02 Thread ataggart
Good point about type-hinting. On Nov 2, 11:42 am, Chouser wrote: > On Mon, Nov 2, 2009 at 3:32 PM, ataggart wrote: > > > If (Integer/parseInt "5") works, then not all functions need be an > > implementation of IFn; or perhaps more precisely, clojure knows when a

Re: (into) improvement

2009-11-03 Thread ataggart
(into [] (concat [1 2] [3 4])) Different tools for different jobs. And Mark makes a great point about assuming too much from a particular usage. On Nov 3, 7:56 pm, mbrodersen wrote: > Currently (into) takes 2 parameters (destination and source): > > (into [] [1 2]) => [1 2] > > but not more

Re: Language request: make key and val work on vector pairs too

2009-11-11 Thread ataggart
Just use first and second for both cases. On Nov 11, 9:52 am, samppi wrote: > Clojure 1.1.0-alpha-SNAPSHOT > user=> (conj (first {1 2}) 3) > [1 2 3] > user=> (conj {1 2} [2 5]) > {2 5, 1 2} > user=> (key (first {1 2})) > 1 > user=> (key [1 2]) > java.lang.ClassCastException: clojure.lang.Persist

Re: repeatedly forcing the evaluation of a lazy seq

2009-11-20 Thread ataggart
The sequence returned from the filter would need to be rescanned to get the nth element, but the filtering itself should only need to happen when the "next" element in the sequence is sought. For cases such as the one you describe, I think it's common to fully realize the sequence into a vector, e

Re: Clojure Scoping Rules

2009-11-21 Thread ataggart
Getting back to the initial post, this would be the (almost) equivalent code in java: public class Test{ static int x = 1; void bindingX(int val){ x = val; } int dummyFn2(){ return x + 1; } void dummyFn(){ System.out.println("entering function: "

Re: initialization of clojure.contrib.logging library

2009-11-23 Thread ataggart
The c.c.logging library delegates to an underlying implementation, thus for any configuration help you'll need to check the documentation of the actual logging system, e.g., log4j. On Nov 21, 7:21 am, Alex Ott wrote: > Hello all > > I have one question about logging library from contrib? How i

Re: PersistentStructMap Exception

2009-11-23 Thread ataggart
That's not how you create a new struct instance. http://clojure.org/data_structures#toc19 On Nov 23, 6:29 am, cearl wrote: > Hi, > I'm getting a cast exception on trying to create a simple structure > and wondered if there was something obvious that I'm not doing. The > transcript below shows

Re: swing: efficiently updating a listbox from a clojure list

2009-11-25 Thread ataggart
Bear in mind that when going from the "slow" to the "fast", you not only removed the repeated calls to to-array, but also removed the overhead of words-with, since the lazy seq returned from the let doesn't get fully realized. Try changing your "fast" version to: (def update-wlist #(let [w (doall

Re: swing: efficiently updating a listbox from a clojure list

2009-11-25 Thread ataggart
On Nov 25, 11:09 am, Martin DeMello wrote: > On Thu, Nov 26, 2009 at 12:31 AM, Jonathan Smith > > To display you would want to use 'into-array' and your 'setListData' > > function, because you seem to have a homogeneous collection of > > strings; while to-array makes you an array of objects, into-

Re: inverse of interleave = unravel

2009-12-02 Thread ataggart
On Dec 2, 9:10 am, Konrad Kułakowski (kony) wrote: > Recently I need something which works as "inverse of interleave" > > I did something like that: > > (defn unravel [expr-list] >         (loop [flist () slist () tic-tac 0 olist expr-list] >                 (let [item (first olist)] >          

Re: Space usage of lazy seqs

2009-12-02 Thread ataggart
On Dec 2, 10:50 am, Johann Hibschman wrote: > I don't understand Clojure's space requirements when processing lazy > sequences. Are there some rules-of-thumb that I could use to better > predict what will use a lot of space? > > I have a 5.5 GB pipe-delimited data file, containing mostly floats

Re: Space usage of lazy seqs

2009-12-02 Thread ataggart
On Dec 2, 10:50 am, Johann Hibschman wrote: > I don't understand Clojure's space requirements when processing lazy > sequences. Are there some rules-of-thumb that I could use to better > predict what will use a lot of space? > > I have a 5.5 GB pipe-delimited data file, containing mostly floats

Re: What about contains? for lists

2009-12-02 Thread ataggart
On Dec 2, 7:10 am, Stefan Kamphausen wrote: > Hi, > > while studying the collection types and trying to find out which > functions work on all collection types (i.e. lists, vectors, maps, > sets) I was flabbergasted by the following > > user> (contains? (list 1 2 3) 3) > false > > OK, the doc of c

Re: What about contains? for lists

2009-12-02 Thread ataggart
On Dec 2, 12:06 pm, ataggart wrote: > On Dec 2, 7:10 am, Stefan Kamphausen wrote: > > > > > > > Hi, > > > while studying the collection types and trying to find out which > > functions work on all collection types (i.e. lists, vectors, maps, > &g

Re: inverse of interleave = unravel

2009-12-02 Thread ataggart
On Dec 2, 12:02 pm, Chouser wrote: > On Wed, Dec 2, 2009 at 2:06 PM, ataggart wrote: > > > On Dec 2, 9:10 am, Konrad Kułakowski (kony) > > wrote: > >> Recently I need something which works as "inverse of interleave" > > > How about this? > &g

Re: What about contains? for lists

2009-12-02 Thread ataggart
On Dec 2, 1:08 pm, Stefan Kamphausen wrote: > Hi, > > On Dec 2, 9:06 pm, ataggart wrote: > > > > I'd like to understand the (probably well-grounded) reason for that. > > > As far as I can see PersistentList extends Counted, so the check for > > >

Re: Clojure Koans?

2009-12-02 Thread ataggart
If by "koan" you mean usage examples, then there are plenty of them within the clojure source itself, as well as clojure-contrib. See also: http://rosettacode.org/wiki/Category:Clojure Leave it to rubyists to turn a simple concept like examples into some religious indoctrination. I kid! On Dec

Re: What about contains? for lists

2009-12-02 Thread ataggart
On Dec 2, 1:32 pm, Stefan Kamphausen wrote: > Hi, > > On Dec 2, 10:24 pm, ataggart wrote: > > > My guess is that String and array, while not implementing the > > IAssociative interface, all have the O(1) lookup performance > > guarantees of associative data stru

Re: Java Class Factory

2009-12-02 Thread ataggart
On Dec 2, 8:15 pm, lazy1 wrote: > Hello, > > I'm trying to create a "factory" method for Java classes, however I'm > doing something wrong. > > (import '(java.util Dictionary HashMap)) > > (def *containers* { :dict Dictionary :hash HashMap}) > (defn new-container >   [type] >   (new (*containers

Re: Remove Value From Vector at Given Index

2009-12-03 Thread ataggart
There's take-nth in core, but no drop-nth (which sounds like what you need), so I wrote it: (defn drop-nth [n coll] (lazy-seq (when-let [s (seq coll)] (concat (take n s) (drop-nth n (next (drop n s))) So, in your example: (vec (drop-nth 2 [2 4 5 8 6 4])) On Dec 1, 7:06 pm, Don

Re: Remove Value From Vector at Given Index

2009-12-03 Thread ataggart
On Dec 3, 2:10 pm, ataggart wrote: > There's take-nth in core, but no drop-nth (which sounds like what you > need), so I wrote it: > > (defn drop-nth [n coll] >   (lazy-seq >     (when-let [s (seq coll)] >       (concat (take n s) (drop-nth n (next (drop n s)

Re: API pages

2009-12-03 Thread ataggart
Looks fine in Safari 4.0.3. On Dec 2, 9:24 pm, Sean Devlin wrote: > Hey, the API page doesn't look right in Firefox 3.5 > > The cut off around halfway through the page. > > I think this also happens in Safari, but I'm not sure right now. > > Oh, and IE 6... YUCK! (But that's expected :)) > > Sean

Re: Creating a matrix mirrored around it's main diagonal

2009-12-03 Thread ataggart
On Dec 3, 4:28 am, Tiemo Kieft wrote: > Hi, > > I'm trying to create a matrix, basically it's a vector of vectors. I copied > the code from ants.clj to create the matrix, however, I have to mirror the > matrix around it's main diagonal (see below). Currently I'm doing this by > first creating

Re: create java class instance from type selected at runtime

2009-12-06 Thread ataggart
On Dec 5, 11:48 am, Christopher Wicklein wrote: > Greetings! > > I'd like to create an instance of a Java class like this: > > let [foo (Bar.)] > > but, I'd like the type specified by Bar to not be static, e.g. something like > this: > > let [foo (:type params).] > > but, I can't seem to get this

Re: Code improvement: Can this loop be expressed as higher-level function calls?

2009-12-06 Thread ataggart
On Dec 6, 11:28 am, samppi wrote: > I've read that loop/recur is less preferable to using higher-level > function calls like reduce and for and map, especially when chunked > seqs are implemented. But is can the loop below be rewritten to use > those functions instead? It's a loop that iterates

Re: The new deftype and multimethod dispatching

2009-12-06 Thread ataggart
On Dec 6, 12:29 pm, Bob Hutchison wrote: > Hi, > > I'm new to Clojure, not new to lisp (CL and scheme), and having a   > thoroughly good time. I've been having a go at the new deftype stuff   > and using a clone of the new branch from the git repository (up-to- > date as of this message being post

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

2009-12-06 Thread ataggart
On Dec 6, 7:33 pm, Allen Rohner wrote: > I started playing with the idea of a hooks library for Clojure, > similar to Emacs hooks. > > You can see the code athttp://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?

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

2009-12-06 Thread ataggart
On Dec 6, 9:22 pm, Allen Rohner wrote: > > What is it supposed to do?  What's the usage look like? > > Oh right, a description would be useful. The point is to build up the > functionality of a function from several places. You define a hook > function: > > (defhook foo [a b]) > > Initially, it

Re: Is it possible to define ordering functions for own type?

2009-12-06 Thread ataggart
On Dec 6, 8:50 pm, John Ky wrote: > Hi, > > Is it possible to define the functions >, <, >=, <=, ==, min, and max for my > own defstruct type? > > My type is: > > (defstruct deadline :value) > > where I initialise value with an object of type long. > > Thanks > > -John The functions >, <, >=, <=

Re: Multiple dispatch with Multimethods

2009-12-07 Thread ataggart
On Dec 7, 1:21 am, Tzach wrote: > Hello > What is the idiomatic way to implement the classic collide-with > function in Clojure? > I would like to implement something similar to the following (pseudo > code ahead): > > (defmulti collide-with foo) > > (defmethod collide-with ["asteroid" "spaceshi

Re: How to use/refer to multiple Clojure classes

2009-12-07 Thread ataggart
On Nov 30, 9:21 am, Dan Kefford wrote: > OK... I'm trying to take Clojure for a spin on Project Euler problems. > I have source files for each problem that I have solved and although I > can refer to and invoke any one of them explicitly from a main class, > I cannot seem to figure out how to re

Re: Datatypes and protocols - update

2009-12-07 Thread ataggart
On Dec 7, 9:07 am, Laurent PETIT wrote: > 2009/12/7 Hugo Duncan > > > On Mon, 07 Dec 2009 06:53:38 -0500, Rich Hickey > > wrote: > > > > Yes, methods are not really functions. Thinking about them as closures > > > over the object is a good way to go - you can see that analogy in play > > > whe

Re: Datatypes and protocols - update

2009-12-07 Thread ataggart
On Dec 7, 11:23 am, ataggart wrote: > On Dec 7, 9:07 am, Laurent PETIT wrote: > > > > > > > 2009/12/7 Hugo Duncan > > > > On Mon, 07 Dec 2009 06:53:38 -0500, Rich Hickey > > > wrote: > > > > > Yes, methods are not really functions.

Re: The new deftype and multimethod dispatching

2009-12-07 Thread ataggart
On Dec 7, 12:37 pm, Bob Hutchison wrote: > On 7-Dec-09, at 12:17 PM, Laurent PETIT wrote: > > > > > > > 2009/12/6 Bob Hutchison > > >> On 6-Dec-09, at 3:46 PM, Meikel Brandmeyer wrote: > > >>> Hi, > > >>> Am 06.12.2009 um 21:29 schrieb Bob Hutchison: > > It turns out that dispatching on pl

Re: new API webpage format

2009-12-07 Thread ataggart
While we're throwing requests at Tom, it'd be nice if the special forms were included in the api. On Dec 7, 5:21 pm, Tom Faulhaber wrote: > Yup, I heard that the first time :-) > > It's coming, but not right this sec. > > Tom > > On Dec 7, 4:57 pm, Howard Lewis Ship wrote: > > > > > I still thin

Re: Trouble implementing Dijkstra algorithm in Clojure

2009-12-07 Thread ataggart
On Dec 7, 4:19 pm, ajay wrote: > Hi all, > > I am new to FP in general and I am trying to pick up Clojure. I am > having trouble thinking in FP terms. > > I am trying to implement the Dijkstra algorithm for shortest paths in > Graph in Clojure. If this succeeds, I will implement all the advanced

Re: Trouble implementing Dijkstra algorithm in Clojure

2009-12-08 Thread ataggart
; heap implementation.  I wrote one myself as part of an exercise (I > implemented a simple Huffman-coder), but I'm not sure it's release > quality.  Otherwise, I'd be happy to donate it to contrib.  Maybe I'll > try to clean it up and send it off for a review. > >

Re: Trouble implementing Dijkstra algorithm in Clojure

2009-12-08 Thread ataggart
age -- > From: ataggart > Date: Tue, Dec 8, 2009 at 6:22 PM > Subject: Re: Trouble implementing Dijkstra algorithm in Clojure > To: Clojure > > On Dec 8, 11:38 am, Mark Tomko wrote: > > A priority queue implemented over a heap would be more efficient than > &g

Re: How to internally refer to other keys in a hashmap?

2009-12-09 Thread ataggart
On Dec 9, 10:20 am, bOR_ wrote: > Hi all, > > I want to make a hash-map where the value of one key depends on the > values of other keys in the hash-map. Is there a way to do this, > without needing an external reference to the hash-map? > > {:a 1 :b 2 :c #(+ :a :b)} > > Similarly, when filling

Re: lazy sequence question

2009-12-09 Thread ataggart
On Dec 9, 9:46 pm, Mark Engelberg wrote: > There are only 9 items that satisfy your predicate.  (take 10 ...) > demands a 10th, and it keeps searching the (iterate inc 1) stream > forever, endlessly searching for that 10th item it will never find. Aww. You make it sound so sad. -- You receive

Re: update-in and get-in why no default?

2009-12-10 Thread ataggart
Seconded; I like the intention of both changes, and do something similar in a lot of my code (e.g., parsing functions that take an extra arg if the parse is unsuccessful). Also, testing the type of update-in2's second arg is a bad idea, imo. As for the breaking change of adding another arg to upd

Re: Code arrangement for understandability

2009-12-10 Thread ataggart
On Dec 10, 11:02 am, Richard Newman wrote: > > They're especially useful for inserting println calls for seeing the > > value of something when I'm debugging; in fact, this is the primary > > way I do debugging. > > (defn tee (x) >    (println "Debug: " (prn-str x)) >    x) > > (let [x (tee (foo

Re: Code arrangement for understandability

2009-12-11 Thread ataggart
On Dec 11, 1:14 am, ngocdaothanh wrote: > > Do you come from a Python background? > > For the sake of this discussion, I would say I come from Erlang. > > > Judging by you examples, I looks like you're still getting used to the lisp > > style of coding.  Everything is a chained function call. > >

Re: AbstractMethodError question

2009-12-11 Thread ataggart
On Dec 11, 12:27 pm, Keith Irwin wrote: > Folks-- > > I've got a class I can't change which has an abstract method I'd like > to override using the proxy macro in Clojure. > > The class looks something like: > > public abstract class Foo { > >    private Map stuff; > >    private void initStuff(

Re: AbstractMethodError question

2009-12-11 Thread ataggart
On Dec 11, 12:44 pm, Keith Irwin wrote: > On Fri, Dec 11, 2009 at 12:27 PM, Keith Irwin wrote: > > public abstract class Foo { > > >    private Map stuff; > > >    private void initStuff() { > > >        stuff = new HashMap(); > >        stuff.put("a", new Object()); > >        addStuff(stuff);

Re: Idiomatic way to return the key of a map, which matches a vector containing a search value.

2009-12-11 Thread ataggart
On Dec 11, 10:44 am, mudphone wrote: > Thanks for the suggestions. > > I think since the original version short circuits when it finds a > result (using "some"), that's probably what I have to stick with. Sean's solution does as well. -- You received this message because you are subscribed to

Re: Code arrangement for understandability

2009-12-11 Thread ataggart
On Dec 11, 10:33 pm, Richard Newman wrote: > > (reduce (fn [model f] (assoc model f (inc (get model f 1 > >        {} features)) > > > Do Clojurians usually arrange like that? Can it be rearrange for more > > understandability? > > I can't speak for everyone, but I don't think it's common to

Re: Datatypes and protocols - update

2009-12-11 Thread ataggart
On Dec 11, 4:14 pm, Jason Wolfe wrote: > I've been trying out the new branch, and on the whole I like it a lot. >  I know it'll take some time to learn how do things properly the "new" > way, and I've figured out how to do most of the things I want to do > thus far.  Thanks, Rich! > > One thing

Re: Datatypes and protocols - update

2009-12-11 Thread ataggart
On Dec 11, 11:44 pm, ataggart wrote: > On Dec 11, 4:14 pm, Jason Wolfe wrote: > > > > > > > I've been trying out the new branch, and on the whole I like it a lot. > >  I know it'll take some time to learn how do things properly the "new" &

Re: Datatypes and protocols - update

2009-12-12 Thread ataggart
On Dec 11, 11:56 pm, ataggart wrote: > On Dec 11, 11:44 pm, ataggart wrote: > > > > > > > On Dec 11, 4:14 pm, Jason Wolfe wrote: > > > > I've been trying out the new branch, and on the whole I like it a lot. > > >  I know it'll

Re: more dumb noob pain ("2dplot.clj")

2009-12-12 Thread ataggart
If it's a java project, then you can just select the jars, right- click, choose Build Path > Add to Build Path. You can also do it through Project > Properties >Java Build Path. On Dec 12, 6:32 pm, rebcabin wrote: > I got a lot closer thanks to the great hints above; the current state > is this

Re: Heap implementation in Clojure

2009-12-15 Thread ataggart
On Dec 14, 5:48 am, Mark Tomko wrote: > I wrote this implementation of a heap (or priority queue) in pure > Clojure: > > http://pastebin.com/m2ab1ad5a > > It's probably not of any quality sufficient to be make it to the > contrib package, but it seems to work.  Any thoughts on how it might > be

Re: struct-maps and key removal

2009-12-15 Thread ataggart
On Dec 14, 11:23 pm, Richard Newman wrote: > Something I keep bumping into: the SQL library returns rows as struct- > maps. Often I want to do things like rename keys (:foo_bar => :foo- > bar), strip out :id columns, etc. > > Nope! > >    java.lang.Exception: Can't remove struct key > > Any opin

Re: Heap implementation in Clojure

2009-12-15 Thread ataggart
On Dec 15, 1:49 am, ataggart wrote: > On Dec 14, 5:48 am, Mark Tomko wrote: > > > I wrote this implementation of a heap (or priority queue) in pure > > Clojure: > > >http://pastebin.com/m2ab1ad5a > > > It's probably not of any quality sufficient to be m

Re: How to modify the last few elements of a vector

2009-12-16 Thread ataggart
On Dec 16, 10:33 am, samppi wrote: > I'm using a vector as a stack. I want to apply a function–let's call > it modify-element, one argument—to the elements from k to (- (count a- > vector) k). > > Right now, I have something like (not tested yet): >   (reduce #(update-in %1 [%2] modify-element)

Re: A tale of cond, clauses, and the docs

2009-12-20 Thread ataggart
On Dec 19, 8:02 pm, Mike K wrote: > [:foo] evaluates to true by virtue of being a keyword. To be precise, it evaluates to true by virtue of it not being nil nor boolean false; being a keyword doesn't really have anything to do with it. user=> (cond nil :n false :f (Object.) :t) :t -- You rec

  1   2   3   4   >