Hi,
I ran into a similar problem myself recently.
I'm not sure if this is the "best" approach but I found that if you
(use 'clojure.contrib.math)
instead of require, it should work.
Regards,
Mark.
On Oct 7, 2:50 pm, vishy wrote:
> Hi,
>
> I am on windows machine. I am using these comma
Hi,
I think http://sites.google.com/site/piotrwendykier/software/
parallelcolt">Parallel Colt has picked up where Colt left off.
It's a very full featured library and forms the basis of the Clojure
stats package http://incanter.org/>Incanter.
Personally, I've used the sparse vector classes in Pa
Hi,
On Sep 10, 3:52 pm, MarkSwanson wrote:
> Just for fun I actually tried this:
>
> Clojure=> (time (lpf6b 1234567890123456789012345678901234567890))
> The prime factorization of 1234567890123456789012345678901234567890
> is :5964848081
> "Elapsed time: 5519.278432 msecs"
>
> I can't confirm th
Hi,
The problem here is that filter is expecting a predicate and you are
passing a set.
When used as a function like so
user=> (#{1 2 3} 2)
2
user=> (#{1 2 3} 5)
nil
the set returns the argument if it is in the set and nil otherwise.
The problem you are observing is because the i
Hi again,
I misinterpreted the question first time around but here's another
attempt.
Given f, a0 and v, let b0 = (reduce f a0 v) = f( f( f( f(a0, v[1]), v
[2]), ...), v[n])
Now define the function g to ignore its second argument and return its
first. That is, g(x, y) = x.
Then (reduce g b0 (r
Hi,
Maybe I'm missing something but doesn't + fit the bill (or any
symmetric function)?
(== (reduce + 3 [1 2 3]) (reduce + 3 [3 2 1])) ;; => true
In this case f = g = + and a0 = b0 for any choice of a0 and v.
Regards,
Mark.
On Jun 4, 3:23 pm, CuppoJava wrote:
> Hey guys,
> I'm really stuck
> What's wrong with this:
>
> user=> (ns test (:use [clojure.contrib.math :exclude (lcm)]))
> nil
> test=> (sqrt 2)
> 1.4142135623730951
> test=> (lcm 3 6)
> java.lang.Exception: Unable to resolve symbol: lcm in this context
> (NO_SOURCE_FILE:3)
> test=> (defn lcm [a b] 1)
> #'test/lcm
> test=> (l
I should clarify: I asked my original question not because I wanted to
actually write an optimiser but rather I was interested in how far the
idea of code-modifying code could be pushed in a Lisp-like language
such as Clojure. The example I gave was just the simplest thing I
could think of that de
f Lisp". In it you'll get an idea of why eval is
> so powerful, and why macros are exactly the tool for the job you're
> thinking of.
>
> http://lib.store.yahoo.net/lib/paulgraham/jmc.ps
>
> I'll let someone else answer "how" with respect to Clojure.
Hi,
I'm quite new to macros so forgive me if this is a naïve question, but
is it possible to write macros that are applied to an entire Clojure
program?
The reason I ask is that, in other threads in this group, some simple
transformations to improve efficiency of Clojure programs were
mentioned.
Hi Laurent,
On May 10, 5:15 am, Laurent PETIT wrote:
> So if you want to call it with a no-arg "predicate", you must adapt it :
>
> (repeatedly-while (fn [ _ ] (no-arg-pred)) f)
> instead of
> (repeatedly-while no-arg-pred f)
I think that this is too convoluted a calling pattern. For my
purpose
Hi Meikel,
On May 10, 3:05 am, Meikel Brandmeyer wrote:
> There is a mistake in this function: pred should be (pred)
> as well as f should be (f).
> Furthermore I would call it repeatedly-while.
>
> (defn repeatedly-while
> [pref f]
> (lazy-seq
> (when (pred)
> (cons (f) (cons
Hi Laurent,
Thanks for the feedback. I'm still a bit stuck though since neither my
proposal nor yours work for the type of application I had in mind.
Here's a complete program which highlights the problems:
; Begin lazyread.clj
(import '(java.io FileReader BufferedReader PrintWriter))
Hi,
This `lazy-seq` over a `when` and `cons` idiom seems fairly common. Is
there any reason there is not a function for it? For example:
(defn cons-while
"Lazily creates a sequence by repeatedly calling f until pred is
false"
[pred f]
(lazy-seq
(when pred
(cons f (cons-while pred
Hi,
This is probably digressing a little from the original question but I
was wondering if using namespaces here is a reasonable thing to do
when designing ADTs.
> SICP tells us that we should be defining accessor functions
> immediately when we create a new data type.
>
> (defn make-fraction [n
rtant, I've also had very good experiences
with Git and GitHub after having used CVS and subversion for many
years. I think the social infrastructure they created at GitHub adds a
lot of value to Git as a SCM tool.
I also agree with several of the other posters about a 1.0 release to
coincide
Hi,
I'm not sure if this is relevant to this discussion but, as a
newcomer, I was puzzled by the organisation of the clojure-contrib
source.
Why, for example, are ClojureCLR and clojurescript at the top of the
trunk? Shouldn't these be in separate projects?
Regards,
Mark.
--
http://mark.reid.n
Hi Laurent,
Thanks for the feedback regarding namespaces. That's exactly the sort
of thing I wasn't sure I was doing correctly.
I currently don't use an IDE that automatically compiles files so
wasn't aware of that problem. I prefer the solution that defines a
main method. My only question now i
Hi,
In the interests of learning Clojure I thought it would be fun to port
the Minilight renderer to Clojure and write about the steps along the
way. If you're interested you can have a look at my first post here:
http://mark.reid.name/sap/minilight-clojure-vectors.html
I've not programmed i
Just a quick note to say that I've added notes about the TextMate
Clojure bundle to my tutorial. I've also put a concise version of the
guide up on GitHub:
http://github.com/mreid/clojure-framework/tree/master
Regards,
Mark.
--
http://mark.reid.name
--~--~-~--~~~
Hi Sean,
On Mar 30, 11:59 pm, Sean wrote:
> As an OSX nerd, my main problem is getting an editor up and running. Maybe
> you could add
> a section on setting up an editor?
That's a good point. I use TextMate with the Clojure bundle. I'll add
a section with the appropriate links.
Regards,
Hi,
I've just written a blog post describing how I set up Clojure on my
Mac:
http://mark.reid.name/sap/setting-up-clojure.html
My main aims were to make it easy to configure the classpath for
various projects while still having a single Clojure command I can run
from anywhere to open a inte
On Mar 26, 1:10 am, Stuart Sierra wrote:
> Hi Mark,
> You'll need to work at a lower level using cons and lazy-seq.
> Something like this (untested):
>
> (defn bio-iterator-seq [iterator]
> (lazy-seq
> (when (.hasNextiterator)
> (cons (.nextSequenceiterator) (bio-iterator-seqiterator)
Hi,
I am very new to Clojure and I am trying to turn a SequenceIterator
from the BioJava library into a lazy Clojure seq.
The interface has two methods `hasNext()` and `nextSequence()` which
have very similar semantics to `hasNext()` and `next()` for the
standard Java Iterator interface.
I have
24 matches
Mail list logo