Re: is mod correct?

2009-02-10 Thread Mark Engelberg
I was the source of this error, and I agree that the behavior is an error. I missed the case of a negative divisor and a 0 remainder among my test cases for the mod function. Thanks for noticing and fixing the problem. Although Chouser's version is slightly more compact than Pratley's, I

Re: Fully lazy sequences are coming - feedback wanted!

2009-02-15 Thread Mark Engelberg
My thoughts so far: 1. It always troubled me that filter, when written in the most natural way, had a hang on to the head problem when skipping over large numbers of items. I think this is something worth solving, and I'm glad that while developing the lazier branch, you came up with a

Re: Fully lazy sequences are coming - feedback wanted!

2009-02-15 Thread Mark Engelberg
On Sun, Feb 15, 2009 at 6:44 PM, Rich Hickey richhic...@gmail.com wrote: I realize you are focused on filter, but that point of the fully lazy branch is full laziness, which would not fall out of what you describe. lazy-cons requires the lazy sequence function do all the work that precedes

Re: Fully lazy sequences are coming - feedback wanted!

2009-02-16 Thread Mark Engelberg
Browsing the source code for LazySeq, I noticed that isEmpty is implemented as follows: public boolean isEmpty() { return count() == 0; } Since count realizes the whole list, this seems like a bad way to test for empty on a lazy sequence.

Re: How do I do this in clojure?

2009-02-16 Thread Mark Engelberg
Suggestion: Provide a statement of purpose as to what this function is supposed to do. What are its inputs and what is its output? Can you break it down into smaller functions? Right now you have a complicated function that takes no inputs and always produces the same string. It seems

Re: new laziness: terminology help

2009-02-24 Thread Mark Engelberg
I believe that one of Rich's stated purposes with the latest revision of the laziness branch was to get rid of some of the subtle differences between these terms after all the discussions about this. I think that with the new changes the intent is: seq (noun) = sequence = ISeq, i.e., anything you

Re: new laziness: terminology help

2009-02-25 Thread Mark Engelberg
On Wed, Feb 25, 2009 at 6:59 AM, Stuart Halloway I believe it would be simpler to leave out this footnote. In my perfect world, seq/ISeq/sequence are synonyms, and nillability is a property only of *functions*: seq and next. I understand why it is useful to use the noun seq to mean the forced

(rest ())

2009-02-27 Thread Mark Engelberg
Maybe it doesn't matter in practice, but does it seem odd to anyone else that (rest ()) returns () rather than nil? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: (rest ())

2009-02-27 Thread Mark Engelberg
Were you thinking of what's now called next and used to be called rest? No. Why did you expect nil from rest in this case? I expect: (rest [1]) - () (rest []) - nil Starting with the new lazier branch, we have a concept of an empty sequence. So the rest of a singleton yields an empty

Observations about new lazy branch

2009-02-27 Thread Mark Engelberg
I just finished porting my combinatorics code to the new lazy constructs, and I discovered some subtleties to using lazy-seq that were not at first apparent. To begin with, consider the two versions of map: The old way: (defn map ([f coll] (when (seq coll) (lazy-cons (f (first coll))

Re: Observations about new lazy branch

2009-02-27 Thread Mark Engelberg
On Fri, Feb 27, 2009 at 8:33 PM, Jason Wolfe jawo...@berkeley.edu wrote: If lazy-cons makes your life easier, I think you can still have something very much like it: (defmacro lazy-cons [x s]  `(lazy-seq (cons ~x (lazy-seq ~s As you pointed out, in most contexts, this will double the

Re: (rest ())

2009-02-28 Thread Mark Engelberg
As Rich explained in one post, in Lisp-like languages, there is a certain amount of intertwining between two views of a sequence which is a series of linked nodes. One way is to think about these nodes as just nodes with a first and rest. Another way is to think about each node as representing

Re: Observations about new lazy branch

2009-02-28 Thread Mark Engelberg
On Sat, Feb 28, 2009 at 6:09 AM, Rich Hickey richhic...@gmail.com wrote: I think your fundamental hangup is on looking at (rest x) as a calculation/effect triggered by a consumer. (rest x) is logically just a slot lookup that obtains another seq. The laziness of that seq is its constructor's

Re: Observations about new lazy branch

2009-02-28 Thread Mark Engelberg
On Sat, Feb 28, 2009 at 6:09 AM, Rich Hickey richhic...@gmail.com wrote: Clojure's fully-lazy now pretty much follows the even model described by Wadler: How to add laziness to a strict language without even being odd: http://homepages.inf.ed.ac.uk/wadler/papers/lazyinstrict/lazyinstrict.ps

Questions about nested associative structures

2009-03-05 Thread Mark Engelberg
1. What is the most elegant way to create/initialize a nested vector, such as to represent a double-dimensioned array? 2. There's get-in for nested structures and get for flat. There's update-in for nested structures, why not plain update for flat? 3. What would you predict to be the most

Comparing lists

2009-03-05 Thread Mark Engelberg
I know that this has been brought up several times here, but I don't recall whether there was ever any resolution: It seems reasonable to expect (compare '(1 2 3) '(4 5)) to do a lexicographic comparison of the two lists, just like (compare [1 2 3] [4 5]) does. Is there an intentional reason

hash-map based on identity

2009-03-06 Thread Mark Engelberg
Is there a variation of hash-map which supports comparison of keys using identical? rather than = ? Ditto with sets. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email

Re: hash-map based on identity

2009-03-07 Thread Mark Engelberg
Here's why it would be useful to have the option of hash maps that use identity... Let's say my keys are rather long lists. Equality comparison will be slow. But if I know that the keys are always the exact same long lists (perhaps because I traversed the key sequence to find a key with a

Re: Workflow poll?

2009-03-07 Thread Mark Engelberg
Anyone using IntelliJ or Netbeans as their primary development environment, or is that stuff too experimental? I've been using the Clojure-in-a-box setup for Windows, which was absolutely instrumental in getting me to try out Clojure. But if I keep downloading the latest versions of Clojure, it

Re: hash-map based on identity

2009-03-07 Thread Mark Engelberg
On Sat, Mar 7, 2009 at 2:57 PM, Rich Hickey richhic...@gmail.com wrote: Identity is tested first in equality, if identical, equal, full stop. So if you are using identical and unique collections as keys you'll find them without a value-by-value comparison. If they are not present, it's

Re: On the importance of recognizing and using maps

2009-03-09 Thread Mark Engelberg
On Sun, Mar 8, 2009 at 10:44 PM, mikel mev...@mac.com wrote: Clojure doesn't have to provide these facilities (though I wouldn't mind if it did); it just needs to stay out of my way when I decide I need to add them. Yeah, as much as I like maps, I feel like there are several common uses cases

Re: naive euler43 blows heap, why?

2009-03-09 Thread Mark Engelberg
On Mon, Mar 9, 2009 at 9:55 AM, Tuomas J. Lukka tuomas.lu...@gmail.com wrote: You are holding on to the head. Try replacing def perms with defn perms [] and calling it when you start using it. That way the permutations are let go as soon as they come. I noticed this with some scripts that go

Re: Static type guy trying to convert

2009-03-10 Thread Mark Engelberg
I think the key to feeling confident in dynamically typed code is to go ahead and write out the contract for the function in your comments. You should always state what the domain and the range of the function are, so that you and other people can use the function appropriately. A static type

Question about throwing errors

2009-03-11 Thread Mark Engelberg
I'm thinking about implementing a backtracking mechanism that throws errors as a way to escape out of the current computation and try another possibility. I'd want to create a specific error to escape, and the backtracking mechanism should only catch this very specific error. Now, I vaguely

Re: Static type guy trying to convert

2009-03-11 Thread Mark Engelberg
I know of someone who tracked all his bugs in a year of coding in both Scheme (dynamic) and ML (static). He said that there was no real difference. The kind of bugs that are caught by static type systems are also quickly identified upon an initial run with a few basic test cases in a dynamic

Java equivalent to Python's Imaging Library (PIL)

2009-03-12 Thread Mark Engelberg
Can anyone point me to a PIL-like library that will work from Clojure? Thanks. --~--~-~--~~~---~--~~ 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 To

Re: Performance tips for Clojure

2009-03-13 Thread Mark Engelberg
list doesn't do what you think it does. You've just created a list of one element. On Fri, Mar 13, 2009 at 12:10 AM, Sergio bigmonac...@gmail.com wrote: (def ls (list (range 100))) --~--~-~--~~~---~--~~ You received this message because you are subscribed

Question about IntelliJ Plugin

2009-03-14 Thread Mark Engelberg
If I split my code across files, how do I make it so that the REPL can see all the code? For example, if I have a main.clj and a tests.clj, when I run the REPL from one of the two files, it only sees the definitions from that file, not everything in the project. What's the right way to do this?

Re: errors?

2009-03-14 Thread Mark Engelberg
But how do you get rid of the (NO_SOURCE_FILE:0) messages for every single error? I'd really like to know the line number of the function that threw the error. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

Re: Which Java book(s) to order

2009-03-16 Thread Mark Engelberg
Of course, with respect to Clojure, probably the most important thing is to learn the Java *libraries*. What are good books about that? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this

Re: Behavior of 'empty'

2009-03-16 Thread Mark Engelberg
On Mon, Mar 16, 2009 at 3:54 PM, Frantisek Sodomka fsodo...@gmail.com wrote: (empty (seq [1 2])) = nil Now that there is the concept of empty sequences, maybe this should actually return an empty sequence, such as (). --~--~-~--~~~---~--~~ You received this

Re: Request Feedback on Clojure Blog Article

2009-03-16 Thread Mark Engelberg
On Mon, Mar 16, 2009 at 9:44 PM, Timothy Pratley timothyprat...@gmail.com wrote: Hi Keith, I don't follow the 'lazy-init' part... It seems to me that you create a delay but force it immediately which is effectively just running create-a-text-field. That behavior seems different from the

Re: Request Feedback on Clojure Blog Article

2009-03-18 Thread Mark Engelberg
On Wed, Mar 18, 2009 at 10:40 PM, Stephen C. Gilardi squee...@mac.com wrote: Because parallel bindings are also useful, I think it's an interesting idea to extend let to allow it to take parallel bindings in a map instead of a vector. These would act like Common Lisp's let:        (def a 4)

Re: What's a convenient way of calling super.method()?

2009-03-21 Thread Mark Engelberg
On Sat, Mar 21, 2009 at 1:38 PM, CuppoJava patrickli_2...@hotmail.com wrote: (mymethod (assoc object :tag :super-class)) which is a little clumsy. Not only is it clumsy, but if mymethod returns a fresh object that is based off of this object in some way (e.g., a non-destructive setter), the

Shouldn't all defs have a - version?

2009-03-23 Thread Mark Engelberg
defn- is pretty useful. But wouldn't it be equally useful to have def-, defmulti-, defmacro-, etc.? I'm aware that it is possible to add the private tag to the metadata of the var, but in many code samples I've seen, people routinely get this wrong (I believe you need to attach the metadata to

Re: What's a convenient way of calling super.method()?

2009-03-23 Thread Mark Engelberg
On Sun, Mar 22, 2009 at 1:17 PM, CuppoJava patrickli_2...@hotmail.com wrote: So, considering it seems that not many other people have run into this issue, can I assume that most people just haven't had a need to call a super multi-method? Is it a bad design choice to call your inherited

Information Hiding

2009-03-23 Thread Mark Engelberg
I've been thinking quite a bit about the OO side of Clojure the past couple of days, and trying to figure out how common OO design patterns would look when ported over to Clojure's way of doing things. The most obvious thing that others have noted is that you can effectively simulate a mutable

Re: Mapping a function over a map's values

2009-03-23 Thread Mark Engelberg
On Sun, Mar 22, 2009 at 11:53 PM, Jeff Valk jv-li...@tx.rr.com wrote: For the record, I think the original approach is the most clear. And it's actually shorter. (defn mapmap [f m]  (zipmap (keys m) (map f (vals m But it traverses m twice, which is likely to be less efficient.

Re: Clojure talk at TSS

2009-03-23 Thread Mark Engelberg
On Mon, Mar 23, 2009 at 1:45 AM, Howard Lewis Ship hls...@gmail.com wrote: If you have a long running process that continually modifies a collection and retains the new version ... does the new version retain the old version?  For how long? In general, I think it's safe to assume that

Re: Information Hiding

2009-03-23 Thread Mark Engelberg
Yes, the :private metadata tag is probably the simplest way to make the whole object private, and then just expose the manipulation functions. The closure solution is similar in this regard. I guess the point I failed to convey is that I'm really wondering if there's a way to effectively make

Re: Information Hiding

2009-03-23 Thread Mark Engelberg
On Mon, Mar 23, 2009 at 10:09 AM, Konrad Hinsen konrad.hin...@laposte.net wrote: You seem to envisage exposing some aspects of your data structure as part of the public API and have others reserved for use by authorized support function. Could you give an example of a situation where this

Re: I need help tracking down a performance problem.

2009-03-23 Thread Mark Engelberg
On Mon, Mar 23, 2009 at 7:31 PM, Vincent Foley vfo...@gmail.com wrote: More generally, is it possible that I'm just doing this whole thing wrong?  That using vectors to represent binary fields and records in a declarative is just a bad idea and that I should try and explore lower- level

Re: oo

2009-03-25 Thread Mark Engelberg
On Wed, Mar 25, 2009 at 1:44 AM, Konrad Hinsen konrad.hin...@laposte.net wrote: Could you elaborate a bit on this? I haven't met any major obstacles with multimethods yet. The dispatch functions give quite a lot of flexibility in practice. In what situation did you find them inconvenient? To

Re: Clojure + Java compilation and IntelliJ IDEA plugin

2009-03-25 Thread Mark Engelberg
If we've already downloaded the first plugin, what's the best way to upgrade? Do you have to delete the first one, or just install the second on top? Is there a way to update the plugin from within the IDE? Thanks. --~--~-~--~~~---~--~~ You received this

Re: Is Clojure's lack of support for forward referencing a feature or a bug?

2009-03-25 Thread Mark Engelberg
On Wed, Mar 11, 2009 at 5:18 PM, Timothy Pratley timothyprat...@gmail.com wrote: It is also quite trivial to patch the compiler to auto-def symbols as it finds them instead of throwing an error. I would be interested in knowing how to do such a patch. When I work on code, I like to organize

Re: oo

2009-03-27 Thread Mark Engelberg
I'm very interested in this thread. I'm having trouble figuring out exactly which situations require prefer-method and which do not. One thing that would help me understand the issues more deeply would be if someone could post the simplest possible multimethod that requires prefer-method to

Re: oo

2009-03-27 Thread Mark Engelberg
I think I've answered at least part of my own question. This is the simplest ambiguous case I've found: ab | | -- | c user (defmulti test-prefer :tag) #'user/test-prefer user (defmethod test-prefer ::a [h] a) #MultiFn clojure.lang.mult...@6551c1 user (defmethod

Re: bug in clojure.contrib.math/exact-integer-sqrt

2009-03-29 Thread Mark Engelberg
Fixed. Thanks for the report. Aside from being a helper function for sqrt, exact-integer-sqrt is available in some Lisp and Scheme implementations. At first glance, you might think that calling (floor (sqrt n)) is sufficient, and no special function is needed. But for large integers which are

Quick slime/emacs questions

2009-03-29 Thread Mark Engelberg
When I have two windows open, and hit C-x-C-b, it pops up a list of buffers in the OTHER window from where the current focus is. Any idea why it's doing that, and how I can alter the behavior so it pops up the list of buffers in the current window? Also, where can I look up the names of various

Re: bug in clojure.contrib.math/exact-integer-sqrt

2009-03-29 Thread Mark Engelberg
If you don't care about the leftover portion that exact-integer-sqrt returns, you can do something like: (let [[floor-sqrt _] (exact-integer-sqrt n)] ...) or (first (exact-integer-sqrt n)) so I didn't want to expose another function which returns only half of the information that this one does.

Set bug?

2009-03-30 Thread Mark Engelberg
(def a (BigInteger. 123)) (= a 123); this prints true (= (hash a) (hash 123)) ; this also prints true So how come (count #{a 123}) prints 2 ? I'm aware that a and 123 have different types, but I was under the impression that the hash set implementation was supposed to just rely on hash

Re: Quick slime/emacs questions

2009-03-30 Thread Mark Engelberg
I have CUA mode enabled, and it does most of those remappings, but not the C-s for save. I know searching is common, which is why I plan to remap C-f to search. Don't need existing binding for C-f since the arrow keys work just fine for moving around. I don't mind the normal Emacs bindings,

Re: Suggest patch to math.clj - integer-length

2009-03-30 Thread Mark Engelberg
This brings up an interesting question. Does Java guarantee that on all architectures and all future versions that Integers will be 32-bit and Longs will be 64-bit? I think the answer is yes, that this is part of the specification, but I'm not certain.

Re: Set bug?

2009-03-30 Thread Mark Engelberg
My own opinions: I don't expect 1 to equal 1.0 (because I think of inexact numbers as fundamentally different from exact numbers). I think of 1.0 as a number that's so close to 1 that we can't tell the difference, but it still might not be 1. I do expect 1 to equal 1/1, and I expect a long 1 to

Re: Set bug?

2009-03-30 Thread Mark Engelberg
On Mon, Mar 30, 2009 at 10:45 AM, Mark Engelberg mark.engelb...@gmail.com wrote: I don't know whether this fix would be worth the performance penalty, though, but it's what would feel right to me. If it's not practical to always reduce integers when used as keys, then I think it would

Re: Possible Solution for Left-Right Precedence and More when using Multimethods? (was re: oo)

2009-03-31 Thread Mark Engelberg
On Tue, Mar 31, 2009 at 9:45 AM, Konrad Hinsen konrad.hin...@laposte.net wrote: I think this should be sufficient to cover all cases you mentioned, but of course it needs to be tried in practice. I think your idea of specifying a sequence of items to try in the dispatching function, at the

Re: The Path to 1.0

2009-04-17 Thread Mark Engelberg
On Fri, Apr 17, 2009 at 6:21 AM, Rich Hickey richhic...@gmail.com wrote: Overall, I'm getting feature requests (more change!) and not a strong drive for 1.0 stability. If you feel otherwise, please speak up. Otherwise, my conclusion is that 1.0 may be more important for not-yet- users wary of

Re: a functional/persistent priority queue

2009-04-19 Thread Mark Engelberg
I'm curious to know how this approach compares to using Clojure's sorted sets or hash tables. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Modifying data structures without changing their interface

2009-04-20 Thread Mark Engelberg
On Mon, Apr 20, 2009 at 1:27 PM, Bradbev brad.beveri...@gmail.com wrote: If you promise that functions will accept and return maps with certain keys, then you must keep that promise moving forward. I think you're missing part of the point of the original post. You don't really want to

Re: Abstract data types in functional languages

2009-04-21 Thread Mark Engelberg
On Mon, Apr 20, 2009 at 11:00 AM, Timo Mihaljov noid@gmail.com wrote: Is the concept of Abstract Data Types [1] useful in Clojure? If yes, how would you implement one? I have composed a lengthy response to this question, and added it to my blog:

Re: ICFP 2009

2009-04-22 Thread Mark Engelberg
Try your hand at one of the older contests, like this one: http://www.boundvariable.org/task.shtml --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Abstract data types in functional languages

2009-04-23 Thread Mark Engelberg
In Clojure, the closest thing to an object (short of implementing a class in Java or using gen-class) is the map. But the more I play around with using maps to implement the kinds of things that objects are used for in other languages, the more I'm feeling that maps don't quite cut it. One

Re: Abstract data types in functional languages

2009-04-24 Thread Mark Engelberg
Laurent, I think we're actually mostly in agreement here, although we differ on some of the details. I agree with the Principle of Uniform Access. One interpretation of this principle is that coders should never have a public field, and should always use getters and setters, to make the API

Re: Metadata for Any Object

2009-04-30 Thread Mark Engelberg
On Thu, Apr 30, 2009 at 6:01 AM, Rich Hickey richhic...@gmail.com wrote: Then, you need to know which operations require metadata propagation. That's built into the Clojure data structures but can't be retrofitted to arbitrary types. Is there a list of which operations propagate metadata? I

Re: Metadata for Any Object

2009-04-30 Thread Mark Engelberg
On Thu, Apr 30, 2009 at 9:46 AM, Rich Hickey richhic...@gmail.com wrote: However, there isn't a list, and metadata propagation could use an audit. If there's a specific case where you think it should and it doesn't please let me know. I think it just took me a while to figure out that cons

Re: The Santa Claus Problem

2009-05-07 Thread Mark Engelberg
On Wed, May 6, 2009 at 12:38 AM, bOR_ boris.sch...@gmail.com wrote: If i remember correctly, any agents send (or send-off?) within a dosync are only send off after the dosync completed. Yes, that's the kind of semantics I want, but it would be rather clunky to have to set up an agent and fake

implicit dosync?

2009-05-11 Thread Mark Engelberg
I'm curious, wouldn't it be possible for every ref-set to be implicitly wrapped in a dosync? That way, you wouldn't have to explictly wrap ref-set in a dosync for the times where you just want to change one ref. You'd only need to explicitly call dosync when you need to wrap more than one

Breaking out of infinite loops

2009-05-12 Thread Mark Engelberg
I often write code that I just want to run in an infinite loop. The code generates lots of random things, and logs the interesting ones to a file. In Python, I'd write such code inside a try block that catches the Ctrl-C exception. So, when I want to use my computer for something else, I just

Re: list vs vector

2009-05-16 Thread Mark Engelberg
In my own experimentation, I was really surprised to find that traversal over vectors seemed to be faster than lists, so I tend to use vectors rather than lists for any fixed collection that I'm basically just traversing once I've built. Haven't benchmarked recently, though, so this could have

Question about building modular code in Clojure

2009-05-16 Thread Mark Engelberg
So I've built a file/namespace with several functions. There are several globals defined at the top of the file (for example, *gravity*) which many of the functions refer to. I made them globals precisely because it would have been a pain to thread them through every single function that uses

Re: Question about building modular code in Clojure

2009-05-17 Thread Mark Engelberg
Thanks for your questions. I'll try to explain better. First, I'll explain that my line of work is to build tools to generate puzzles. I often have a module which generates the puzzles through various random processes, using certain probabilities and parameters. Then, I have another module

Re: Question about building modular code in Clojure

2009-05-17 Thread Mark Engelberg
On Sun, May 17, 2009 at 2:18 PM, mikel mev...@mac.com wrote: I'm still not quite clear on exactly what you're trying to accomplish. You showed how to accomplish your purpose in Clojure, but then suggested that the result was not 'clean'. It's not quite clear what you mean by 'clean'--that is,

Re: Question about building modular code in Clojure

2009-05-17 Thread Mark Engelberg
On Sun, May 17, 2009 at 8:12 PM, David Nolen dnolen.li...@gmail.com wrote: Have you looked at the immigrate function in Compojure? This imports public vars from a different namespace into a namespace as if they were defined there.  Maybe this is enough to get the behavior that you want? Not

Re: Question about building modular code in Clojure

2009-05-18 Thread Mark Engelberg
David, that seems to work. I think I can achieve my objectives with this strategy. However, I must admit, I find it rather unsettling that collections of functions written inside of namespaces are fundamentally less composable than those that are not. It means that to remain extensible, I need

Re: Question about building modular code in Clojure

2009-05-18 Thread Mark Engelberg
BTW, for those of you interested in reading academic papers about modules in functional programming langs, I found this list of articles: http://www.readscheme.org/modules/ I remember reading about PLT Scheme's units several years ago, and I think it's pretty much what I'm looking for, with the

Re: Question about building modular code in Clojure

2009-05-18 Thread Mark Engelberg
On Sun, May 17, 2009 at 11:48 PM, Konrad Hinsen konrad.hin...@laposte.net wrote: It's the approach of cloning and mutating something that smells of quick and dirty, although I agree it is quite convenient in the prototyping phase. I disagree that incremental extension of a module is a quick

Re: Question about building modular code in Clojure

2009-05-18 Thread Mark Engelberg
On Mon, May 18, 2009 at 1:17 AM, Adrian Cuthbertson adrian.cuthbert...@gmail.com wrote: (alter-var-root (var say-grav) (fn [_] (fn [x] (prn my-version-grav: x But this only works if you only want one variation, and you no longer care about the original version, right?. If you want to

Re: Question about building modular code in Clojure

2009-05-18 Thread Mark Engelberg
On Mon, May 18, 2009 at 4:23 AM, Laurent PETIT laurent.pe...@gmail.com wrote: The most modular I can think of right now is just about creating a gravity type and using multimethods for all your functions. This way you would have dynamic resolution of methods that do not work with precompiled

Re: Question about building modular code in Clojure

2009-05-18 Thread Mark Engelberg
On Mon, May 18, 2009 at 2:16 AM, Meikel Brandmeyer m...@kotka.de wrote: If that is true, you should maybe consider some glue.     /- Analysis Glue -- Solve     \- Create The Glue part combines/uses the different modules. There you could change parameters easily with binding, swap in

Re: Clojure at JavaOne

2009-05-18 Thread Mark Engelberg
For me, persistent vectors was the killer feature that drew me to Clojure. Don't know how to convey the value of that in 4 minutes, though. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to

Re: Question about building modular code in Clojure

2009-05-19 Thread Mark Engelberg
On Tue, May 19, 2009 at 6:18 AM, Meikel Brandmeyer m...@kotka.de wrote: I think the idea of decoupling is called inversion of control or dependency injection. I'm sure it works for you, but it sure did in this (admittedly) simple example. There are various ways at passing around parameter: -

Re: Question about building modular code in Clojure

2009-05-19 Thread Mark Engelberg
On Tue, May 19, 2009 at 9:08 PM, George Jahad andr...@blackbirdsystems.net wrote: ] It seems like what you are really trying to do is simulate inheritance/overriding in clojure.  What's wrong with using gen-class and proxy for that? I guess it's still an open question as to whether gen-class

Re: Question about building modular code in Clojure

2009-05-22 Thread Mark Engelberg
On Fri, May 22, 2009 at 1:37 AM, Konrad Hinsen konrad.hin...@laposte.net wrote: As long as it uses the same variables as the template, it would still work, but (like the load-and-redefine method) it would fail as soon as the template author decides to change the names of his variables. I

Re: compilation and classpath

2009-05-22 Thread Mark Engelberg
I also had lots of problems getting compilation to work. I think perhaps Clojure is making some assumptions about where your working directory is located relative to your clojure.jar and classpath, and if you have a different directory structure, things fail. For me, the solution was to

Re: Question about building modular code in Clojure

2009-05-22 Thread Mark Engelberg
OK, after looking at deftemplate with macroexpand, it's starting to make more sense. I suppose one downside to this versus load is that it's probably much more difficult to debug (just because all your code is wrapped in a macro), but basically I like the idea.

Scoping question

2009-05-27 Thread Mark Engelberg
Is there any practical difference between: (let [x 2] (defn f [] x)) and (def f (let [x 2] (fn [] x)))? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Scoping question

2009-05-27 Thread Mark Engelberg
No, I was just worried that using def/defn not at the top level, but inside a let, might have unforeseen consequences. On Wed, May 27, 2009 at 3:48 AM, Rich Hickey richhic...@gmail.com wrote: No, are you experiencing one? --~--~-~--~~~---~--~~ You received this

Re: Clojure Book example that has unexpected effect in trunk version of Clojure

2009-05-31 Thread Mark Engelberg
I posted about this recently. In emacs/slime, printed output on other threads does not appear. I have not found a workaround, other than running such code in a standard REPL. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Re: Clojure Book example that has unexpected effect in trunk version of Clojure

2009-06-01 Thread Mark Engelberg
What happens to compile errors once you make that change. Do they end up in the REPL too? --~--~-~--~~~---~--~~ 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

Re: Elegant but very slow

2008-12-04 Thread Mark Engelberg
I already tried bOR's two suggestions (replace anonymous function with + and type hinting), but they made no difference on my machine. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this

Re: Atoms

2008-12-04 Thread Mark Engelberg
Didn't commute essentially give this behavior for refs? How is this different? On Thu, Dec 4, 2008 at 5:02 PM, Rich Hickey [EMAIL PROTECTED] wrote: I've added a new reference type - atom. --~--~-~--~~~---~--~~ You received this message because you are

Re: Atoms

2008-12-05 Thread Mark Engelberg
So, earlier, I asked how atoms differ from using commute on refs. It sounds like the answer is that if you use atoms in a larger transaction, then as soon as the atom set is encountered, it actually changes instantly, so if you rollback, and do the transaction again, it's already been set, and

Re: Elegant but very slow

2008-12-06 Thread Mark Engelberg
Has anyone been able to use type hints to successfully close the last bit of difference between the Clojure and Java version on this benchmark? On Sat, Dec 6, 2008 at 6:14 AM, PeterB [EMAIL PROTECTED] wrote: Running in Clojure REPL for java 1.6.0_11 with -server option: result: -2

Re: memory issue with nth

2008-12-06 Thread Mark Engelberg
It doesn't blow the heap on my machine, using the Clojure in a Box setup, and I only have 1GB of memory total. I added a couple 0s, and it didn't make a difference. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

Re: Running out of memory when using filter?

2008-12-06 Thread Mark Engelberg
Except your version of filter doesn't do any filtering on the rest in the case where the first satisfies the predicate. On Sat, Dec 6, 2008 at 7:43 PM, Stephen C. Gilardi [EMAIL PROTECTED] wrote: If you use a definition of filter like this in your test, I think it will succeed: (defn

Re: Running out of memory when using filter?

2008-12-06 Thread Mark Engelberg
Well, part of the puzzle is to figure out why filter works just fine on the output of the range function, but not on the output of the map function. I'm starting to wonder whether there might be a fundamental bug in the java implementation of LazyCons. Maybe it doesn't implement first

Emacs / Slime questions

2008-12-07 Thread Mark Engelberg
I'm using Clojure Box on Windows. It's working well for me, but I have a number of questions: 1. I see that you can use C-c C-c to feed the definition your cursor is on to the REPL. How do you feed the entire file to the REPL? 2. How do I restart the REPL, so that any definitions are erased

Re: Emacs / Slime questions

2008-12-07 Thread Mark Engelberg
Thanks for all the info. I've searched my whole hard drive for a .emacs file, and can't find one. Can someone tell me where Clojure Box stores this file, or whether it's called something entirely different? --Mark --~--~-~--~~~---~--~~ You received this message

Re: Running out of memory when using filter?

2008-12-08 Thread Mark Engelberg
Has anyone made progress on this bug? The simplest form of the bug was this: (defn splode [n] (doseq [i (filter #(= % 20) (map inc (range n)))])) This blows the heap, but it shouldn't. I find this deeply troubling, because if this doesn't work, it undermines my faith in the implementation

Re: Running out of memory when using filter?

2008-12-08 Thread Mark Engelberg
On Mon, Dec 8, 2008 at 5:56 PM, Stephen C. Gilardi [EMAIL PROTECTED] wrote: I think I finally see the problem. The rest expression in filter's call to lazy-cons has a reference to coll in it. That's all it takes for coll to be retained during the entire calculation of the rest. Well, I had

  1   2   3   4   5   6   7   8   9   10   >