Sure. BigInteger.doubleValue() casts to infinity if the value is too
large to be represented:
user (double (fact 1000))
Infinity
You could try this using BigDecimals instead of doubles:
user (+ 0.5M (fact 1000))
-Per
On Sat, Oct 9, 2010 at 11:08 AM, Miki miki.teb...@gmail.com wrote:
If the
Try something like this:
(defn dmap [ args]
(for [[head items] args]
item in items]
[head item]))
-Per
On Thu, Oct 7, 2010 at 1:29 PM, Stefan Rohlfing
stefan.rohlf...@gmail.com wrote:
Dear Clojure Group,
Following an Enlive tutorial I wanted to implement a function 'd-map'
Your manual composition of concat and map is the same as the built-in
function mapcat.
Anyway, all this is what (for ...) does for you under the covers.
-Per
On Thu, Oct 7, 2010 at 1:52 PM, Michael Gardner gardne...@gmail.com wrote:
On Oct 7, 2010, at 1:29 AM, Stefan Rohlfing wrote:
That's some great work there, George!
Are there any basic obstructions in the backend to doing
expression-oriented rather than line-oriented breakpoints and
stepping?
-Per
On Sat, Oct 2, 2010 at 3:32 AM, George Jahad
cloj...@blackbirdsystems.net wrote:
For your delectation:
With all these reports of performance degradation, it sounds like it
would be really useful to have a performance regression suite.
-Per
On Thu, Sep 30, 2010 at 1:19 PM, Mark Engelberg
mark.engelb...@gmail.com wrote:
bitwise-and and bitwise-shift-right and bitwise-shift-left run more
than 50
I would use something like this:
(defn zip [ xss]
(apply map vector xss))
(doseq [[x y] (zip [1 2 3] [11 22 33])]
(println x y))
Most of the time I use parallel mapping directly. But in cases like
this one I think the intention of the code is better expressed by the
above
The namespace binding is what's holding onto the head. This is a
common enough question (which tends to occur more in toy programs than
real ones) that it probably belongs in a FAQ.
-Per
On Fri, Sep 24, 2010 at 9:58 PM, Jeff Palmucci jpalmu...@gmail.com wrote:
Sorry, I posted this question and
Cool!
I'm getting back to Clojure after an extended absence. Just today I
was pondering the design of a solution to a similar problem, though I
suspect our requirements diverge on several points. My tentative
conclusion was that it could be done entirely in Clojure and without
modifying existing
On Thu, Sep 23, 2010 at 8:16 PM, Alyssa Kwan alyssa.c.k...@gmail.com wrote:
There's no need for any transaction boundary; you just
have to make sure that compareAndSet does a durable swap.
I had the chance to read your code today. You have a transaction
boundary in DRef.set() which is called by
were outside
LockingTransaction.run(), the order could (and probably would) be
different between in-memory resources and durable resources. For
ultimate safety, we need to be even more intrusive and add a prepare
phase to the STM.
On Sep 23, 11:05 pm, Per Vognsen per.vogn...@gmail.com wrote
If you have a fixed cell topology, you can also find a coloring of the
graph and use it for contention-free scheduling. With a regular grid,
you can use the obvious 2-coloring (a checkerboard pattern), so you
would handle all the white squares in phase 1 and all the black
squares in phase 2.
-Per
With XNA running on the Xbox 360, reflection is the least of your
worries. The runtime uses a very poor non-generational mark-and-sweep
collector. At the rate of memory allocation in a typical Clojure
program, you would be faced with constant GC hitches. Even people
writing XNA games in C# (where
On Sun, Jul 18, 2010 at 11:32 AM, Carson c.sci.b...@gmail.com wrote:
I guess different people see things differently. I actually didn't
understand the intent of the imperative version, even though it takes
less lines I guess. There's quite a few things called convolution.
My naive
Here's how it works with Haskell:
The Prelude module is imported automatically into all modules as if
by the statement `import Prelude', if and only if it is not imported
with an explicit import declaration. This provision for explicit
import allows values defined in the Prelude
On Sat, May 1, 2010 at 7:25 PM, Lee Spector lspec...@hampshire.edu wrote:
about how to write a real random bignum generator.
Let n be the bignum upper bound on the desired range. Find the
quotient q and remainder r of n by b = 2^31-1. Generate q random
numbers with upper bound b and one random
of the textbook algorithms for generating
non-power-of-two random numbers from random bit streams should apply
to this kind of situation.
-Per
On Sat, May 1, 2010 at 8:48 PM, Per Vognsen per.vogn...@gmail.com wrote:
On Sat, May 1, 2010 at 7:25 PM, Lee Spector lspec...@hampshire.edu wrote:
about how
Consider:
(def as (lazy-seq (cons 1 bs)))
(def bs (lazy-seq (cons 2 cs)))
;; ...
(def zs (lazy-seq (cons 26 as)))
Suppose you start two threads concurrently. The first forces 'as' and
the second forces 'zs'. If the timing is just right, this can result
in a deadlock:
// LazySeq.java
final
On Mon, Apr 26, 2010 at 5:55 PM, Meikel Brandmeyer m...@kotka.de wrote:
Hi,
On 26 Apr., 11:22, Per Vognsen per.vogn...@gmail.com wrote:
Consider:
(def as (lazy-seq (cons 1 bs)))
(def bs (lazy-seq (cons 2 cs)))
;; ...
(def zs (lazy-seq (cons 26 as)))
Suppose you start two threads
On Mon, Apr 26, 2010 at 6:15 PM, Per Vognsen per.vogn...@gmail.com wrote:
[...]
The idea is to try to create a situation where a pair of LazySeqs, xs
and ys, are interlinked in a cycle such that the first thread forces
them in order xs, ys while the second thread concurrently forces them
Okay, that is a blatant infinite loop that has nothing to do with
deadlocks. I give up. This combination of laziness and concurrency and
locking is giving me a headache. Sorry about the distraction,
everyone.
-Per
On Mon, Apr 26, 2010 at 6:23 PM, Per Vognsen per.vogn...@gmail.com wrote:
On Mon
A lot of these arguments go away with functional programming. With a
functional queue, you might as well store the length as a value
attribute because it won't ever change. In some cases I can see the
argument for on-demand computation of fields with referentially
transparent caching. That's where
How about this?
(use 'clojure.contrib.str-utils 'clojure.contrib.duck-streams)
(defn parse [file]
(let [r (reader file)]
(map (fn [line] (map #(Integer/parseInt %) (.split line )))
(take (Integer/parseInt (.readLine r)) (repeatedly
#(.readLine r))
(defn unparse [xss file]
(.readLine r))
(repeatedly #(.readLine r)))]
(map #(Integer/parseInt %) (.split line )
-Per
On Thu, Apr 22, 2010 at 10:29 PM, Per Vognsen per.vogn...@gmail.com wrote:
How about this?
(use 'clojure.contrib.str-utils 'clojure.contrib.duck-streams)
(defn parse
Yet another variation:
(defn conjugate [f g [g-inv]]
(comp (or g-inv g) f g))
(defn composite [f f-inv n x]
(nth (iterate (if (pos? n) f f-inv) x) (abs n)))
(defn rotate-left [xs]
(when (seq xs) (concat (rest xs) [(first xs)])))
(def rotate-right (conjugate rotate-left reverse))
(defn
function.
From this, it follows (with no extra work) that the conjugate
transformation of an invertible function is an invertible function.
-Per
On Thu, Apr 22, 2010 at 10:38 AM, Michał Marczyk
michal.marc...@gmail.com wrote:
On 22 April 2010 03:51, Per Vognsen per.vogn...@gmail.com wrote:
Yet
You might want to check out this paper on a simple functional I/O system:
http://www.ccs.neu.edu/scheme/pubs/icfp09-fffk.pdf
The basic idea is really simple and natural. I've used something
similar in my own past programs and I noticed that Penumbra has a
GLUT-like event-driven interface that
On Tue, Apr 20, 2010 at 6:43 PM, jvshahid jvsha...@gmail.com wrote:
Thanks Per,
This definitely works
Try (loop [x (. 1 longValue)] (if (= 0 x) x (recur (- x (long 1).
but from my understanding of clojure internals clojure.lang.Numbers
should take care of that.
The Numbers class
On Tue, Apr 20, 2010 at 7:02 PM, Per Vognsen per.vogn...@gmail.com wrote:
With the way primitive types are currently supported in the compiler,
if you wanted it to work the way you expect, you'd need to express the
complicated arithmetic tower and its grid of type conversions in a
static form
On Mon, Apr 19, 2010 at 6:29 PM, Meikel Brandmeyer m...@kotka.de wrote:
PS: Tested with 1.0, though. So maybe this changed to 1.1.
No, even in HEAD there is only support for reading doubles. It would
be nice if the reader supported the customary 'f' suffix for reading
floats. I actually made
On Tue, Apr 20, 2010 at 8:34 AM, jvshahid jvsha...@gmail.com wrote:
(loop [x (. 1 longValue)] (if (= 0 x) x (recur (- x 1
Try (loop [x (. 1 longValue)] (if (= 0 x) x (recur (- x (long 1).
-Per
--
You received this message because you are subscribed to the Google
Groups Clojure group.
# (assoc (meta (var r#)) :name (:name
r#)))]
(register-rule reg-r#)
reg-r#)))
On Apr 17, 10:48 am, Per Vognsen per.vogn...@gmail.com wrote:
On Sat, Apr 17, 2010 at 2:29 AM, Kevin Livingston
kevinlivingston.pub...@gmail.com wrote:
I have an application that will read in a large
(use 'clojure.contrib.combinatorics
'clojure.contrib.str-utils)
(defn anagrams [xs]
(map #(str-join %) (distinct (permutations xs
Of course, the real meat is in the permutations function. The
implementation in the combinatorics library is a bit complicated.
Here's something simpler
On Mon, Apr 19, 2010 at 10:30 AM, falcon shahb...@gmail.com wrote:
1. core.clj is a gigantic library with more than 400 function
definitions (378 defns and 62 defmacros to be exact). I didn't expect
to find sequence related functions, such as map/reduce in core.
Doesn't it make sense to move
referring symbols, you can then specify a group mask with
:only-groups and :exclude-groups to compliment the current :only and
:exclude features.
-Per
On Mon, Apr 19, 2010 at 11:28 AM, Per Vognsen per.vogn...@gmail.com wrote:
On Mon, Apr 19, 2010 at 10:30 AM, falcon shahb...@gmail.com wrote:
1
On Mon, Apr 19, 2010 at 12:15 PM, falcon shahb...@gmail.com wrote:
As I understand it, map is, itself, lazy. Does that mean that using
map to implement these methods would create extra intermediate
structures?
Yes.
What if often used functions such as map/reduce/filter were macros,
that
Not currently. I added the capability to some code I posted last month
for fixing print-method for promises so they aren't auto-dereferenced
when undelivered:
(defn promise?
[p]
(isa? (type p) ::Promise))
(defn promise-delivered?
[p]
(zero? (.getCount (:d p
(defmethod print-method
On Sat, Apr 17, 2010 at 11:07 PM, alux alu...@googlemail.com wrote:
Hello Per,
thats very cool! Many thanks! Completely solves my problem. (As far as
I can see :-)
I'm not sure whether I completely understand the implications of the
nondeterminism you described; will think about it. You say
On Sat, Apr 17, 2010 at 2:29 AM, Kevin Livingston
kevinlivingston.pub...@gmail.com wrote:
I have an application that will read in a large number of structures
from a file. those structures will be used throughout the application
to produce additional data etc. since they are user
What may confuse is that map destructuring swaps the positions of keys
and values as compared to map literals:
user (let [{x :body} {:body 42}]
x)
42
It does conform to the pattern that the bound variable precedes the
value to bind in forms like let. A benefit of this ordering is that
On Fri, Apr 16, 2010 at 12:41 PM, Aravindh Johendran
ajohend...@gmail.com wrote:
Sorry, I shoulda been clearer. By similar functionality, i meant a 20-
q game with
1) the network implemented as closures and
There are various ways you can do this while separating concerns. If
you don't mind
in the literal syntax and so impose no symmetry
constraints.
-Per
On Fri, Apr 16, 2010 at 9:25 PM, Asim Jalis asimja...@gmail.com wrote:
On Fri, Apr 16, 2010 at 2:15 AM, Per Vognsen per.vogn...@gmail.com wrote:
What may confuse is that map destructuring swaps the positions of keys
and values
It doesn't seem confusing to me. You are taking complete control of
the set's local notion of ordering and equality. This is what I'd
expect.
Here's an example. First, a handy little function from Haskell:
(defn on [key f]
#(apply f (map key %)))
Then:
user (sorted-set-by (on :id compare)
Maybe the example was poorly picked but the point stands: if you're
asking for a sorted set based on a comparator, you should expect
duplicate elements as dictated by comparator to be eliminated. If you
wanted to sort a set of people by age, you wouldn't use a sorted set
but a sorted sequence.
On Sat, Apr 17, 2010 at 12:01 AM, Sean Devlin francoisdev...@gmail.com wrote:
I know you might not like it, but there is a convention in JavaLand
that a comparator value of 0 is identical in a sorted collection.
It's not a Java convention. It's intrinsic to the business of sorting.
For sorting
Tangent:
On Fri, Apr 16, 2010 at 7:41 PM, Douglas Philips d...@mac.com wrote:
(1) http://clojure.org/data_structures says:
... seq returns a sequence of map entries, which are key/value pairs. ...
I haven't yet found where in the docs a pair is defined, so I am guessing
that the concrete
Equality and ordinality are not the same thing. It should be
perfectly reasonable to hand someone a set of unique objects sorted by
some non-unique attribute of the elements of the set.
Sure, it's perfectly reasonable but it implies a different data
structure. It sounds like you want a data
On Sat, Apr 17, 2010 at 1:05 AM, Per Vognsen per.vogn...@gmail.com wrote:
You can only do slow
linear-time lookups by traversing the tree's nodes exhaustively.
Correction: You do not have to do a linear search on the whole tree
but only on the subset of the tree for which the comparator returns
What do you mean by similar functionality? Without using mutable
state, you won't be able to retain the defnode-style interface. But
obviously a twenty-questions program like this is easy to implement in
a purely functional way:
(defn ask [questions node]
(let [data (questions node)]
The first thing I ever implemented with promises was dataflow
programming in this style. A good read is the chapter on declarative
concurrency in Peter van Roy's Concepts, Techniques and Models of
Computer Programming. Oz has the concept of concurrent
single-assignment variables, which are much
On Fri, Apr 16, 2010 at 3:16 AM, TimDaly d...@axiom-developer.org wrote:
This might be interesting when the discussion of events vs threads
comes up:
http://www.usenix.org/events/hotos03/tech/full_papers/vonbehren/vonbehren_html/
Essentially they argue that thread programming can scale (100k
Is there any written rationale for direct binding? It sounds like a
poor man's inlining, except we already have perfectly good opt-in
inlining.
If these screwy semantics are to remain, an absolute minimum courtesy
would be for 'binding' to throw an exception at macro expansion time
when one tries
That sounds weird. If you know what keys weren't making it into the
index as expected, did you try reducing the problem to a smaller test
case involving those exceptional keys?
-Per
On Fri, Apr 16, 2010 at 11:50 AM, Luc Préfontaine
lprefonta...@softaddicts.ca wrote:
Hi all,
I tripped over
You can rebind *prxml-indent*. It's by nil by default, which means no
indentation and (confusingly) no line breaks. If you set it to 0, you
will get line breaks but with no indentation. With a greater value,
you will get line breaks with indentation. If you had looked at the
code, this should have
On Fri, Apr 9, 2010 at 10:39 PM, Josh Stratton strattonbra...@gmail.com wrote:
Here's an example of trying to use map to bring the two tables
together together in the same scope. I'm doing this because the nth
element in one sequence correlates to its nth counterpart in the
second sequence.
On Sat, Apr 10, 2010 at 10:22 AM, Douglas Philips d...@mac.com wrote:
On 2010 Apr 9, at 9:04 PM, Per Vognsen wrote:
On Sat, Apr 10, 2010 at 7:48 AM, Douglas Philips d...@mac.com wrote:
Odd:
user= (binding [m1 (fn [a b] (println m1 from binding a b))]
(eval '(if true (m1
On Sat, Apr 10, 2010 at 12:25 PM, Douglas Philips d...@mac.com wrote:
The differences between def and binding are also weird, since binding does
not also shadow the meta-data on the var, so not only :macro will be wrong,
but :file, :line, :arglists could also be wrong.
The binding form doesn't
have a question like this.
It's often useful to execute the offending form step by step, to see
what the result of each computation is.
Love the REPL.
Sean
On Apr 7, 8:45 pm, Per Vognsen per.vogn...@gmail.com wrote:
The second case is equivalent to (into [] [{:a 1 :b 2}]). You're
passing
You can easily code positional keyword parameters yourself. It takes
only a few minutes for a basic version. Here's an admittedly not very
pretty example:
http://gist.github.com/360145
-Per
On Thu, Apr 8, 2010 at 9:13 PM, Sophie itsme...@hotmail.com wrote:
On Apr 7, 7:56 am, David Nolen
Or you can separate concerns a bit more:
(defn transpose [xs]
(apply map vector xs))
Now Nurullah's original suggestion applies:
(map #(apply max %) (transpose xs))
-Per
On Fri, Apr 9, 2010 at 12:38 AM, James Reeves
weavejes...@googlemail.com wrote:
On Apr 8, 1:13 pm, John Sanda
On Fri, Apr 9, 2010 at 10:04 AM, Douglas Philips d...@mac.com wrote:
I'm trying to understand how the two forms here differ:
In a fresh repl:
user= '((a) (b) (c))
((a) (b) (c))
which is OK, those are just symbols.
But then:
user= (defn x [] (a) (b) (c))
On Fri, Apr 9, 2010 at 10:35 AM, Douglas Philips d...@mac.com wrote:
On 2010 Apr 8, at 11:16 PM, Per Vognsen wrote:
It's not a defn thing. If you write (do (a) (b) (c)) at the REPL, you
should see the same exception.
Yes, I would expect that since at the REPL I am asking to have
On Fri, Apr 9, 2010 at 11:26 AM, Douglas Philips d...@mac.com wrote:
On 2010 Apr 8, at 11:48 PM, Per Vognsen wrote:
The body of fn is still compiled in an expression context. When the
compiler sees (fn [...] ...), it will introduce the bindings into the
local environment and recursively
On Tue, Apr 6, 2010 at 9:59 PM, Christophe Grand christo...@cgrand.net wrote:
Btw, to some extent, one can create cyclic data-structures in Clojure (only
lazyseqs though -- unless you implement your own map or use lazy-map etc.) :
user= (defn cyclic-seq [coll] (let [s (promise)] @(deliver s
On Tue, Apr 6, 2010 at 10:43 PM, Douglas Philips d...@mac.com wrote:
On 2010 Apr 6, at 10:59 AM, Christophe Grand wrote:
The cycles are gone but the identity john-doe aand its curren-state are
still conflated so you get the same problem:
Thus, since simple trees have the exact same issues,
You need a level of indirection. One way is to make the backward
reference from accounts to owners be based on a non-pointer primary
key (maybe a keyword) that can be resolved through some table. This is
how it works in relational database systems
If you want to use references of some sort,
of with-transient. I think
(with-transient f x)
reads easier. Also, it should probably end with a bang, because I
don't think it's safe in the STM.
Great work guys.
Sean
On Apr 5, 12:52 am, Per Vognsen per.vogn...@gmail.com wrote:
On Mon, Apr 5, 2010 at 11:33 AM, Lee Spector lspec
It's no more mutable than a pure lambda calculus with lazy evaluation.
There is no _observable_ mutability. Anything else is an
implementation detail.
Single assignment comes from the tradition of logic programming and
concurrent process calculus rather than lambda calculus. A single
assignment
(map #(fn? (when-let [x (resolve (symbol %))] @x)) [map, first,
nofun]) should do the trick. But before you go ahead and do this,
make sure it's what you actually need.
-Per
On Sun, Apr 4, 2010 at 3:06 PM, Manfred Lotz manfred.l...@arcor.de wrote:
Hi there,
I can ask if something is an fn,
Interesting question. Here's something I whipped up in response:
http://gist.github.com/355456
I intentionally provide only lazy-alter and no lazy-ref-set. The
reason is that lazy-alter can be coded so that all the unwrapping and
rewrapping of delays can be abstracted away from the user-provided
AM, Bob Hutchison hutch-li...@recursive.ca wrote:
On 2010-04-04, at 11:15 AM, Per Vognsen wrote:
Interesting question. Here's something I whipped up in response:
http://gist.github.com/355456
I intentionally provide only lazy-alter and no lazy-ref-set. The
reason is that lazy-alter can
The seq-utils library has a shuffle function that calls out to
java.util.Collections.
If you want to do it yourself, the easiest would be
(defn naive-shuffle [xs]
(let [v (vec xs)]
(- (count v) range lex-permutations rand-elt (map v
This uses the seq-utils and combinatorics libraries
))
item (nth lst index)
remainder (concat (subvec (into [] lst) 0 index)
(subvec (into [] lst) (inc index)))]
(cons item (shuffle remainder)
-Lee
On Apr 4, 2010, at 11:01 PM, Per Vognsen wrote:
The seq-utils library has a shuffle function
Wow, you're right. The partial laziness of his code was foiling my benchmark.
-Per
On Mon, Apr 5, 2010 at 11:05 AM, Mark Engelberg
mark.engelb...@gmail.com wrote:
On my system, knuth-shuffle performs several times faster than Spector's
recursive functional shuffle on smallish lists, and the
version of my code. The code
itself is only three lines; the rest consists of very general purpose
utilities that I find myself using again and again.
http://gist.github.com/356035
-Per
-Lee
On Apr 5, 2010, at 12:11 AM, Per Vognsen wrote:
Wow, you're right. The partial laziness of his code
Unfortunately you can only attach metadata to types that implement the
IObj interface. That excludes native Java types like Integer and
Float:
user= (with-meta 42 {:foo 42})
java.lang.ClassCastException: java.lang.Integer (NO_SOURCE_FILE:0)
user= (with-meta 42.0 {:foo 42})
in the newtype wrapper.
(Clojure's arithmetic tower isn't expressible via protocol-style
single dispatch, so this is vastly simplified, but you get the idea.)
-Per
On Sat, Apr 3, 2010 at 3:18 PM, Per Vognsen per.vogn...@gmail.com wrote:
Unfortunately you can only attach metadata to types that implement
Lazy data flow via sequences is a superior substitute for imperative
control flow. But sometimes unrestrained control flow is convenient.
Here's a proof of concept that provides statically scoped first-class
labels with dynamic extent:
http://gist.github.com/354676
The lexically scoped atom
They are not completely orthogonal. In fact they work well together.
One of the core assumptions in generational garbage collection is that
data in higher generations rarely grow pointers to data in lower
generations. This is often true in imperative programs. But absent
implicit mutation in the
You talk of transactions, persistent in-memory and garbage
collection. Are you sure you understand what persistence means here?
It's a matter of efficient structural sharing of data structures
rather than persistence in the database sense.
-Per
On Sat, Apr 3, 2010 at 9:13 PM, David R. Smith
In most character-buffered REPLs the enter key serves two purposes:
quoting a new line character and submitting input to the REPL. Some
systems like Mathematica require a special key combination like
shift-enter or control-enter to submit input. That is a clean
separation of concerns but it is
/value pairs from other key/value pairs in a map.
It's like Perl's fat comma arrow operator in that sense - syntactically
no different from comma, but stylistically helpful.
On Fri, Apr 2, 2010 at 1:52 AM, Per Vognsen per.vogn...@gmail.com wrote:
It doesn't feel right only if you still think you
Well, while I don't like it much, there are in fact REPLs that work
the way he expects, e.g. SBCL's:
This is SBCL 1.0.24, an implementation of ANSI Common Lisp.
More information about SBCL is available at http://www.sbcl.org/.
SBCL is free software, provided as is, with absolutely no warranty.
, 2010 at 4:02 PM, Meikel Brandmeyer m...@kotka.de wrote:
Hi,
On Apr 1, 10:42 am, Per Vognsen per.vogn...@gmail.com wrote:
Are you serious? It is neither complete nor consistent. How can it be
authoritative?
The list is by definition complete and consistent. Use characters not
in the list
It doesn't feel right only if you still think you are programming in
an Algol-style language where , is a separator token.
I can't imagine this is going to change.
-Per
On Fri, Apr 2, 2010 at 12:37 PM, Frank Siebenlist
frank.siebenl...@gmail.com wrote:
Even though the specs clearly say that
On Fri, Mar 26, 2010 at 12:59 PM, Chas Emerick cemer...@snowtide.com wrote:
On Mar 26, 2010, at 12:59 AM, Per Vognsen wrote:
On Fri, Mar 26, 2010 at 11:50 AM, Chas Emerick cemer...@snowtide.com
wrote:
Because they're common processes that are ideally built once, and then
reused with minor
On Fri, Mar 26, 2010 at 9:55 AM, Chas Emerick cemer...@snowtide.com wrote:
Hi Lee,
Indeed -- from the docs for Math.random():
This method is properly synchronized to allow correct use by more than one
thread. However, if many threads need to generate pseudorandom numbers at a
great rate, it
It would be nice if the compiler handled these things with greater
cleverness. In the mean time, some macros might be in order.
I'd also like to add that clojure.core is not generally an exemplar of style. :)
-Per
On Wed, Mar 24, 2010 at 11:58 PM, Sean Devlin francoisdev...@gmail.com wrote:
On Thu, Mar 25, 2010 at 6:52 PM, WoodHacker ramsa...@comcast.net wrote:
I thank all the people who have sent me solutions to my Conj
problem. Unfortunately, none of them seem to work.
The issue is adding a value to a defined vector - (def savedColors
[black, white])
One solution was given
Are the writes commutative? Since you are using pmap, I presume so. In
that case, you could funnel the writes through an agent serving as a
queue.
-Per
On Thu, Mar 25, 2010 at 9:59 PM, Scott sbuck...@gmail.com wrote:
id prefer best practices if possible
typically, cheating has consequences
Though it might not be the best option here, the Clojure reader is
always ready to serve:
user (type (read-string 123))
java.lang.Integer
user (type (read-string 123123123123123))
java.lang.Long
user (type (read-string 123123123123123123123123123123123123))
java.math.BigInteger
Of course, it
In those hills yonder in the lands of Common Lisp, it's usually
considered good practice to blast the entire read table save for what
you need when you deal with untrusted data. Barring that, a better
option might be a more modular reader: read-number, read-symbol, etc.
-Per
On Fri, Mar 26, 2010
Clojure calls out to Java's java.lang.Math.Random:
This method is properly synchronized to allow correct use by more
than one thread. However, if many threads need to generate
pseudorandom numbers at a great rate, it may reduce contention for
each thread to have its own pseudorandom-number
Look at clojure.contrib.repl-utils/add-break-thread!:
http://richhickey.github.com/clojure-contrib/repl-utils-api.html
-Per
On Fri, Mar 26, 2010 at 10:20 AM, Douglas Philips d...@mac.com wrote:
I've been using clojure 1.1.0 (via MacPorts clojure+rlwrap) and every time I
type Control-C, it
One of the weirdest things coming to the Java world is to witness what
strange things people take for granted should be in the build tool.
All the example features you mention in your article are convenient,
but I don't see why they belong in the build tool. They should be
completely separate
You can put a user.clj file in your class path.
-Per
On Fri, Mar 26, 2010 at 11:42 AM, Douglas Philips d...@mac.com wrote:
On 2010 Mar 25, at 11:29 PM, Per Vognsen wrote:
Look at clojure.contrib.repl-utils/add-break-thread!:
http://richhickey.github.com/clojure-contrib/repl-utils-api.html
On Fri, Mar 26, 2010 at 11:50 AM, Chas Emerick cemer...@snowtide.com wrote:
Because they're common processes that are ideally built once, and then
reused with minor variation. Library reuse is generally considered to be a
good thing in software development, so it strikes me as odd that many
truncated. I can't think of many
cases where a downcast is used *and* the original value is expected to
ever be larger than the target type. If you really need that, then
bit-masking prior to casting seems appropriate.
On Mar 23, 7:41 am, Per Vognsen per.vogn...@gmail.com wrote:
Interesting
On Wed, Mar 24, 2010 at 8:21 PM, Glen Rubin rubing...@gmail.com wrote:
I wrote the following code to produce a lazy sequence of the triangle
numbers. (triangle numbers are the series of numbers: 1, 1+2, 1+2+3,
etc...)
(defn tri-nums []
prduce a lazy sequence of triangle numbers
(let
In addition, right now his Clojure code isn't directly analogous to
his Java code. If he used an array of bytes instead of integers, he
wouldn't need the bit-masking.
Getting this to work revealed a big surprise to me. Java has only
signed integer types: byte, short, int and long. Clojure reads
, Per Vognsen per.vogn...@gmail.com wrote:
In addition, right now his Clojure code isn't directly analogous to
his Java code. If he used an array of bytes instead of integers, he
wouldn't need the bit-masking.
Getting this to work revealed a big surprise to me. Java has only
signed integer types
1 - 100 of 144 matches
Mail list logo