So I'm going to stop pretending like I'm an expert and actually post
some Clojure code. Be constructively critical 'cause I'm a n00b in
that regard ;-) This is a pseudorandom number generator for the
Gaussian (0,1) distribution.
(defn next-gaussrand-state [current-
state]
^{:doc "Given the cu
On Dec 14, 6:06 am, Dan Larkin wrote:
> Yes, I'd like the feature because it's a pain in the neck to go
> through and escape strings when I know there's a better way.
For escaping strings, I prefer ruby's solution, which is to have
reader support for arbitrary delimiters, either matched pairs
I've got an issue where the clojure.xml/parse and /emit functions are
not symmetric with respect to how attributes are read and written.
The parser decodes HTML entities (e.g. & -> &) however the emitter
does not re-encode them:
user> (require ['clojure.xml :as 'xml])
nil
user> (xml/emit (xml/par
On Sat, Dec 13, 2008 at 6:39 PM, Chouser wrote:
>
> On Sat, Dec 13, 2008 at 4:46 PM, Mark Volkmann
> wrote:
>>
>> I just updated to the latest version of clojure-contrib. show works
>> for me, but source doesn't. Here's what I did.
>>
>> (require 'clojure.contrib.repl-utils)
>> (show 1/2) ; giv
On Sat, Dec 13, 2008 at 7:06 PM, Dan Larkin wrote:
>
> Yes, I'd like the feature because it's a pain in the neck to go
> through and escape strings when I know there's a better way.
>
> Also sometimes it doesn't feel right to escape strings... for instance
> in function doc strings I'd like to gi
On Saturday 13 December 2008 17:19, Drew Olson wrote:
> ...
>
> You can also compile vim from source with the +ruby flag
Yes, of course, but that's a bridge too far.
> - Drew
RRS
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the
On Dec 13, 2008, at 2:10 AM, Meikel Brandmeyer wrote:
> Hi Randall,
>
> Am 12.12.2008 um 23:29 schrieb Randall R Schulz:
>> I guess what you should say at least is that it requires Ruby and the
>> Vim Ruby module / extension / whatever. Unfortunately, neither of the
>> systems I use have that in
Yes, I'd like the feature because it's a pain in the neck to go
through and escape strings when I know there's a better way.
Also sometimes it doesn't feel right to escape strings... for instance
in function doc strings I'd like to give an example return value. But
if the value has to be e
On Dec 13, 9:34 pm, Dan Larkin wrote:
> I'm here to ask for python style triple-double-quotes syntax in clojure.
I'm not completely sure they're needed, to be honest. In Python,
triple quotes have 2 benefits: multi-line quotes and you don't have to
escape quotation marks. In Clojure, normal quot
On Sat, Dec 13, 2008 at 4:46 PM, Mark Volkmann
wrote:
>
> I just updated to the latest version of clojure-contrib. show works
> for me, but source doesn't. Here's what I did.
>
> (require 'clojure.contrib.repl-utils)
> (show 1/2) ; gives the output you show above
You must be getting 'show' from
Hi,
Here's another patch from me:
The clojure.lang.Range type is implemented with integer type start and
end indices. The core.clj range function should detect when an index
doesn't fit inside an int and create an increasing sequence using
iterate instead. The current implementation detects
Hi,
thanks for Clojure! Here's my first contribution (CA filled out and
will arrive next week):
Negating Integer.MIN_VALUE overflows but should return a BigInteger.
It also affects binary subtraction since Clojure implements it using
negation and addition. The overflow occurs silently withou
On Saturday 13 December 2008 15:35, Randall R Schulz wrote:
> ...
>
> Any algorithm that requires to O(n) steps is itself O(n).
And by that I meant "...two O(n) steps...", of course.
> The big-O concept is roughly "equality up to a constant factor."
Randall Schulz
--~--~-~--~~---
On Saturday 13 December 2008 14:29, levand wrote:
> > ...
>
> > Calling reverse when done is still O(N)
>
> Really? Maybe my grasp of big-O notation is faulty, but isn't the
> recursive function itself O(n), and then a reversal another O(n)
> operation on top of that, leading to two complete trave
> Really? I get:
>
> (last (copy-seq (range 10)))
> -> 9
I'm running inside of VirtualBox assigned very little memory. Maybe
that's why? I'll run some more tests. I know I have been able to get
up to 3000 levels of recursion without a stack overflow, once, at
another time.
In any case, i
Did you ever get this resolved? I just had the same thing start
happening to me today, after not experiencing any problems with it as
recently as yesterday. (What changed? I tried to install swank.
Nuking swank did not fix the problem, tho.) Step by step:
(add-classpath ...) ; seems to work, b
On Dec 12, 2008, at 3:24 PM, Stuart Sierra wrote:
> It's been a month since Clojure rev. 1094 introduced the namespace-is-
> file change. Are people still using releases that require the old
> contrib directories, or can we safely delete them?
They're gone now as of SVN rev. 299.
-Stuart Sierra
Konrad,
I've looked over your monad code and I like it, FWIW.
The macro programming will twist your mind if you don't have
experience writing Lisp style macros, but the resulting syntax seems
pretty clean.
I would make some minor changes in two places. I would write with-
monad as:
(defmacro
On Fri, Dec 12, 2008 at 11:37 PM, Chouser wrote:
>
> I've added updated versions of 'show' and 'source' to a new lib named
> clojure.contrib.repl-utils
>
> 'show' is for exploring classes at the REPL. What's new is that it
> now displays the modifiers of the class and the parameter types for
> e
Fellow clojurecrats,
I'm here to ask for python style triple-double-quotes syntax in clojure.
For those unfamiliar they're documented here:
http://docs.python.org/reference/lexical_analysis.html#strings
This is also a nice summary:
http://diveintopython.org/getting_to_know_python/documenting_
On 13 déc, 17:03, Michel Salim wrote:
> On Dec 13, 8:28 am, lpetit wrote:> Hello,
>
> > I wanted to know if I was alone thinking that 'mapcat' should better
> > have been named 'catmap' ?
> > When reading code, this looks more natural because it resembles the
> > functional composition of the 2
I'm looking at the terminal case. It's the difference between running
clojure.lang.Repl and clojure.main (which runs a repl by default). The
reading done by the latter is intended to be identical to the reading
done by the former but isn't in the case of read-line. If anyone sees
the fix b
thanks for pointing this out, and I absolutely appreciate the example.
I'm still new to functional approach and I always like to see how
things are done properly.
On Dec 13, 1:15 pm, Chouser wrote:
> On Sat, Dec 13, 2008 at 10:41 AM, Dmitri wrote:
>
> > I wrote a simple word counter described h
To give an example, I tried running through the Iliad from project
gutenberg, it's roughly 1MB of text http://www.gutenberg.org/files/6130/6130.txt
and the program takes ~4600 ms to run, if I comment out printing of
results it runs in ~3700 ms.
By contrast a java version runs in ~560ms.
Now, obv
On Sat, Dec 13, 2008 at 10:41 AM, Dmitri wrote:
>
> I wrote a simple word counter described here http://ptrace.fefe.de/wp/
> it reads stdin and counts the occurrences of words, however I notice
> that it runs significantly slower than the java version in the link.
There are several differences t
I added the time call later on to find what was taking up the cycles,
I also checked the reverse, it's impact is minimal, the print-words
part of the program runs fast, but the read-words takes the majority
of the time.
On Dec 13, 12:38 pm, Jeremy Dunck wrote:
> On Dec 13, 9:41 am, Dmitri wrote
On Dec 13, 9:41 am, Dmitri wrote:
...
> The slowdown seems to occur in the inc-count
> function, where it "updates" the map using the assoc. Is this not a
> proper way to approach this in clojure?
(recur (time (inc-count words head)) tail
You're pretty tightly looping here-- a
Thanks Meikel, removing the ~'s worked. Oh and thanks for vimclojure and
gorilla!
On Sat, Dec 13, 2008 at 9:28 AM, Meikel Brandmeyer wrote:
> Hi,
>
> Am 13.12.2008 um 17:17 schrieb Brian Doyle:
>
> Here is my script:
>>
>> java -cp
>> ~/share/clojure.jar:~/share/clojure-contrib.jar:~/share/gor
On Saturday 13 December 2008 08:17, Brian Doyle wrote:
> I'm sure I'm doing something stupid but I can't start up gorilla.
>
> ...
>
> Here is my script:
>
> java -cp
> ~/share/clojure.jar:~/share/clojure-contrib.jar:~/share/gorilla.jar
> de.kotka.gorilla
Tildes don't expand anywhere but at the b
Konrad,
I got your code to work by doing the following:
Replaced with-monad with:
(defmacro with-monad
[name & exprs]
(let [bind-sym 'm-bind
result-sym 'm-result
zero-sym 'm-zero
plus-sym 'm-plus]
`(let [~bind-sym (:m-bind ~name)
~result-sym (:m-result ~na
On Sat, Dec 13, 2008 at 11:17 AM, Brian Doyle wrote:
> I'm sure I'm doing something stupid but I can't start up gorilla.
>
> Exception in thread "main" java.lang.NoClassDefFoundError: de/kotka/gorilla
> Caused by: java.lang.ClassNotFoundException: de.kotka.gorilla
> at java.net.URLClassLoader
Hi,
Am 13.12.2008 um 17:17 schrieb Brian Doyle:
Here is my script:
java -cp ~/share/clojure.jar:~/share/clojure-contrib.jar:~/share/
gorilla.jar de.kotka.gorilla
I can reproduce the issue. The ~ is a shellish feature
from Unix. It is only expanded at the start of a word.
So the first ~ in y
I'm sure I'm doing something stupid but I can't start up gorilla.
Exception in thread "main" java.lang.NoClassDefFoundError: de/kotka/gorilla
Caused by: java.lang.ClassNotFoundException: de.kotka.gorilla
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessContr
On Dec 13, 9:27 am, wubbie wrote:
>
> My question is what's the usage for ture?. I don't see a meaningful
> example on usage of true?
>
At the very least, when you have to interface with Java? Also, your
code might use true as a special value -- say as values inside a key
to indicate you don't ca
On Dec 13, 8:28 am, lpetit wrote:
> Hello,
>
> I wanted to know if I was alone thinking that 'mapcat' should better
> have been named 'catmap' ?
> When reading code, this looks more natural because it resembles the
> functional composition of the 2 functions : (cat (map ...))
>
mapcat, I take to
On Dec 13, 10:41 am, Dmitri wrote:
> I wrote a simple word counter described herehttp://ptrace.fefe.de/wp/
> it reads stdin and counts the occurrences of words, however I notice
> that it runs significantly slower than the java version in the link.
>
> I was wondering why there is such a dramatic
On Dec 13, 4:26 am, Michel Salim wrote:
> Using up-to-date clojure and swank-clojure, I've not been able to use
> read-line:
>
> - In Emacs (with Slime / swank-clojure), (read-line) never stops
> consuming inputs
>
> - Running clojure directly from a terminal console, (read-line) always
> retur
On Dec 13, 4:11 pm, levand wrote:
> Right... I realize there is absolutely no need to actually do this, it
> was more of an exercise in understanding ways to iterate over seqs.
> For example, I might want to do something else than a straight copy.
map is a good way to iterate over seq. E.g.
(m
I wrote a simple word counter described here http://ptrace.fefe.de/wp/
it reads stdin and counts the occurrences of words, however I notice
that it runs significantly slower than the java version in the link.
I was wondering why there is such a dramatic difference. The approach
I took was to crea
Hi,
Am 13.12.2008 um 15:07 schrieb Randall R Schulz:
I installed a couple of new packages on my 10.3 box and
now "vim --version" reports +ruby, so I guess I can at least give it a
try there (that's not my primary box, though it is the faster one).
Unfortunately, vim by itself cannot do, what I
I've had a really quick look at your mode, it looks good, and I like the
regularity in keyword highlighting. I'm going to have a proper look sometime
later on the weekend and will get back to you when I have done.
Kind Regards,
David.
2008/12/12 Daniel Spiewak
>
> Sounds like a good plan. :-
On Dec 12, 9:51 pm, levand wrote:
> So, I'm trying to understand functional programming, particularly as
> it relates to the seq abstraction, and I'm hitting a slight difficulty
> as I'm playing around - something that seems as if it ought to be
> simple, is not.
>
> I'm playing with copying on
Hello,
While reading the book, I came across the phrase
"true? tests whether a value is actually true, not
whether the value evaluates to true in a boolean context. The only
thing
that is true? is true:
(true? true)
-> true
(true? "foo")
-> false
Be careful with predicates ..."
My question is wh
Right... I realize there is absolutely no need to actually do this, it
was more of an exercise in understanding ways to iterate over seqs.
For example, I might want to do something else than a straight copy.
Thanks for the replies...
On Dec 13, 8:12 am, lpetit wrote:
> Yes, the semantics of a s
On Saturday 13 December 2008 00:10, Meikel Brandmeyer wrote:
> Hi Randall,
>
> ...
>
> For your problem with the ruby-enabled vim: at least
> debian has a vim-ruby package, IIRC. So maybe Suse
> has this also.
I installed a couple of new packages on my 10.3 box and
now "vim --version" reports +r
On Dec 13, 2008, at 2:18 AM, Mark Engelberg wrote:
>
> On Fri, Dec 12, 2008 at 9:28 PM, Rich Hickey
> wrote:
>> I think it's very important not to conflate different notions of
>> sequences. Clojure's model a very specific abstraction, the Lisp
>> list,
>> originally implemented as a singly
Hello,
I wanted to know if I was alone thinking that 'mapcat' should better
have been named 'catmap' ?
When reading code, this looks more natural because it resembles the
functional composition of the 2 functions : (cat (map ...))
I know this is an inheritence from older lisp dialects, but cloju
On 13 Dec 2008, at 12:39, Dave Newton wrote:
>
> --- On Sat, 12/13/08, Stephen Parker wrote:
>> On 12 Dec 2008, at 23:10, Mark Fredrickson wrote:
>>> [...] insert 3 before every item less than or equal to 5 in a seq:
>>
>> (def bar [24 6 5 5 7 5 8 2])
>> (insert-before-if #(<= 5 %) 3 bar)
>>
>> =>
Yes, the semantics of a sequence force it to be immutable :
"Seqs differ from iterators in that they are persistent and
immutable" ( http://clojure.org/sequences )
So there's simply no need to have a copy function for sequences (or
for any other clojure data structure).
HTH,
--
Laurent
On 13
On Dec 13, 4:51 am, levand wrote:
> So, I'm trying to understand functional programming, particularly as
> it relates to the seq abstraction, and I'm hitting a slight difficulty
> as I'm playing around - something that seems as if it ought to be
> simple, is not.
>
> I'm playing with copying one
--- On Sat, 12/13/08, Stephen Parker wrote:
> On 12 Dec 2008, at 23:10, Mark Fredrickson wrote:
>> [...] insert 3 before every item less than or equal to 5 in a seq:
>
> (def bar [24 6 5 5 7 5 8 2])
> (insert-before-if #(<= 5 %) 3 bar)
>
> => (3 24 3 6 3 5 3 5 3 7 3 5 3 8 2)
Er...
Dave
--~--
Using up-to-date clojure and swank-clojure, I've not been able to use
read-line:
- In Emacs (with Slime / swank-clojure), (read-line) never stops
consuming inputs
- Running clojure directly from a terminal console, (read-line) always
returns ""
This exception is also thrown when starting Swank:
On 12 Dec 2008, at 23:10, Mark Fredrickson wrote:
>> For (2), say I want to insert 3 before every item less than or equal
>> to 5 in a seq:
>
> Again reduce to the rescue:
>
> (reduce into (map (fn [i] (if (<= i 5) [3 i] [i])) [24 6 5 5 7 5 8
> 2]))
Could use mapcat:
(def bar [24 6 5 5 7 5 8
Hi Randall,
Am 12.12.2008 um 23:29 schrieb Randall R Schulz:
I guess what you should say at least is that it requires Ruby and the
Vim Ruby module / extension / whatever. Unfortunately, neither of the
systems I use have that in their Vim builds.
From the vim.org page, where you can download Go
54 matches
Mail list logo