How's textjure coming along?
On Dec 10, 3:35 pm, Chouser wrote:
> On Wed, Dec 10, 2008 at 7:15 AM, Simon Brooke wrote:
>
> > I note people seem mainly to be using Emacs as an editing/development
> > environment for Clojure. But as people keep pointing out, Clojure is
> > homoiconic; the canonic
So up until now, I've mainly been writing my code in a given file,
using no namespaces, and then just compiling and executing it in a
SLIME-based REPL.
I've accumulated a few functions that seem worth making into a little library.
So, for example, I've written a few permutation functions. I put
On Dec 28, 7:50 pm, Piotr 'Qertoip' Włodarek
wrote:
> Following my recent adventure with words ranking, here's the parallel
> version:
>
> ...
> (defn parallel-top-words [in-filepath out-filepath]
> (let [string (slurp in-filepath)
'slurp' just reads the whole file in at once as a string, rig
Thanks, Mike - although we had already looked at the context
classloader, your explanation did provide some inspiration for a
workaround. The correct classloader should be available in the JSP and
so it should be possible to grab it there and pass it into Clojure as
a variable (or a binding?) in t
On Dec 29, 1:15 pm, "Mark Volkmann" wrote:
> It's early enough in the life of Clojure that we haven't developed any
> deeply held habits yet. I think it would be a good idea for you and
> other Clojure committers to at least suggest the way you think things
> should be done in code. If you think
On Mon, Dec 29, 2008 at 7:15 PM, Brian Doyle wrote:
> I noticed that in the init-model macro you are creating a 'defn table []
> ...' function in the
> model namespace and was wondering why you didn't just make it a def instead,
> since
> it doesn't take any args?
That didn't occur to me. I do l
Now I'm dumped back to my shell prompt following a single Clojure REPL
prompt (of the Contrib REPL variety) without even touching the
keyboard:
% clojure-svn --crepl +cp=$PROJ_SRC/tau/run +cp=/dar/clojure
1:1 user=>
%
Here it is working with the current clojure.jar and clojure-contrib.jar:
%
thanks for sharing. looking forward to the day when i can write my
android app in clojure!
On Dec 30, 12:07 pm, Adam King wrote:
> Rich Hickey wrote:
> > On Sun, Dec 28, 2008 at 6:05 PM, Randall R Schulz wrote:
>
> >> Howdy, Folks,
>
> >> The gauntlet has been thrown down:
>
> > I've made chan
On Dec 30, 2:49 pm, wubbie wrote:
> Very criptic for newbie.
> What does "Threads the expr through the forms." mean?
Shameless plug, if you find learning from examples easier than textual
descriptions, you might want to look up
http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examp
On Monday 29 December 2008 18:36, Stephen C. Gilardi wrote:
> On Dec 29, 2008, at 8:49 PM, Randall R Schulz wrote:
> > Following today's SVN updates to the Clojure Core and Contrib (as
> > of this writing, at 17:42 PST, which is GMT -8), I can no longer
> > invoke the Contrib REPL as I was able to
Rich Hickey wrote:
> On Sun, Dec 28, 2008 at 6:05 PM, Randall R Schulz wrote:
>
>> Howdy, Folks,
>>
>> The gauntlet has been thrown down:
>>
>
> I've made changes in svn 1186 and 1188 that should help facilitate
> targeting Android/Dalvik. clojure.jar now translates with dx --dex,
> but t
Very criptic for newbie.
What does "Threads the expr through the forms." mean?
Does it create a thread to execute?
thanks
sun
On Dec 29, 10:07 pm, Paul Barry wrote:
> You can look up the documentation for a function/macro interactively
> from the repl:
>
> user=> (doc ->)
> --
> (defn top-words-core [s]
> (reduce #(assoc %1 %2 (inc (%1 %2 0))) {}
> (re-seq #"\w+"
> (.toLowerCase s
"maps are functions of their keys" means:
user=> ({:a 1, :b 2, :c 3} :a)
1
Here we created a map {:a 1, :b 2, :c 3}, can then called it like a
funct
On Mon, Dec 29, 2008 at 9:36 PM, Aaron Brooks wrote:
>
> In Clojure (anybody correct me if I'm wrong) I think it's preferable
> for performance reasons to use reduce instead of apply when you can.
I actually think that's backwards. In many cases it doesn't really
matter. It's common to do what +
Craig,
Something you should be aware of is that this implementation of
Fibonacci is very inefficient. For more info as to why, you can read:
http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-11.html#%_sec_1.2.2
The short story is doing it this way performs a lot of wasted
calculations as n
You can look up the documentation for a function/macro interactively
from the repl:
user=> (doc ->)
-
clojure.core/->
([x form] [x form & more])
Macro
Threads the expr through the forms. Inserts x as the
second item in the first form, making a list of it if it is not a
> 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
(var-set x 2)
(let [z @x]
(fn
On Dec 29, 2008, at 8:49 PM, Randall R Schulz wrote:
Following today's SVN updates to the Clojure Core and Contrib (as of
this writing, at 17:42 PST, which is GMT -8), I can no longer invoke
the
Contrib REPL as I was able to before today. When I do, I get no prompt
until I type a non-empty li
On Dec 24, 4:20 pm, Mibu wrote:
> I'd write it this way:
> (apply + (mapcat #(range 1 %) (range 2 14)))
>
> I think idiomatically I would have written it with (partial range 1)
> instead of #(range 1 %), but I prefer compact forms.
In Clojure (anybody correct me if I'm wrong) I think it's prefer
What if you run the Swing code in the Event Dispatch Thread?
In other words, does this:
(. javax.swing.SwingUtilities (invokeAndWait #(.
javax.swing.JOptionPane (showMessageDialog nil "Hello World"
or
(. javax.swing.SwingUtilities (invokeLater #(. javax.swing.JOptionPane
(showMessageDialog
On Mon, Dec 29, 2008 at 7:27 PM, wubbie wrote:
>
> Hi all,
>
> Looking into ants.clj, I came across
> (defn place [[x y]]
> (-> world (nth x) (nth y)))
>
> What -> mean here?
It means (nth (nth world x) y).
It "threads" world through the forms that follow.
First it makes world the second item i
;; Note: originally I was just going to write Stuart, but I think input from
anybody on the list could be valuable, so I'm CC'ing Clojure
Hi Stuart,
I've been working on an RSpec-like library for Clojure called Specjure. It
has gone through many iterations and the one that is currently up on gith
Hi,
Following today's SVN updates to the Clojure Core and Contrib (as of
this writing, at 17:42 PST, which is GMT -8), I can no longer invoke the
Contrib REPL as I was able to before today. When I do, I get no prompt
until I type a non-empty line, after which I'm presented with an
unending repeti
Hi all,
Looking into ants.clj, I came across
(defn place [[x y]]
(-> world (nth x) (nth y)))
What -> mean here?
thanks
sun
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group,
On Mon, Dec 29, 2008 at 2:57 PM, Dave Griffith
wrote:
>
> It looks like the mutable locals use case is covered by the "with-
> local-vars" binding form.
Not really. with-local-vars has somewhat surprising semantics.
For example, you'd expect this (contrived) function to generate an
"add 2" fun
On Mon, Dec 29, 2008 at 8:02 PM, CuppoJava wrote:
>
> The reason I'm asking about this is that it's quite standard practice
> to set up some parameters inside the constructor of a class.
>
> ie. A use-case like this is quite common, and (I think) reasonable.
>
> public class MyThread extends Thre
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. I fully accept the necessity
> of doing that at times,
Thanks for the reply Chouser,
Yeah, I figured it would be like that. No "this" value actually exists
until after the init function is called.
The reason I'm asking about this is that it's quite standard practice
to set up some parameters inside the constructor of a class.
ie. A use-case like th
A useful comment addition:
How do I run it?
Cheers
Tom
2008/12/29 Mark Volkmann
>
> On Mon, Dec 29, 2008 at 3:58 PM, Chouser wrote:
> >
> > On Mon, Dec 29, 2008 at 4:40 PM, Mark Volkmann
> > wrote:
> >>
> >> I think that's supposed to be + instead of *, at least Common Lisp
> >> seems to us
That seems to be working better now John. I looked over most of the code
and it seems
like a good start. I'm no expert when it comes to functional programming or
Clojure,
so I'm not sure how to critic the code exactly. If I was doing the porting
I would prolly
do it in very OO way, since that'
Mark,
Thanks for providing that. I've linked to it from the site of the
original post at http://www.plt1.com/1070/even-smaller-snake/
(Btw, a typo in my name at the top of your page :-)
On 12/30/08, Mark Volkmann wrote:
>
> On Mon, Dec 29, 2008 at 3:58 PM, Chouser wrote:
>>
>> On Mon, Dec 29
It looks like the mutable locals use case is covered by the "with-
local-vars" binding form. That said, I'm not sure how useful this
would be. Even in Java 5, 95% of my local vars are immutable, i.e
annotated as final and never have any mutating methods called on
them. Most of the rest are simp
On Mon, Dec 29, 2008 at 3:58 PM, Chouser wrote:
>
> On Mon, Dec 29, 2008 at 4:40 PM, Mark Volkmann
> wrote:
>>
>> I think that's supposed to be + instead of *, at least Common Lisp
>> seems to use +.
>
> I meant * -- I don't know CL at all, but the *asterisk* form is used
> frequently in clojur
I don't know CL that well myself, but I think the convention is to use
+ for constants (i.e. defconst) where * is used for global variables
(i.e. defparameter). In that case the + convention doesn't really
make sense in clojure as it doesn't have any notion of a constant
reference type.
--Darren
On Mon, Dec 29, 2008 at 4:40 PM, Mark Volkmann
wrote:
>
> I think that's supposed to be + instead of *, at least Common Lisp
> seems to use +.
I meant * -- I don't know CL at all, but the *asterisk* form is used
frequently in clojure.core, while no +plus+ form ever appears. I also
was careful
On Mon, Dec 29, 2008 at 3:10 PM, Chouser wrote:
>
> On Mon, Dec 29, 2008 at 3:40 PM, Mark Volkmann
> wrote:
>>
>> On Mon, Dec 29, 2008 at 2:24 PM, Brian Doyle wrote:
>>> Looking at this code the uppercase variables stands out.
>>> This isn't idiomatic is it?
>>>
>>> (def GRID_SIZE 10)
>>> (def
On Mon, Dec 29, 2008 at 3:01 PM, Stuart Sierra
wrote:
>
> On Dec 29, 3:40 pm, "Mark Volkmann" wrote:
>> On Mon, Dec 29, 2008 at 2:24 PM, Brian Doyle wrote:
>> > Looking at this code the uppercase variables stands out.
>> > This isn't idiomatic is it?
>>
>> > (def GRID_SIZE 10)
>> > (def HEIGHT
On Mon, Dec 29, 2008 at 3:40 PM, Mark Volkmann
wrote:
>
> On Mon, Dec 29, 2008 at 2:24 PM, Brian Doyle wrote:
>> Looking at this code the uppercase variables stands out.
>> This isn't idiomatic is it?
>>
>> (def GRID_SIZE 10)
>> (def HEIGHT 600)
>> (def MARGIN 50)
>
> I don't know.
I believe th
On Dec 29, 3:40 pm, "Mark Volkmann" wrote:
> On Mon, Dec 29, 2008 at 2:24 PM, Brian Doyle wrote:
> > Looking at this code the uppercase variables stands out.
> > This isn't idiomatic is it?
>
> > (def GRID_SIZE 10)
> > (def HEIGHT 600)
> > (def MARGIN 50)
>
> I don't know. I was following Java c
Emeka,
In short, no. Remember, this was about me learning some functional
tools, so this shouldn't be viewed as pedagogical. Well, *my* code
shouldn't - I can't speak for the other posters in this thread.
-Matt
On Dec 27, 7:28 am, Emeka wrote:
> >(defn sum-up-to [n]
>
> >"returns the sum
On Mon, Dec 29, 2008 at 2:24 PM, Brian Doyle wrote:
> Looking at this code the uppercase variables stands out.
> This isn't idiomatic is it?
>
> (def GRID_SIZE 10)
> (def HEIGHT 600)
> (def MARGIN 50)
I don't know. I was following Java conventions of making constants all
uppercase. Is there a co
On Sat, Dec 27, 2008 at 9:24 PM, CuppoJava wrote:
>
> I believe the first parameter must be "this", only in the case of
> methods .
> The init function doesn't take a "this" parameter.
Correct.
My understanding is that the init function is actually run before the
instance is even created. So n
On Dec 29, 2:29 pm, "Mark Engelberg" wrote:
> On Mon, Dec 29, 2008 at 8:05 AM, Rich Hickey wrote:
> > It is certainly not the whole point of Clojure to make as much code as
> > possible safe for its software transactional memory. Clojure is a set
> > of tools. They are designed to allow for ro
Fixed (rev 1190)
tristan a écrit :
> Thanks for the explanation Christophe.
> I really need to try use (for) more often. I seem to forget about it
> all the time.
>
> On Dec 27, 10:42 pm, Christophe Grand wrote:
>
>> tristan a écrit :
>>
>>
>>> Hi All,
>>>
>>> I've been trying to
Looking at this code the uppercase variables stands out.
This isn't idiomatic is it?
(def GRID_SIZE 10)
(def HEIGHT 600)
(def MARGIN 50)
On Mon, Dec 29, 2008 at 12:19 PM, Mark Volkmann
wrote:
>
> On Mon, Dec 29, 2008 at 11:11 AM, lpetit wrote:
> >
> > You should consider using docstrings for d
Hi Kees-Jochem,
Am 29.12.2008 um 20:37 schrieb Kees-Jochem Wehrmeijer:
I created a small file foo.clj with the following contents:
(defn foo [] :bar)
Then from a REPL I try the following:
(do (load-file "foo.clj") (foo))
but this gives an error message:
java.lang.Exception: Unable to resolve s
On Sun, Dec 28, 2008 at 6:05 PM, Randall R Schulz wrote:
>
> Howdy, Folks,
>
> The gauntlet has been thrown down:
I've made changes in svn 1186 and 1188 that should help facilitate
targeting Android/Dalvik. clojure.jar now translates with dx --dex,
but that is all I've had time to look at.
If p
On Dec 21, 5:53 pm, "Stephen C. Gilardi" wrote:
> On Dec 21, 2008, at 4:43 PM, Stephen C. Gilardi wrote:
>
> > On Dec 21, 2008, at 4:40 PM, Rich Hickey wrote:
> >> If main doesn't match the behavior of Repl and Script in this area
> >> when run in repl or script modes respectively, it needs to.
Hi everybody,
I just got started with Clojure and I'm now trying to simultaneously
learn Lisp and Java. My progress is slow, but I'm having a lot of fun.
I hit a small roadblock though, because I can't figure out why calling
load-file from within a do is behaving the way it is. I'm probably
missi
On Dec 29, 7:50 am, Achim Passen wrote:
> Hi!
>
> I uploaded my attempt at this to the files section of this group:
>http://clojure.googlegroups.com/web/mod-sgn.diff
>
> It adds the modulus operator plus, as a by-product, the signum
> operator (sgn).
>
> Comments most welcome!
>
Thanks! Co
On Mon, Dec 29, 2008 at 8:05 AM, Rich Hickey wrote:
> It is certainly not the whole point of Clojure to make as much code as
> possible safe for its software transactional memory. Clojure is a set
> of tools. They are designed to allow for robust programs to be built,
> including multithreaded pr
On Mon, Dec 29, 2008 at 11:11 AM, lpetit wrote:
>
> You should consider using docstrings for documenting functions
Good suggestion. I've changed my code to do that. I also noticed that
I had forgotten to replace special characters with built-in entities
in my HTML, so that is fixed now. The new
Not sure about that; knowing what a function is for is an important starting
point to understanding it. Anyway' half of the code you work on will be
using the other half (for given values of 'half' of course ;-) .
Generally, Clojure is a Lisp so Lisp idioms should apply (closing all your
braces o
Rich & rest.
I have gone through the process of implementing this in defn. The
patch is inlined for commenting (if need be) and attached for accurate
application.
I declare my changes public domain, but I suppose I could fill out a
CA if it helps. I can also make a similar change for defmacro, if
On Sat, Dec 27, 2008 at 8:55 AM, Peter Wolf wrote:
> Hi Justin,
> This is the right place. Thanks for trying the plugin.
>
> It would absolutely be helpful to document use of the plugin. However, I
> am sure you can tell that it is nowhere near ready.
>
Yes, I noticed there wasn't much there y
On Monday 29 December 2008 09:11, lpetit wrote:
> You should consider using docstrings for documenting functions
There's a big difference between the comments directed at someone
reading the code (possibly the author at a later date) and someone
wishing to use it. Function-level documentation s
Doh!
I just read your discussion w/ Anton on his blog. Seems you've already
looked at the context classloader.
*shrug*. I'm stumped.
/mike.
On Mon, Dec 29, 2008 at 12:46 PM, Michael Reid wrote:
> Hi,
>
> I'm not sure how to integrate this into the Tomcat JSP scenario, but I
> think the issu
Hi,
I'm not sure how to integrate this into the Tomcat JSP scenario, but I
think the issue is that *use-context-classloader* is not set to true
(it defaults to nil).
Again, I'm not positive how to get your JSP to do this, but an
untested stab at it would be just to wrap the call to
clojure.main/
You should consider using docstrings for documenting functions
On 29 déc, 16:45, "Mark Volkmann" wrote:
> On Mon, Dec 29, 2008 at 5:44 AM, Mark Volkmann
>
>
>
> wrote:
> > I would like to produce a version of the snake code that could serve
> > as an example of the kind of code that the Clojure
On Dec 29, 2008, at 10:45 AM, Mark Volkmann wrote:
>
> On Mon, Dec 29, 2008 at 5:44 AM, Mark Volkmann
> wrote:
>
>> I would like to produce a version of the snake code that could serve
>> as an example of the kind of code that the Clojure community thinks
>> is
>> "good". Unless it's part of a
On Sat, Dec 27, 2008 at 12:03 AM, Mark Engelberg
wrote:
>
> On Fri, Dec 26, 2008 at 8:35 PM, Adrian Cuthbertson
> wrote:
>> It's important to distinguish between updating atoms within
>> transactions and outside transactions. In the former case, one has to
>> ensure the update function can be re
> My challenge to everyone on the list is to start with any version of
> the snake code you've seen and make it as readable as *you* think it
> should be by doing things like renaming variables and functions,
> adding comments and changing indentation. I'd really like to see what
> *you* think is
On Mon, Dec 29, 2008 at 5:44 AM, Mark Volkmann
wrote:
> I would like to produce a version of the snake code that could serve
> as an example of the kind of code that the Clojure community thinks is
> "good". Unless it's part of an exercise to produce the shortest code
> possible, I think we shou
Haven't solved it yet, but I may have found something useful enough
for someone cleverer than I to make something out of.
When I run clojure directly as inferior-lisp, without slime, the
problem does occur. However, as soon as I enter something in the
inferior lisp buffer, it starts working again
Hi!
I uploaded my attempt at this to the files section of this group:
http://clojure.googlegroups.com/web/mod-sgn.diff
It adds the modulus operator plus, as a by-product, the signum
operator (sgn).
Comments most welcome!
Kind regards,
achim
On 29 Dez., 07:01, Rich Hickey wrote:
> On Dec
On Mon, Dec 29, 2008 at 10:49 AM, Emeka wrote:
> Hello sir,
>
> I would have asked this question in the thread but , I don't want to create
> noise over this issue.
> I have not been able to get my head around your code or Clojure. I need some
> support.
>
>
> (defn top-words-core [s]
> (red
On Mon, Dec 29, 2008 at 12:03 AM, Abhishek Reddy wrote:
>
> Speaking for myself, as the author of the original Snake example, I
> had no intention of converting developers to Clojure, or of producing
> instructive or readable code, with that snippet.
>
> While I agree with some of your critique,
I think that just as important as "compactness" is the issue of
"density": the ratio
of the "conceptual weight"of the computation to the size of the code
expressing it.
if a computation is inherently complicated and I manage to squeeze it
into
a few lines (typically accomplished via an intense co
>> (defn fib-helper [a b]
>> (fib-helper b (+ a b)))
> This defines an infinitely recursive function. It never actually
> returns anything, so it quickly exhausts the stack. Were you trying
> for a lazy infinite sequence of fibonacci numbers?
Yes - exactly, I couldn't figure it out, even afte
Hello sir,
I would have asked this question in the thread but , I don't want to create
noise over this issue.
I have not been able to get my head around your code or Clojure. I need some
support.
(defn top-words-core [s]
(reduce #(assoc %1 %2 (inc (%1 %2 0))) {}
(re-seq #"\w+"
Hi David,
>> (defn fib (fib-helper 0 1)) ; This doesn't work either: (defn fib (fib-
>> helper '(0 1)))
> You're missing your argument list for fib.
I assumed you meant the empty square brackets [] just after the work
fib? I didn't realise these were necessary even when there were no
function a
You could consider using a StreamTokenizer:
(import '(java.io StreamTokenizer BufferedReader FileReader))
(defn wordfreq [filename]
(with-local-vars [words {}]
(let [st (StreamTokenizer. (BufferedReader. (FileReader.
filename)))]
(loop [tt (.nextToken st)]
(when (not= tt Strea
Mark,
Thanks so much for pointing that out, it makes Clojure to belong to others.
Clojure should not be only for FP experts and PH.D holders. I took time to
check the background of some members in this group: we have lecturers,
research scientists and others from the best technical schools. I know
I want to be able to read and write a clojure object, which contains
functions, from/to a file.
The structure looks something like this: { :s "my-string" :f (fn[x]
(inc x) }
Reading is easy: (load-file ...) works fine. The tricky part is
writing it back to the file. (pr ...) gives something like
Timothy -
It becomes more tricky if you want to know what fraction of everything
a host can present that carries 2 or 3 different filters (I mentioned
that somewhere).
For example: everything is 4^4 = 256 options
[ABCD][ABCD][ABCD][ABCD]
Host carries these two filters:
[ABC][AC][AB][ABC]
[ABC][
75 matches
Mail list logo