Re: Datatypes and Protocols - early experience program

2009-11-15 Thread Michael Wood
2009/11/16 John Harrop : > On Sun, Nov 15, 2009 at 8:17 PM, David Brown wrote: >> >> On Sun, Nov 15, 2009 at 04:20:19PM -0500, John Harrop wrote: >> >> >That's weird. It's not documented anywhere on the site. And it seems to >> > hang >> >the REPL: >> > >> >user=> nil #!foo >> > >> >and nothing. E

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-15 Thread ajuc
On 16 Lis, 01:32, Alex Osborne wrote: > Clojure's name gives a hint as to how do this: use a closure. :-)  Just > pull the let outside the defn: > > (let [hilbert-map {...}] >    (defn point-to-hilbert [...] >      ...)) Now it seems so obvious :). I guess I don't think functional yet. Thank yo

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-15 Thread Alex Osborne
John Harrop wrote: > On Sun, Nov 15, 2009 at 7:32 PM, Alex Osborne > wrote: > > ajuc wrote: > > I would like to somehow hide the global hilbert-map into my function, > > but I can't see how to do that. > > Clojure's name gives a hint as to how do this: us

Re: Datatypes and Protocols - early experience program

2009-11-15 Thread John Harrop
On Sun, Nov 15, 2009 at 8:17 PM, David Brown wrote: > On Sun, Nov 15, 2009 at 04:20:19PM -0500, John Harrop wrote: > > >That's weird. It's not documented anywhere on the site. And it seems to > hang > >the REPL: > > > >user=> nil #!foo > > > >and nothing. Enter doesn't print "nil" and a fresh use

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-15 Thread John Harrop
On Sun, Nov 15, 2009 at 7:32 PM, Alex Osborne wrote: > ajuc wrote: > > I would like to somehow hide the global hilbert-map into my function, > > but I can't see how to do that. > > > > Is this possible? I know that I can just inert literal into my let, > > but that degrades performance, when func

Re: A macro for flexible keyword argument handling

2009-11-15 Thread Constantine Vetoshev
Looks like Google Groups posting software forced line wraps at less than 80 columns, breaking the code. Lovely. Here's the fn-keywords macro reformatted for 72 column wrapping. (defmacro fn-keywords "Adds flexible keyword handling to any form which has a parameter list: fn, defn, defmethod, l

A macro for flexible keyword argument handling

2009-11-15 Thread Constantine Vetoshev
A couple of days ago, I finally had enough of manually extracting function keyword arguments. defnk is cool and all, but it does nothing for fn, letfn, defmethod, or any other form with a parameter list. Map destructuring is also cool, but providing defaults requires writing each symbol twice, once

Re: Datatypes and Protocols - early experience program

2009-11-15 Thread David Brown
On Sun, Nov 15, 2009 at 04:20:19PM -0500, John Harrop wrote: >That's weird. It's not documented anywhere on the site. And it seems to hang >the REPL: > >user=> nil #!foo > >and nothing. Enter doesn't print "nil" and a fresh user=> prompt as it >should and nothing else apparently works either. The

Re: idomatic sudoku?

2009-11-15 Thread David Brown
On Sun, Nov 15, 2009 at 09:43:38PM +0100, B Smith-Mannschott wrote: >On Sun, Oct 11, 2009 at 22:12, Matt Wilson wrote: >> The only hassle with a map is that iterating over it (in my case, with >> a `for`) turns it into a list of [key value], which makes it a pain to >> turn back into a map once y

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-15 Thread Alex Osborne
ajuc wrote: > I would like to somehow hide the global hilbert-map into my function, > but I can't see how to do that. > > Is this possible? I know that I can just inert literal into my let, > but that degrades performance, when function is called many times. > > I would like to have something lik

Clojure & Terracotta - TIM

2009-11-15 Thread Sergey Didenko
Hi from a Clojure newbie! I have read the april thread "Clojure + Terracotta Update" and it looks pretty positive. A few question for TIM users: Is there newer version than http://github.com/pjstadig/tim-clojure-1.0-snapshot ? Are there still bugs? Can it be called production ready? Regards,

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-15 Thread John Harrop
Interesting. It looks like Clojure's missing a few obvious optimizations, and is reconstructing the literal structure each time the function is called, or each time the value is used if the literal is directly at point of use. On the other hand, deref of a global is not exactly blindingly fast eit

Re: Datatypes and Protocols - early experience program

2009-11-15 Thread John Harrop
On Sun, Nov 15, 2009 at 8:45 AM, Michael Wood wrote: > 2009/11/14 John Harrop : > > On Sat, Nov 14, 2009 at 1:42 PM, Richard Newman > wrote: > >> > >> I like CL's package support for this kind of situation, where > >> unexported symbols can still be reached via foo::bar, at the cost of > >> an o

Re: Map a list of agents to a list of their values

2009-11-15 Thread John Harrop
On Sat, Nov 14, 2009 at 6:03 PM, Meikel Brandmeyer wrote: > Hi, > > Am 14.11.2009 um 20:31 schrieb John Harrop: > > > For situations like this, I find it handy to discover what reader-macros >> are expanding to. This works well: >> >> user=>(defmacro expand [arg] (println arg)) >> #'user/expand

Re: idomatic sudoku?

2009-11-15 Thread B Smith-Mannschott
On Sun, Oct 11, 2009 at 22:12, Matt Wilson wrote: > > My approach (which I might upload once I've tidied it up a bit) was to > use a hash-map of [x y] cell coordinates to a set of all remaining > numbers. So, something like: > > {[0 0] #{1 2 3 4} [0 1] #{5 6 7 8} …} > > Then I just made some funct

Re: clojure event handling

2009-11-15 Thread nchubrich
Thanks for posting these examples; I'd never thought of using multimethods that way. And thanks for the Swing example. I'm really interested in functional-reactive programming; hope we see lots of that stuff in Clojure. Anyone ever used FrTime in PLT? Here's the Swing events without the S

Re: Mocking (with EasyMock?) java calls

2009-11-15 Thread ronen
Id recommend using mockito instead: http://mockito.org/ On Nov 12, 1:55 am, Howard Lewis Ship wrote: > Try looking at this: > > http://github.com/hlship/cascade/blob/master/src/main/clojure/cascade... > > > > On Thu, Nov 5, 2009 at 5:00 AM, vanallan wrote: > > > Hi > > Im trying to convert a co

Re: Some questions about core.clj implementation

2009-11-15 Thread Meikel Brandmeyer
Hi, Am 15.11.2009 um 14:51 schrieb Angel Java Lopez: 2) The cond macro is defined: (defmacro cond "Takes a set of test/expr pairs. It evaluates each test one at a time. If a test returns logical true, cond evaluates and returns the value of the corresponding expr and doesn't evaluate an

Re: SLIME REPL broken

2009-11-15 Thread Cyrus Harmon
Heh: ";; Yeah, I'm lazy -- I'll flesh this out later" Not sure if that's related to the problem, but it's amusing at least. Cyrus On Nov 15, 2009, at 6:21 AM, Stefan Kamphausen wrote: > Hi, > > a short discussion on the SLIME mailinglist lead to the result that > the arglist of a backend f

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-15 Thread Michael Wood
2009/11/15 ajuc : > >> That's very odd. >> >> Rich needs to take a look at this. Letting a constant shouldn't have a >> performance hit, IMO. >> >> Could you test whether it's faster to use your complex data structure >> directly in the function, anonymously at the point of use, or to yank it >> fr

SLIME REPL broken

2009-11-15 Thread Stefan Kamphausen
Hi, a short discussion on the SLIME mailinglist lead to the result that the arglist of a backend function in swank did change. Current checkouts of SLIME do not work with Clojure, at least if you use autodoc. http://common-lisp.net/pipermail/slime-devel/2009-November/016919.html I took a quick

Re: Some questions about core.clj implementation

2009-11-15 Thread Michael Wood
2009/11/15 Angel Java Lopez : [...] > (defn spread >   {:private true} >   [arglist] >   (cond >    (nil? arglist) nil >    (nil? (next arglist)) (seq (first arglist)) >    :else (cons (first arglist) (spread (next arglist) > > Where is defined :else keyword behaviour? I can't find how :else is

Re: Clojure Web Libraries

2009-11-15 Thread Stefan Tilkov
On Nov 15, 2009, at 4:58 AM, ngocdaothanh wrote: > Hi Stuart, > > Can you elaborate on Restlet? After some short investigation I think > it uses annotation but Clojure does not support it, so Clojure is not > "Restlet-ready". > Only the JSR-311 (JAX-RS) API uses annotations. Restlet has a lower

Some questions about core.clj implementation

2009-11-15 Thread Angel Java Lopez
Hi people! I'm working on reimplement core.clj using my own C# interpreter for a clojure-like language. Browsing in the 1.0.0 source code of core.clj, I have some questions: 1: this is defn definition: (def #^{:doc "Same as (def name (fn [params* ] exprs*)) or (def name (fn ([params* ] exp

Re: Datatypes and Protocols - early experience program

2009-11-15 Thread Michael Wood
2009/11/14 John Harrop : > On Sat, Nov 14, 2009 at 1:42 PM, Richard Newman wrote: >> >> I like CL's package support for this kind of situation, where >> unexported symbols can still be reached via foo::bar, at the cost of >> an obvious "code smell". > > This suggests an alternate fix for the priva

Re: Map a list of agents to a list of their values

2009-11-15 Thread Meikel Brandmeyer
Hi, Am 14.11.2009 um 20:31 schrieb John Harrop: For situations like this, I find it handy to discover what reader- macros are expanding to. This works well: user=>(defmacro expand [arg] (println arg)) #'user/expand user=>(expand #(@%)) (fn* [p1__6536] ((clojure.core/deref p1__6536))) user=>

Re: swap two elements in an arbitrary collection

2009-11-15 Thread Meikel Brandmeyer
Hi, Am 13.11.2009 um 17:29 schrieb Lauri Pesonen: I hope this helps. I don't think I did a particularly good job in explaining how the macro works... And there is always macroexpand(-1)... user=> (macroexpand-1 '(-> foo (bar baz))) (bar foo baz) Sincerely Meikel smime.p7s Description:

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-15 Thread ajuc
> That's very odd. > > Rich needs to take a look at this. Letting a constant shouldn't have a > performance hit, IMO. > > Could you test whether it's faster to use your complex data structure > directly in the function, anonymously at the point of use, or to yank it > from a global var? Code (can

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-15 Thread John Harrop
On Sun, Nov 15, 2009 at 4:49 AM, ajuc wrote: > On 15 Lis, 00:21, John Harrop wrote: > > On Sat, Nov 14, 2009 at 3:03 PM, ajuc wrote: > > > I have to install java one more time, when I try to start java - > > > server, I get: > > > Error: no `server' JVM at `F:\Program Files\Java\jre6\bin\server

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-15 Thread ajuc
On 15 Lis, 00:21, John Harrop wrote: > On Sat, Nov 14, 2009 at 3:03 PM, ajuc wrote: > > I have to install java one more time, when I try to start java - > > server, I get: > > Error: no `server' JVM at `F:\Program Files\Java\jre6\bin\server > > \jvm.dll > > You need to use the one in F:\Program

Re: Deep deref

2009-11-15 Thread Danny Woods
> Danny, could you maybe hack up a possible very simple example of what > you mean? > I can not simply store a copy of the Karl person in Tinas :friends > slot, > because when Karl gets one year older, then I don‘t want to go through > all persons, looking for Karls, and have their age updated.