Re: what does -> mean?

2008-12-30 Thread Craig Marshall
Hi Timothy, This is not really related to the current thread (sorry), but I want to say thanks for this API examples page, it looks like it'll be a great help, just what I need! Somehow I'd managed to completely miss it until now when you mentioned it - either I'm partially blind, or it could be

Re: making code readable

2008-12-30 Thread Christophe Grand
Mark Volkmann a écrit : > For example, here's some code that I don't > know how to rewrite in a way that I find self-explanatory: > > (every? > #(<= (- (apple %) +grid-size+) (head %) (+ (apple %) +grid-size+)) > [+x-index+ +y-index+])) > > And here's another one: > > (assoc snake :body >

Re: load-file within a do

2008-12-30 Thread Kees-Jochem Wehrmeijer
Ah of course. Thanks a lot, your explanation makes things a lot clearer! I guess because of the direct nature of the REPL I hadn't thought about compile time vs runtime, but that makes perfect sense. On Dec 29, 8:00 pm, Meikel Brandmeyer wrote: > Hi Kees-Jochem, > > Am 29.12.2008 um 20:37 schr

Re: Understanding how to use namespaces

2008-12-30 Thread Meikel Brandmeyer
Hi, using namespaces also requires to layout the files in a certain way. For the following consider the directory cp to be in the classpath. Create a file cp/permutations.clj with your functions: (ns permutations) (defn fun1 ...) (defn fun2 ...) Then create your second namespace in the corres

Re: In core structure editor, anyone?

2008-12-30 Thread Chouser
On Tue, Dec 30, 2008 at 1:24 AM, falcon wrote: > > How's textjure coming along? Not ready yet. :-/ Current sub-project: setting up sufficiently flexible system to handle vi-style keybindings. --Chouser --~--~-~--~~~---~--~~ You received this message because you

Re: How to encapsulate local state in closures

2008-12-30 Thread Rich Hickey
On Dec 29, 8:08 pm, "Mark Engelberg" wrote: > On Mon, Dec 29, 2008 at 12:40 PM, Rich Hickey wrote: > > People who know what they are doing can do these things right now with > > Clojure's array support. There really isn't any more value for Clojure > > to add to that, so no special primitives.

Re: Parallel words frequency ranking

2008-12-30 Thread Piotr 'Qertoip' Włodarek
On Dec 29, 7:02 am, Chouser wrote: > > (defn split-string-in-two [s] > >  (let [chunk-size (quot (count s) 2)] > >    [(subs s 0 chunk-size), (subs s chunk-size)])) > > Might this cut a word in half and produce (slightly) incorrect > results? True, I decided to let it be for the sake of simplici

Re: making code readable

2008-12-30 Thread Mark Volkmann
On Tue, Dec 30, 2008 at 4:21 AM, Christophe Grand wrote: > > Mark Volkmann a écrit : >> For example, here's some code that I don't >> know how to rewrite in a way that I find self-explanatory: >> >> (every? >> #(<= (- (apple %) +grid-size+) (head %) (+ (apple %) +grid-size+)) >> [+x-index

Re: making code readable

2008-12-30 Thread Christophe Grand
Mark Volkmann a écrit : >> (assoc snake :body >>(cons >> (map + dir (first body)) >> > > The previous line needs to be (vec (map + dir (first body))). > It works without the vec. Since we aren't using indexing anymore we don't need to make a vector: a seq (or any collection type)

Re: Contrib REPL Invocation Changes

2008-12-30 Thread Randall R Schulz
On Monday 29 December 2008 20:50, Stephen C. Gilardi wrote: > > ... > > Here it is working with the current clojure.jar and > clojure-contrib.jar: > > % java -cp clojure.jar:clojure-contrib.jar clojure.contrib.repl_ln > Clojure > 1:1 user=> (prn "hi") > "hi" > nil > 1:2 user=> I can't replicate t

Re: Stumped - Java hangs when using Swing in Slime

2008-12-30 Thread levand
Wow... that actually fixes it. Still a minor problem, since according to the Sun website, it is legal to create a Swing object in another thread as long as long as it is not "realized" yet... Still, this definitely is a doable workaround. Thanks! -Luke On Dec 29, 9:17 pm, Rowdy Rednose wrote:

Re: making code readable

2008-12-30 Thread John D. Hume
On Mon, Dec 29, 2008 at 4:10 PM, Chouser wrote: > I believe the idiom for global values like this is to place asterisks > around the name. I thought the asterisk convention was for variables intended for dynamic binding. It took me a minute to figure out where I got that idea. "Programming Cloju

Re: Understanding how to use namespaces

2008-12-30 Thread Daniel Eklund
Hey Mark, In addition to Meikel's explanation above, have a look at this message http://groups.google.com/group/clojure/msg/17ada41fcb5ef667 from the overall thread http://groups.google.com/group/clojure/browse_frm/thread/ff80d120c996ba1a/9bfbfe1b08246035# This was the post that finally made

Re: test-is nesting

2008-12-30 Thread J. McConnell
On Mon, Dec 29, 2008 at 9:12 PM, Larrytheliquid wrote: > > This is what I'm thinking, let me explain: http://gist.github.com/41468 > (If you are familiar with RSpec, here is the equivalent RSpec example > http://rspec.info/examples.html) I really like the look of this so far. Nice work! > Anoth

Re: Some code review for clj-record?

2008-12-30 Thread Brian Doyle
I see what you are doing with the validations and defining them in the init-modelcall. I think that's a good idea actually and like it better than my solution to putting the callbacks in the model namespace. A couple of small things that I noticed when starting to play around with clj-record. In

Re: Accessing "this" in gen-class constructor

2008-12-30 Thread CuppoJava
Ah sorry I missed that. However, you accomplished this only because there exists a constructor in Thread that takes a String name argument. As a general case, it's not usually that convenient... ie. public class MyThread extends Thread{ public MyThread(){ setName("This is my thread");

swank-clojure license

2008-12-30 Thread lpetit
Sorry for this e-mail that could be more targeted to Jeffrey Chu, but I was unable to find its direct e-mail address, and I know he is a clojure ml member, so ... It seems that swank-clojure license is a flavor of GPL ("License as distributed with Emacs"). So I guess that if for clojure-dev (ecl

Re: Accessing "this" in gen-class constructor

2008-12-30 Thread Chouser
On Tue, Dec 30, 2008 at 11:52 AM, CuppoJava wrote: > > Ah sorry I missed that. > > However, you accomplished this only because there exists a constructor > in Thread that takes a String name argument. > As a general case, it's not usually that convenient... > > ie. > > public class MyThread exten

Re: Parallel words frequency ranking

2008-12-30 Thread Mibu
In an ideal world, standard functions like map, sort, reduce, filter, etc. would know when to parallelize on their own, or even better, the compiler will do it for them. Meanwhile, I tried playing with the parallel lib ( http://clojure.org/other_libraries ) which has functions like preduce, psor

Re: swank-clojure license

2008-12-30 Thread Phil Hagelberg
lpetit writes: > So I guess that if for clojure-dev (eclipse plugin for clojure) we > want to use it for interactivity with an external clojure environment, > and we want to start the environment from the plugin, we have a > problem : stop me if I'm wrong, but if any file of swank-clojure is > e

Re: swank-clojure license

2008-12-30 Thread lpetit
I'm not sure. From what I remember, what you describe is more related to LGPL ? On 30 déc, 18:19, Phil Hagelberg wrote: > lpetit writes: > > So I guess that if for clojure-dev (eclipse plugin for clojure) we > > want to use it for interactivity with an external clojure environment, > > and we

Re: test-is nesting

2008-12-30 Thread Stuart Halloway
If you guys can get these changes sorted out quickly (next few weeks) I would love to cover them in the book. No pressure. :-) Thanks, Stuart > On Mon, Dec 29, 2008 at 9:12 PM, Larrytheliquid > wrote: >> >> This is what I'm thinking, let me explain: http://gist.github.com/41468 >> (If you are

Re: In core structure editor, anyone?

2008-12-30 Thread chris
I would be super interested in trying things out with textjure whenever you are ready. I don't want to give up emacs + slime, but I do think it is an interesting concept to connect to a running process and change it. One other thing that LISP had that was useful was saving the state of the syste

Re: making code readable

2008-12-30 Thread Mitch
What about some sort of lint program? I'm thinking about something like pylint for clojure with configurable rules, but which will default to the standards agreed upon bu the clojure community. Even if you don't follow the rules 100%, it could be useful to see where you are deviating to be sure

Re: Contrib REPL Invocation Changes

2008-12-30 Thread Stephen C. Gilardi
On Dec 30, 2008, at 9:53 AM, Randall R Schulz wrote: Anyway, I guess it needs to be pointed that the invocation you supplied won't work unless the Clojure Contrib JAR file is built with pre- compiled Java classes and that this only happens if you supply the clojure.jar property ("-Dclojure.ja

Re: Accessing "this" in gen-class constructor

2008-12-30 Thread CuppoJava
Haha yeah... it's a rather poor API. I'm making do with a temporary post-constructor hook that I manually call after instantiating the object right now. But it's tedious and error-prone. Thanks for the help Chouser --~--~-~--~~~---~--~~ You received this message b

Re: swank-clojure license

2008-12-30 Thread Phil Hagelberg
lpetit writes: > I'm not sure. From what I remember, what you describe is more related > to LGPL ? No, the LGPL allows using the code in another program that is Free but not GPL-licensed. If you're just distributing some code from swank-clojure, licensing conflicts will never come into play. It

Accessing static protected fields?

2008-12-30 Thread CuppoJava
Hi, Is there anyway to access a static protected field from within Clojure? I've tried using :exposes in gen-class, however that gives me the following error: java.lang.IncompatibleClassChangeError: Expected non-static field graphics.JMEGame.ALWAYS_SHOW_PROPS_DIALOG Thanks for your replies -P

Re: Accessing static protected fields?

2008-12-30 Thread Rich Hickey
On Dec 30, 2008, at 1:27 PM, CuppoJava wrote: > > Hi, > Is there anyway to access a static protected field from within > Clojure? > > I've tried using :exposes in gen-class, however that gives me the > following error: > > java.lang.IncompatibleClassChangeError: Expected non-static field > graph

Re: Accessing static protected fields?

2008-12-30 Thread CuppoJava
Ah okay. I'll dig through the clojure source today and see if I'm able to make a patch myself. Thanks for the reply Rich --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send em

Re: test-is nesting

2008-12-30 Thread Stuart Sierra
On Dec 29, 9:12 pm, Larrytheliquid wrote: > As I get closer to something I like, it seems that what I will end up with > will end up with will look look like where test-is seems to be heading. Hi Larry, You have laid out pretty clearly where I would like test-is to go next. I've been experimen

Re: Parallel words frequency ranking

2008-12-30 Thread Mark H.
On Dec 30, 9:18 am, Mibu wrote: > In an ideal world, standard functions like map, sort, reduce, filter, > etc. would know when to parallelize on their own, or even better, the > compiler will do it for them. The former is easier than the latter ;-) Even the smartest autoparallelizing compilers

metaprogramming: finding function arity and other information about the envrionment

2008-12-30 Thread falcon
How do I find the arity of a given function? I can get a list of all name spaces using (all-ns) I can get functions within each name space using (find-ns 'clojure) ; so map find-ns over each value returned by all-ns (doc fn) gives me a description of the function, and information about function

Re: Parallel words frequency ranking

2008-12-30 Thread Mark H.
On Dec 28, 7:50 pm, Piotr 'Qertoip' Włodarek wrote: > On 38MB file it takes 28s, compared to 38s of similar but sequential > version. Another good thing is to make a simple performance model, perhaps aided by timings of individual components, before you start parallelizing everything ;-) How lo

send-off *agent* #' func

2008-12-30 Thread wubbie
Hi, Why do we need to specify the second argument(#'func) is a function, not a variable? the syntax of send-off required a function as the second arg? thanks, sun --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

Re: metaprogramming: finding function arity and other information about the envrionment

2008-12-30 Thread pmf
On Dec 30, 10:29 pm, falcon wrote: > (doc fn) gives me a description of the function, and information about > function arity.  I assumed the description and arity were part of > metadata but (meta fn) only returns nil (for a few functions I tried). Be sure to var-quote the function, i.e. don't

Re: metaprogramming: finding function arity and other information about the envrionment

2008-12-30 Thread falcon
Impressive, source file and line numbers are already included! I need to better understand reader macro (or where ever # comes from). Thanks > > Be sure to var-quote the function, i.e. don't use (meta print), but > (meta #'print). --~--~-~--~~~---~--~~ You receiv

Re: metaprogramming: finding function arity and other information about the envrionment

2008-12-30 Thread pmf
On Dec 30, 11:08 pm, falcon wrote: > Impressive, source file and line numbers are already included! > I need to better understand reader macro (or where ever # comes from). You actually need to know two things regarding this issue. In function-definitions, the meta-data is actually assigned to

Re: send-off *agent* #' func

2008-12-30 Thread Chouser
On Tue, Dec 30, 2008 at 4:56 PM, wubbie wrote: > > Why do we need to specify the second argument(#'func) is a function, > not a variable? > the syntax of send-off required a function as the second arg? The second argument will be called as a function -- if it's not callable (doesn't implement

Re: metaprogramming: finding function arity and other information about the envrionment

2008-12-30 Thread Chouser
On Tue, Dec 30, 2008 at 4:29 PM, falcon wrote: > > Generally speaking, how can I get information about my environment: > -which bindings exist > -the source code for a given function (if source code is available) pmf's explanations are solid, but for the source code in particular, you may be int

REPL Subtleties. Emacs inferior-mode.

2008-12-30 Thread CuppoJava
Hi, I'm just noticing some subtle threading problems when running a Jme application from the REPL within inferior-lisp mode Emacs. For instance this works: (. jmetest.renderer.TestArrow main nil) But this doesn't: (attempting to execute from a separate thread) (def thread (proxy [Thread] []

Re: swank-clojure license

2008-12-30 Thread Mark H.
On Dec 30, 10:26 am, Phil Hagelberg wrote: > lpetit writes: > > I'm not sure. From what I remember, what you describe is more related > > to LGPL ? > > No, the LGPL allows using the code in another program that is Free but > not GPL-licensed. Actually the LGPL allows linking to the library (som

Re: metaprogramming: finding function arity and other information about the envrionment

2008-12-30 Thread falcon
Makes sense, thanks On Dec 30, 5:29 pm, pmf wrote: > On Dec 30, 11:08 pm, falcon wrote: > > > Impressive, source file and line numbers are already included! > > I need to better understand reader macro (or where ever # comes from). > > You actually need to know two things regarding this issue.

Re: metaprogramming: finding function arity and other information about the envrionment

2008-12-30 Thread falcon
I was thinking of writing a poor man's enclojure (to get a feel for a real clojure project). Looks like a lot of work is already done :) I see many references to clojure contrib, perhaps this jar could be made more prominent on clojure.org? On Dec 30, 5:40 pm, Chouser wrote: > On Tue, Dec 30,

Re: test-is nesting

2008-12-30 Thread Larrytheliquid
Thanks for the reply Stuart, I thought about similar things. I'm still not sure which approach is better myself, but let me clarify a few things. In the current design of test-is, every test must be attached to > the :test metadata of a Var. That's why "deftest" currently requires > a symbol, eve

Re: How to encapsulate local state in closures

2008-12-30 Thread Mark Engelberg
On Tue, Dec 30, 2008 at 5:53 AM, Rich Hickey wrote: > Could you provide an example of when you would need/use that? > Sure. Use Case #1: Implementing classic imperative algorithms Consider the binary gcd algorithm on page 338 of The Art of Computer Programmiing, volume 2. This is a very clever

Re: REPL Subtleties. Emacs inferior-mode.

2008-12-30 Thread Matt Revelle
On Dec 30, 2008, at 5:53 PM, CuppoJava wrote: > > Hi, > I'm just noticing some subtle threading problems when running a Jme > application from the REPL within inferior-lisp mode Emacs. > > For instance this works: > > (. jmetest.renderer.TestArrow main nil) > > But this doesn't: (attempting to e

Re: Stumped - Java hangs when using Swing in Slime

2008-12-30 Thread Rowdy Rednose
Just curious - do both invokeLater and invokeAndWait work? Or only invokeLater? On 31 Dez., 00:39, levand wrote: > Wow... that actually fixes it. Still a minor problem, since according > to the Sun website, it is legal to create a Swing object in another > thread as long as long as it is not "re

Re: Stumped - Java hangs when using Swing in Slime

2008-12-30 Thread Rowdy Rednose
Luke, I believe they don't promote the "as long as it's not yet realized" rule anymore but rather say "do even creation of Swing objects in the EDT" now: http://java.sun.com:80/docs/books/tutorial/uiswing/concurrency/initial.html Cheers Rowdy On 31 Dez., 00:39, levand wrote: > Wow... that act

Re: REPL Subtleties. Emacs inferior-mode.

2008-12-30 Thread CuppoJava
Thanks Matt, I was actually hoping for you to reply. I found one of your earlier posts mentioning that you got JME working properly interactively with the REPL. Unfortunately, your solution didn't seem to work. I seem to be having the same problem as the guy in this post: http://groups.google.com

Re: REPL Subtleties. Emacs inferior-mode.

2008-12-30 Thread Matt Revelle
On Dec 30, 2008, at 9:13 PM, CuppoJava wrote: > > Thanks Matt, > I was actually hoping for you to reply. I found one of your earlier > posts mentioning that you got JME working properly interactively with > the REPL. > > Unfortunately, your solution didn't seem to work. I seem to be having > the

Re: REPL Subtleties. Emacs inferior-mode.

2008-12-30 Thread CuppoJava
Haha, I'm now seriously considering getting a Mac... Anyway thanks for your help. I think I'll try installing Slime and Swank and see if that helps at all. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" gr

Re: test-is nesting

2008-12-30 Thread Stuart Sierra
Hi Larry, hi all, Just a quick note: this is not a complete answer, but I just added the "testing" macro, which lets you add nested documentation strings to tests, as in RSpec. I've also removed the "T-..." gensyms for now; every deftest must have a symbol name. user> (use 'clojure.contrib.test

Re: Stumped - Java hangs when using Swing in Slime

2008-12-30 Thread CuppoJava
I want to add that it's not confined to just Swing applications. I have the exact same problem using JME on an Emacs *inferior-lisp* REPL. The program hangs, until I enter subsequent commands on the REPL. The SwingUtilities trick, and updating to the latest Java runtime doesn't help. I'm going

Re: How to encapsulate local state in closures

2008-12-30 Thread Pinocchio
Timothy Pratley wrote: >> I think if Clojure could do something like this (enforce a certain >> kind of referentially transparent mutable local), that would be neat, >> > > It is possible to achieve this behavior explicitly: > (defn create-add-2 [] > (with-local-vars [x 1] > (do >

Re: How to encapsulate local state in closures

2008-12-30 Thread Rich Hickey
On Dec 30, 2008, at 6:29 PM, Mark Engelberg wrote: > On Tue, Dec 30, 2008 at 5:53 AM, Rich Hickey > wrote: >> Could you provide an example of when you would need/use that? >> > > Sure. > > Use Case #1: Implementing classic imperative algorithms > > Consider the binary gcd algorithm on page 33

Re: How to encapsulate local state in closures

2008-12-30 Thread Mark Engelberg
On Tue, Dec 30, 2008 at 8:38 PM, Rich Hickey wrote: > There's simply no value for Clojure to add to a simple mutable box. > Clojure does provide the tools for low-level mutation - access to > Java. You can wrap that in whatever functions/macros you like. > There's no way to use the @ dereferenci

Re: Understanding how to use namespaces

2008-12-30 Thread Mark Engelberg
Thanks, that helps dramatically. It took me a while to figure out how to edit the SLIME startup to include my clojure files directory in the classpath, but I got it working. So it seems like you have to make sure the namespace always matches the file. That means if you change the name of the fi

Re: Understanding how to use namespaces

2008-12-30 Thread Brian Doyle
On Tue, Dec 30, 2008 at 11:25 PM, Mark Engelberg wrote: > > Thanks, that helps dramatically. It took me a while to figure out how > to edit the SLIME startup to include my clojure files directory in the > classpath, but I got it working. > > So it seems like you have to make sure the namespace al

Re: Stumped - Java hangs when using Swing in Slime

2008-12-30 Thread CuppoJava
I would like to add that nope... installing SLIME didn't seem to help. I'm on Clojure rev. 1160, and the latest SLIME and Swank sources as of December 30 2008. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure

Re: swank-clojure license

2008-12-30 Thread lpetit
On 30 déc, 23:55, "Mark H." wrote: > On Dec 30, 10:26 am, Phil Hagelberg wrote: > Actually the LGPL allows linking to the library (somewhat different > than "using the code") from any program, even one which is not under > an open-source license.  "L" used to stand for "library" and the > canoni

Re: swank-clojure license

2008-12-30 Thread Phil Hagelberg
lpetit writes: > So swank-clojure will not be hard-linked (at compilation time) to any > of clojure-dev code. Nor will it be dynamically linked to any clojure- > dev code at runtime : it will be dynamically linked to the clojure > environment launched by clojure-dev on behalf of the user. > > Bu