On 12.01.2009, at 01:01, samppi wrote:
> The problem is that even though "some" and "filter" are lazy, "alt" is
> still not, so calling "(alt (sub-function1 c) ...)" in the meta-meta-
> function still evaluates (sub-function1 c), etc. It could be shown in
> the REPL:
How about changing the inter
> (defn seq-of-rand-strings [maxlength]
> (repeatedly (fn []
> (apply str (take (rand-int maxlength)
> (repeatedly #(char (+ (int \a) (rand-int 26)
>
> user=> (take 3 (seq-of-rand-strings 10))
> ("kae" "xwuwyp" "xa")
Thanks Chouser. I learned some useful and i
On 12.01.2009, at 06:41, Mark P wrote:
> 1. Some of the algorithms I use have the potential
> to be parallelized. I am hoping that as the number
> of cores in PCs increase, at some point Clojure's
> performance will beat C++'s due to Clojure's
> superior utilization of multiple cores. (Any idea
Hi,
Following in a growing tradition I have written YACS (Yet Another Clojure
Snake); this one uses an Agent to hold the state and has separate GUI and
model threads using
invokeLater to update the GUI from the model in a thread safe way. At least
that was the plan.
My specific aims were to prac
On Mon, Jan 12, 2009 at 6:41 AM, Mark P wrote:
> 1. Some of the algorithms I use have the potential
> to be parallelized. I am hoping that as the number
> of cores in PCs increase, at some point Clojure's
> performance will beat C++'s due to Clojure's
> superior utilization of multiple cores. (
For example, I am pretty sure I don't need to wrap 'send' in 'dosync' (it
works without it).
Tom
2009/1/12 Tom Ayerst
> Hi,
>
> Following in a growing tradition I have written YACS (Yet Another Clojure
> Snake); this one uses an Agent to hold the state and has separate GUI and
> model threads u
Hey,
I would like to contribute to Clojure but I'm not a language designer,
neither familiar with LISP :(
How can I be useful to Clojure project?
Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" grou
Hey,
Clojure is described as a modern dialect of LISP.
What is a "LISP dialect"?
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
Lisp languages stem from the general concept of representing a program
as a data structure made up of lists. Hence, LISt Processing. There
are a lot of variations in how things can work though, for example how
variables are scoped and bound, how variables and functions are
referenced, the bu
This might help: java libraries for fast computing. I guess they will
be usable from within clojure as well.
http://acs.lbl.gov/~hoschek/colt/
Welcome to the Colt Project. Colt provides a set of Open Source
Libraries for High Performance Scientific and Technical Computing in
Java.
Scientific an
1Learn Clojure
2Use it to solve real problems
3Help other people learn it
4Give feedback to Rich about issues so he can improve the implementation
5Maybe submit some useful generic pieces to Clojure Contrib
6Develop the first Killer App
(Personally I'm still on 1 / 2)
Chee
What is (Yet Another Clojure Snake)?
Something like YACC?
On Jan 12, 1:15 pm, "Tom Ayerst" wrote:
> For example, I am pretty sure I don't need to wrap 'send' in 'dosync' (it
> works without it).
>
> Tom
>
> 2009/1/12 Tom Ayerst
>
> > Hi,
>
> > Following in a growing tradition I have written YAC
I just knew someone would say that ;-) (Your acronymic options shrink once
you start with Yet Another... )
If you haven't been following, search for Clojure Snake earlier in the list
(or run the code).
Cheers
Tom
2009/1/12 HB
>
> What is (Yet Another Clojure Snake)?
> Something like YACC?
>
Not a macro, but does what you want:
(defn alt [& functions]
(fn [tokens]
(some #((force %) tokens) functions)))
;define sub-functions the same way
(defn a-meta-meta-function [c]
(alt (delay (sub-function1 c)) (delay (sub-function2 c)) (delay (sub-
function3 c
--~--~-~--~-
On Mon, Jan 12, 2009 at 5:15 AM, Tom Ayerst wrote:
> For example, I am pretty sure I don't need to wrap 'send' in 'dosync' (it
> works without it).
Right. dosync starts a transaction. Agents and Atoms aren't affected
by transactions. You only need dosync when working with Refs.
> 2009/1/12 Tom
On Mon, Jan 12, 2009 at 9:01 AM, Mark Volkmann
wrote:
>
> On Mon, Jan 12, 2009 at 5:15 AM, Tom Ayerst wrote:
>> For example, I am pretty sure I don't need to wrap 'send' in 'dosync' (it
>> works without it).
>
> Right. dosync starts a transaction. Agents and Atoms aren't affected
> by transactio
On Tue, Jan 6, 2009 at 12:00 AM, wubbie wrote:
>
> Hi,
> Why are there multiple "Logging str" output.
Because str calls itself recursively.
> Also in (apply str-orig args), I don't see any args passed at all!
I'm not sure what you mean here. The "args" in (apply str-orig args)
is the list o
On Mon, Jan 12, 2009 at 8:27 AM, Chouser wrote:
>
> On Mon, Jan 12, 2009 at 9:01 AM, Mark Volkmann
> wrote:
>>
>> On Mon, Jan 12, 2009 at 5:15 AM, Tom Ayerst wrote:
>>> For example, I am pretty sure I don't need to wrap 'send' in 'dosync' (it
>>> works without it).
>>
>> Right. dosync starts a
Hi All.
While familiarizing myself with different ways of making my models
concurrent, I ran into something that might be a bug.
given this code, and a 4core machine:
(defn fib [n]
(if (<= n 1)
1
(+ (fib (- n 1)) (fib (- n 2)
(defn pow
"from the tiny math library"
[
Okay, I'm one of Clojure's biggest fans, and probably one of a very
few using it regularly at work. But let me attempt to inject some
reality into the discussion. The big advantages of Clojure are
succinctness and expressiveness within a Java environment. If you have
highly-optimized, custom-desig
On Jan 12, 12:11 am, Mark Fredrickson
wrote:
> I can't imagine this idea will be met warmly, but I have a suggestion.
> It requires ending maps and vectors as functions of keys. Instead,
> make the first argument to a collection be a function which is mapped
> to across the collection. Any
On Jan 12, 10:31 am, Stuart Sierra
wrote:
> On Jan 12, 12:11 am, Mark Fredrickson
> wrote:
>
> > I can't imagine this idea will be met warmly, but I have a suggestion.
> > It requires ending maps and vectors as functions of keys. Instead,
> > make the first argument to a collection be a functi
Awesome—thanks for everyone's answers; I think I'll go with delay/
force. What I'm a little worried about is the caching. After a calling
of "alt" finishes, what happens to all those Delay objects and their
cached values? Are they garbage-collected, or will they remain
indefinitely? Should I worry
On Jan 12, 2009, at 17:11, samppi wrote:
> Awesome—thanks for everyone's answers; I think I'll go with delay/
> force. What I'm a little worried about is the caching. After a calling
> of "alt" finishes, what happens to all those Delay objects and their
> cached values? Are they garbage-collected
> After a calling
> of "alt" finishes, what happens to all those Delay objects and their
> cached values? Are they garbage-collected, or will they remain
> indefinitely? Should I worry?
>
I believe the references to the delays will be dropped as alt
executes, so they'll be eligible for grabage c
On Sun, Jan 11, 2009 at 9:12 PM, Mark Triggs wrote:
>
> I've also found this useful for accessing members in nested maps. For
> example:
>
> (let [me {:person {:name {:first "Mark"
>:last "Triggs"}
> :email "mark.h.tri...@gmail.com"}}]
>(-> me
If you have a blog, you may certainly write about your experience, the
difficulties you encountered learning the language, etc. This can
provide valuable help to other new users as well as give an indication
of what the documentation should cover.
On Jan 12, 4:21 am, HB wrote:
> Hey,
> I would
Hi,
I'm sorry. I wanted to answer you but it somehow got lost.
Am 05.01.2009 um 23:00 schrieb wubbie:
Why are there multiple "Logging str" output.
As Michael already said, it's because the originial str
calls itself recursively.
Here is a thread, which explains this in more detail.
http:/
On Jan 12, 5:24 am, e wrote:
> It's funny, whenever I tried to be all safe like this and take the time to
> make stuff safe in C++, coworkers would say, "we are grown-ups. At some
> point you gotta stop being a paranoid programmer.
Given that software bugs are a very common occurrence, I'd say
On Mon, Jan 12, 2009 at 11:15 AM, Michael Reid wrote:
>
> On Sun, Jan 11, 2009 at 9:12 PM, Mark Triggs wrote:
>>
>> I've also found this useful for accessing members in nested maps. For
>> example:
>>
>> (let [me {:person {:name {:first "Mark"
>>:last "Triggs"}
>>
Chouser's solution works well, but I found that you can end up
with an empty string sometimes or never getting the maxlength
that you passed in.
1:2 user=> (take 3 (seq-of-rand-strings 10))
("ngene" "" "dwlbzndqx")
I added an inc before calling the take and that clears things up.
(defn seq-of-ra
Yeah, doto is a handy complement to ->. I forgot about doto, and
there's a place some code which I'll use now. Thanks Mark!
Kev
On Jan 13, 6:38 am, "Mark Volkmann" wrote:
> On Mon, Jan 12, 2009 at 11:15 AM, Michael Reid wrote:
>
> > On Sun, Jan 11, 2009 at 9:12 PM, Mark Triggs
> > wrote:
>
>
I couldn't figure out how to do this with the included functions/
macros in clojure.contrib.sql so I massaged with-results and do-
prepared together to get this macro (with supporting fn), which seems
to work. Useful addition for contrib.sql?
;; query-with-results should work just like with-resul
Here is an example SWT application. It is a 'search' tool. Open a
file and the search term is highlighted. It has a java oriented
approach because I copied the java code verbatim. This might be
useful if you are still used to imperative programming.
Main source:
http://jvmnotebook.googlecode.
Just a bug in my code, sorry.
On Jan 9, 6:49 pm, BerlinBrown wrote:
> Does anyone see what I am doing here. I am creating someSWTcode.
>
>
>
> (import '(org.eclipse.swt.widgets Display Shell Text Widget))
> (import '(org.eclipse.swt.widgets Label Menu MenuItem Control))
> (import '(org.ecl
For mapping across maps I often find the following utility helpful:
(defn map-map "Like map, but expects f to produce pairs that are
combined to produce a map output."
[f & maps] (reduce #(conj %1 %2) {} (apply map f maps)))
1:1 user=> (map-map (fn [[k v]] [k (str v " Mark")]) {:greet
"hello"
Hi Boris
> (something goes wrong when sending off a million agents, and for a
> while I am only using 1 of the four CPU's.)
> (using send or send-off doesn't seem to make a difference here,
> performance or crash-wise)
Your issue is not agent specific,
consider this code which for me blows up wi
Hi all,
I've got lots of utilities that I think people might find useful, and
might fit well in clojure.contrib (just sent in my contrib agreement
last week). I don't know how the process works to get code in there,
but I figured I'd go ahead and post them all here so people can chime
in about wh
Then why are sets callable? Not that I'm complaining - I found it
handy, then came to wonder why lists aren't.
-Ethan
> I'd just like to add to this discussion that maps and vectors are
> functions not just because it's neat or possible, with the
> implementation one of many possibilities, but
Hi all,
I've just been fiddling with Lucene indexing from Clojure, and wanted
to
access a static field of this inner class:
http://lucene.apache.org/java/2_4_0/api/org/apache/lucene/index/IndexWriter.MaxFieldLength.html
I'm importing IndexWriter$MaxFieldLength with no problems, but
attempts
On Mon, Jan 12, 2009 at 5:56 PM, Jason Wolfe wrote:
>
> For mapping across maps I often find the following utility helpful:
>
> (defn map-map "Like map, but expects f to produce pairs that are
> combined to produce a map output."
> [f & maps] (reduce #(conj %1 %2) {} (apply map f maps)))
>
> 1:
After a fair amount of macro writing in CL, I think I got the
backquote expansion mechanism pretty much nailed down (after all, it
is quite clear in the HyperSpec). Now, I thought I understood the
Clojure algorithm just as well. It looked very similar (concat instead
of append and so on). Apart fr
user=> (import '(java.nio.channels FileChannel))
nil
user=> java.nio.channels.FileChannel$MapMode/READ_ONLY
#
Sorry for the noise!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this gro
To achieve high speed IO I've tried to used mapped FileChannel but
failed to specify MapMode.
user=> (import '(java.nio.channels.FileChannel MapMode))
java.lang.ClassNotFoundException:
java.nio.channels.FileChannel.MapMode (NO_SOURCE_FILE:0)
while
user=> (import '(java.nio ByteOrder))
nil
user
A set is, in a sense, a function mapping from arbitrary objects to
Boolean values. If the object is in the set, it returns true. A list,
in the Lisp world at least, only has two elements, first and rest (car
and cdr in older Lisps). A list object isn't really a "complete"
collection the way vector
I give up.I don't know what's wrong and I don't want to just punt and go
on to a totally different implementation. Can while loops have more that
one statement in the body? Maybe it's something dumb.
I'm not turning my back on what people say about loop/recur or functional
programming. I'm
On Jan 12, 6:49 pm, Rock wrote:
> After a fair amount of macro writing in CL, I think I got the
> backquote expansion mechanism pretty much nailed down (after all, it
> is quite clear in the HyperSpec). Now, I thought I understood the
> Clojure algorithm just as well. It looked very similar (co
OK. Perfect. Thanks. I was worried there for a moment. Next time I'll
read the docs more carefully. My fault.
On Jan 13, 3:29 am, Rich Hickey wrote:
> On Jan 12, 6:49 pm, Rock wrote:
>
>
>
> > After a fair amount of macro writing in CL, I think I got the
> > backquote expansion mechanism prett
i forgot about the wiki. why is this maintained in a totally different page
from clojure.org? I should be looking at these examples:
http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples
On Mon, Jan 12, 2009 at 9:15 PM, e wrote:
> I give up.I don't know what's wrong and I
what is "set!"? I don't see that in the api
On Mon, Jan 12, 2009 at 5:24 PM, BerlinBrown wrote:
>
> Here is an example SWT application. It is a 'search' tool. Open a
> file and the search term is highlighted. It has a java oriented
> approach because I copied the java code verbatim. This mi
Hi,
I've got some suggestions for improving command-line.clj...
It would be great if you could provide a function to be called with
the value of the option and the result of that function binds to the
variable. This would take care of the annoying stuff like calling
(Integer/parseInt intAsStr)
http://clojure.org/vars#toc1
On Jan 12, 2009, at 9:42 PM, e wrote:
> what is "set!"? I don't see that in the api
>
> On Mon, Jan 12, 2009 at 5:24 PM, BerlinBrown
> wrote:
>
> Here is an example SWT application. It is a 'search' tool. Open a
> file and the search term is highlighted. It has
thanks. I think this will be useful, but I have to figure out how to get it
to build in enclojure. Right now I get, "Exception in thread "main"
java.util.MissingResourceException: Can't find bundle for base name
octane_main, locale en_US (octane_main.clj:136)"
On Mon, Jan 12, 2009 at 5:24 PM, Be
> I just want to get this out of my system, but I'm getting some class cast
> exception and no useful line number.
In situations like these I find that looking at the entire stack trace
provides clues. The REPL by default does not print the entire stack
though I'm sure there is a way to achieve t
The gen-class documentation at http://clojure.org/API#toc248 has a
minor typo: the description of the :state keyword begins at the end of
the :factory paragraph instead of beginning a new paragraph. Not a
big deal but it makes the :state description harder to find.
--~--~-~--~~---
On Mon, Jan 12, 2009 at 9:44 PM, aria42 wrote:
>
> Currently, you'd need to do something like this, where you might re-
> def the var
>
> (with-command-line *command-line-args*
> "my-program"
> [[picture "Path to Picture" "/default/path"]]
> (def picture (load-picture picture))
> (blah))
I u
o! all the stuff from listmerge ended up in my-list directly. so
then when listmerge was called on these elements it rightly complained!
Awesome. Lots of good lessons coming out of this.
I need to learn how to run closure code as a script then. I seem to
remember something about this w
by the way, Tim, I've seen NB before as comments in J. What's it stand for?
On Mon, Jan 12, 2009 at 10:39 PM, e wrote:
> o! all the stuff from listmerge ended up in my-list directly. so
> then when listmerge was called on these elements it rightly complained!
> Awesome. Lots of good
o #2 . . . and I totally lost site of what I was doing with l1 and
l2 ! they were already lists because my-list was a list of lists. I new
that when I started, like on Friday.
On Mon, Jan 12, 2009 at 10:39 PM, e wrote:
> o! all the stuff from listmerge ended up in my-list d
Couldn't it have access to the other bindings so far like let? And
then just have the order of options reflect the partial order induced
by dependency? So is this possible...
(with-command-line *command-line-args*
"my-program"
[[size "The size of something" #(if % (Integer/parseInt %) 99)]
> by the way, Tim, I've seen NB before as comments in J. What's it stand for?
An abbreviation for nota bene, a Latin expression meaning "note
well".
> I need to learn how to run closure code as a script then.
http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started
first section shows
On Mon, Jan 12, 2009 at 6:48 PM, Jason Wolfe wrote:
>
> (defn map-when "Like map but discards logically false entries"
> [fn & seqs]
> (filter identity (apply map fn seqs)))
I'd use map-when.
> (defn iterate-while [f x]
> (take-while identity (iterate f x)))
This one too.
It raises a quest
> It all depends on your algorithms and your code. Clojure has lots of
> support (data structures and algorithms) for concurrent programming,
> but you have to choose and combine them yourself to get efficient
> parallelization.
I know that there are other functional approaches where
the co
Hi All,
I'm happy to announce the alpha release of 'Ring', a library inspired
by Python's WSGI and Ruby's Rack for developing web applications in
Clojure.
I've made it as easy as humanly possible for you to try it out:
git clone git://github.com/mmcgrana/ring.git
cd ring
java -Djava
Mark,
This looks great! Thanks for writing and sharing.
-Matt
On Jan 12, 2009, at 11:45 PM, Mark McGranaghan wrote:
>
> Hi All,
>
> I'm happy to announce the alpha release of 'Ring', a library inspired
> by Python's WSGI and Ruby's Rack for developing web applications in
> Clojure.
>
> I've m
my unsafe version works now, thanks to a LOT of help.
(defn msort [toSort]
(with-local-vars [my-list (for [x toSort] [x])]
(while (rest @my-list)
(let [[l1 l2 & my-list-rest] @my-list]
(var-set my-list (conj my-list-rest (listmerge l1 l2)))
)) (first @my-list)))
now I'm try
I'm incredibly impressed! Have only looked at the code briefly but I
read the whole post and I'm really excited for where this is going.
On Jan 12, 2009, at 11:45 PM, Mark McGranaghan wrote:
>
> Hi All,
>
> I'm happy to announce the alpha release of 'Ring', a library inspired
> by Python's W
> JNA might be an alternative to JNI:https://jna.dev.java.net/
> But I wouldn't know; haven't used either.
Thanks for this info. It sounds like JNA may be worth
looking into.
Cheers,
Mark.
--~--~-~--~~~---~--~~
You received this message because you are subscrib
Hi,
I'm still getting used to the primitive support in Clojure, and I want
to confirm my understanding.
As far as I know, primitive support is only supported in local let
bindings, right?
So in designing a vector math library,
To translate from Java, one would write a class with primitive field
> (if (l2)
The problem is on this line. (l2) is a function call.
Replace with (if l2
and it works fine :)
java.lang.IllegalArgumentException: Wrong number of args passed to:
LazilyPersistentVector (NO_SOURCE_FILE:0)
The error message bears a little explaining:
vectors are functions,
user=> (
What's does the req object that is passed into the function have in it?
On Mon, Jan 12, 2009 at 11:45 PM, Mark McGranaghan wrote:
>
> Hi All,
>
> I'm happy to announce the alpha release of 'Ring', a library inspired
> by Python's WSGI and Ruby's Rack for developing web applications in
> Clojure.
To answer my own question:
[#^HttpServletRequest request]
{:server-port (.getServerPort request)
:server-name (.getServerName request)
:remote-addr (.getRemoteAddr request)
:uri (.getRequestURI request)
:query-string (.getQueryString request)
:scheme (keyword (.getScheme request)
seriously? Wow! Interesting.
On Tue, Jan 13, 2009 at 12:53 AM, Timothy Pratley
wrote:
>
> >(if (l2)
>
> The problem is on this line. (l2) is a function call.
> Replace with (if l2
> and it works fine :)
>
> java.lang.IllegalArgumentException: Wrong number of args passed to:
> LazilyPersiste
I hear about boxing a lot. What is it? Thanks.
On Tue, Jan 13, 2009 at 12:49 AM, CuppoJava wrote:
>
> Hi,
> I'm still getting used to the primitive support in Clojure, and I want
> to confirm my understanding.
>
> As far as I know, primitive support is only supported in local let
> bindings, ri
Keys in a map that are of type long can't be looked up in a map using
int literal syntax:
user=> (def my_map { (java.lang.Long. "42") "foo"})
#'user/my_map
user=> my_map
{42 "foo"}
user=> (my_map 42)
nil
user=> (my_map (long 42))
"foo"
user=> (= 42 (java.lang.Long. "42"))
true
I found this b
On Jan 13, 1:21 am, Stuart Sierra wrote:
> If you have
> highly-optimized, custom-designed numerical algorithms written in a
> low-level language like C++, you will never be able to write a version
> that is equally fast in a dynamic, virtual-machine language.
I think you are essentially right (
Do you know Java? It'll be easier to explain if you do.
In Java, everything is an Object. Object's are treated as references
to a specific memory location which holds the actual data. So when you
pass an Object to a method, you're only passing the method the memory
location of that Object.
For p
There's a study someone did that compared C++, Java, and Lisp
implementations of various problems. It could be urban legend, but how I
remember it:
The best C++ implementation was the fastest for each problem.
But the average lisp implementation was faster then the average java or C++
implementat
> {:x 0 :y 0 :z 0}
> I think a map would have too much overhead to retrieve and set keys.
> Is that correct? Although this is the most straight-forward
> conversion.
How about a structmap?
http://clojure.org/data_structures
"StructMaps
Often many map instances have the same base set of keys, for
Instead of that being an error, why not overload the vector function so that
no args calls the version that returns the list. That seems like a good
idea! I wonder if people will object.
On Tue, Jan 13, 2009 at 1:23 AM, e wrote:
> seriously? Wow! Interesting.
>
>
> On Tue, Jan 13, 2009 at 12
>> What's does the req object that is passed into the function have in it?
The contents of the incoming Ring request (and outgoing Ring response)
are described in the SPEC document. I should make this a little
clearer in the docs. Good for you for checking the source though!
> Which by the way i
ah great explanation. That will help a lot. I found that annoying in
Java.
On Tue, Jan 13, 2009 at 1:38 AM, CuppoJava wrote:
>
> Do you know Java? It'll be easier to explain if you do.
>
> In Java, everything is an Object. Object's are treated as references
> to a specific memory location w
On Jan 13, 5:57 pm, e wrote:
> Instead of that being an error, why not overload the vector function so that
> no args calls the version that returns the list. That seems like a good
> idea! I wonder if people will object.
Actually in your case that would not work, because l2 can also be nil.
BTW Rich,
The documentation http://clojure.org/data_structures hints that
accessors are faster than regular map lookups and provides the
following example:
(reduce (fn [n y] (+ n (:fred y))) 0 x)
-> 45
(reduce (fn [n y] (+ n (fred y))) 0 x)
-> 45
However I think it would be cle
Lisps are not inherently slow. SBCL, Clojure and several Schemes are
all much faster than most popular high-level languages (e.g. Python,
Perl, Ruby...) while being at least as high-level.
Optimized code in SBCL may only be marginally slower than C when type
declarations are used properly. The co
You're probably thinking of this:
http://www.flownet.com/gat/papers/lisp-java.pdf
There's also the (in)famous language benchmark site:
http://shootout.alioth.debian.org/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Grou
Hey,
How much Clojure source code is complicated?
I'm not a programming Godfather but I would like to study Clojure
source code.
Could an intermediate programmer like me grasp the source code?
Thanks.
--~--~-~--~~~---~--~~
You received this message because you are s
87 matches
Mail list logo