Hi All,
It is amazing what a discussion inserstion sort (still) can kick off :)
My intention was to play with algorithms in clojure and be made aware of the
little
traps one has to look out for coming from scheme for instance. Therefore,
translating the htdp version to clojure
and playing with i
On Thu, Dec 30, 2010 at 12:51 AM, Andreas Kostler
wrote:
> Now the discussion evolved around vectors not being suitable for this task.
> Can someone explain why this holds in this context? In my understanding
> subvec is a constant time operation. So maybe vector is not that unsuitable
> for this
On Wed, Dec 29, 2010 at 11:31 PM, David Nolen wrote:
> The original algorithm is simply wrong for very large inputs, it cannot be
> TCO'ed. Pick a ridiculously large list size and the Scheme/Racket program
> will barf *immediately*.
> David
Have you tried it? I tried this particular algorithm, i
Oh, vectors are indeed bad since vector concatenation is a linear time
operation.
My apologies to Meikel, I simply missed your remark about finger trees.
I guess a version that swaps the values "in place" would be the way to go.
On 30/12/2010, at 7:34 PM, Mark Engelberg wrote:
> On Wed, Dec 29
On Thu, Dec 30, 2010 at 3:24 AM, Andreas Kostler
wrote:
> Oh, vectors are indeed bad since vector concatenation is a linear time
> operation.
> My apologies to Meikel, I simply missed your remark about finger trees.
> I guess a version that swaps the values "in place" would be the way to go.
Whe
On 30/12/2010, at 8:40 PM, Mark Engelberg wrote:
> On Thu, Dec 30, 2010 at 3:24 AM, Andreas Kostler
> wrote:
>> Oh, vectors are indeed bad since vector concatenation is a linear time
>> operation.
>> My apologies to Meikel, I simply missed your remark about finger trees.
>> I guess a version th
On Wed, Dec 29, 2010 at 9:31 PM, Mark Engelberg
wrote:
> So here's the answer to the puzzle I posed earlier
I just realized that the "append" function in my code was unnecessary,
since into serves the same purpose. Thus my solution could be
rewritten as:
(defn insert [n alon]
(loop [alon
On Thu, Dec 30, 2010 at 3:49 AM, Andreas Kostler
wrote:
> Isn't that the problem though? This will make the best case inefficient since
> the work performed by into is proportional to the length of v2 (or v1 if you
> swap them around).
> Therefore, even thought the list is sorted you still need t
On 30/12/2010, at 8:54 PM, Mark Engelberg wrote:
> On Thu, Dec 30, 2010 at 3:49 AM, Andreas Kostler
> wrote:
>> Isn't that the problem though? This will make the best case inefficient since
>> the work performed by into is proportional to the length of v2 (or v1 if you
>> swap them around).
>> T
On Thu, Dec 30, 2010 at 4:01 AM, Andreas Kostler
wrote:
> Oh of course. I apologise. Mark do you mind to lay out how you perform your
> benchmarks.
> On my system (insertion-sort (into [] (range 1))) runs for an
> unacceptable amount of time (talking ~10s)
> That seems to be quite long for sor
On Thu, Dec 30, 2010 at 4:01 AM, Andreas Kostler
wrote:
> With the initial implementation, using binary search to find the insertion
> point should still result in a speed up, right?
Sure, that should help, although it doesn't change the overall
quadratic bound unless you can also do the insertio
Gist updated to use watchers for table state reporting, instead of coupling
the reporting with the transaction.
Also, as cgrand pointed to me, note that this implementation using the STM
is somehow related to the "Monitor solution" described in :
http://en.wikipedia.org/wiki/Dining_philosophers_pr
Hello everybody,
An object of class created using defrecord does not implement IFn .. while
it behaves very similar to map otherwise .. Is this way by design? can it be
made to behave like a hash-map without any performance penalty in terms of
behaving like a function?
Thanks,
Sunil.
--
You rec
thanks David and Ben for you responses..
Sunil.
On Wed, Dec 29, 2010 at 9:47 PM, David Nolen wrote:
> On Wed, Dec 29, 2010 at 10:48 AM, B Smith-Mannschott <
> bsmith.o...@gmail.com> wrote:
>
>> - (defn f [[^double x]] x)
>> The compiler (1.3) does not complain about this, though I can't say
>> w
On Thu, Dec 30, 2010 at 5:34 AM, Mark Engelberg wrote:
> On Wed, Dec 29, 2010 at 11:31 PM, David Nolen
> wrote:
> > The original algorithm is simply wrong for very large inputs, it cannot
> be
> > TCO'ed. Pick a ridiculously large list size and the Scheme/Racket program
> > will barf *immediately
@Mark: applause. A nice pedagogical exercise, and your step-by-step
approach --- so reminiscent of HTDP --- was very effective.
Your final solution reminds me of an undergraduate data structures and
algorithms final I took (too) many years ago on which, after weeks of
doing recursive sorts and tr
I don't get any errors when I run your code. This is the output:
1 1
1 1
1 1
1 1
1 1
1 1 1 1 1
1 1 1 1 1
Are you sure you are using the latest Clojure 1.2 version and not an
early beta, etc.?
Process finished with exit code 0
On Dec 29, 11:25 pm, Jarl Haggerty wrote:
> What is wro
Yes, that's intentional – implementing IFn is (as you can see) orthogonal to
implementing IPersistentMap, IPersistentCollection, etc.
Of course, keyword access of record slots is most idiomatic, e.g. (:my-slot
some-record)
If you'd like to pass around a function that accesses a record, there's
I'm doing something kind of tricky...I'm running a REPL in my Java
Swing application. I do something like:
public class MyConsoleClass extends OurEmbeddedInterpreterClass {
// ...
// inner class
private class ReplRunner extends Thread {
public void run() {
Namespace MYNS = Namesp
>From the Qi mailing list:
http://groups.google.com/group/qilang/browse_thread/thread/e4a2f534fad5032a
"I contend that this kind of problem cannot be solved (efficiently) in any
pure functional programming language. You may disagree"
:D
David
--
You received this message because you are subsc
On Thu, 30 Dec 2010 12:03:14 -0500
David Nolen wrote:
> From the Qi mailing list:
>
> http://groups.google.com/group/qilang/browse_thread/thread/e4a2f534fad5032a
>
> "I contend that this kind of problem cannot be solved (efficiently) in any
> pure functional programming language. You may disagr
I'm using the maven plugin so I think I'm using the lastest 1.2, and
I've tried every 1.3 version, but I just got a hold of my laptop, and
I am having no problems on there.
I was having several other problems too(I started another discussion
complaining about a whittled down version of this progra
Hello,
I'm wring a service that polls RSS feeds (using feedme). And I'd like to act
only on the new entries in each feed.
So far I have something like:
(defn get-new-entries [seen]
(let [seen? (complement seen)]
(filter #(seen? (:id %)) (get-entries
(defn poll [sleep-time]
(loop [se
10 of us from Sonian are going to converge on Boston the week of Jan
9. It's always awesome to meet other Clojure hackers. I propose we
meet up somewhere central(ish) Jan 11 @ 7-9pm-ish. We have room at
our company headquarters in Dedham but that might be a hike for some
people. Any other places
On Thu, Dec 30, 2010 at 6:40 AM, Mark Engelberg
wrote:
> As for finger trees, I have not found them to be useful. Although
> they have good theoretical bounds, they are very slow in practice.
> For example, if you try splitting, concatenating, and traversing lists
> of, say, 10 elements, thes
Java's LinkedHashMap provides the hook necessary to implement a simple LRU
cache. Here's some code where we use LHM in as an LRU cache, in service of
providing a variation on the memoization concept:
https://gist.github.com/747395
Whether what's there is sufficient for your needs is another st
I've been working on a simple Clojure library for bounded caching and
memoization. It's not quite ready for prime-time, but the simple case
that you need is usable.
I'll throw it up on github when I get home tonight and post the URL
here.
On Dec 30, 1:35 pm, Miki wrote:
> Hello,
>
> I'm wring a
On Thu, Dec 30, 2010 at 11:01 AM, Ken Wesson wrote:
> I hope that didn't include a naive benchmarking of
> take/drop/concat/seq. Because three of those are lazy, you need to
> wrap the output of an algorithm using them in a (doall ...) and then
> in your timing function to get an accurate read on
Am 30.12.2010 07:54, schrieb Jarl Haggerty:
This code,
(defprotocol Matrix
(matrix-get [this c r]))
(deftype Matrix2D [data height width]
Matrix
(matrix-get [this r c] 1))
Gives me this error
Exception in thread "main" java.lang.IllegalArgumentException: Can't
define method not in in
You might try `(binding [*compile-files* true] ...)` around whatever code
creates the namespace. Can't promise that will work.
This still won't let you save definitions entered at the REPL. Once they're
compiled and loaded into the JVM, the bytecode is no longer accessible.
-Stuart Sierra
cloj
You can make it implement IFn easily enough:
(defrecord Foo [a b c]
clojure.lang.IFn
(invoke [this key] (get this key)))
It has been debated whether or not this is a good idea, design-wise, but it
should not be a performance penalty.
-Stuart Sierra
clojure.com
--
You received this messag
I've been playing with making a macro to encapsulate Stuart's post, like
this:
(defmacro defrecord-ifn [name & args]
`(defrecord ~name ~...@args
clojure.lang.IFn
(invoke [this key] (get this key
(defrecord-ifn Foo [a b c])
(def foo (Foo. "A" "B" "C"))
(prn (map foo [:a :c])) => ("
Hi!
You would be more than welcome at the Boston Coding Dojo (http://
www.meetup.com/boston-coding-dojo/). We meet every other Thursday at
First Church in Boston, in Boston's Back Bay on Marlborough St. In
January, we are meeting on 1/6 and 1/20, so nothing on the week of
1/9, I'm afraid. What
Alex Baranosky writes:
> I've been playing with making a macro to encapsulate Stuart's post, like this:
>
> (defmacro defrecord-ifn [name & args]
> `(defrecord ~name ~...@args
> clojure.lang.IFn
> (invoke [this key] (get this key
>
> (defrecord-ifn Foo [a b c])
>
> (def foo (Foo. "A
Worked like a charm. Thanks Alex.
--
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
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe f
Technically, there's no possibility of variable capture, but you
should use gensyms:
(defmacro defrecord-ifn [name & args]
`(defrecord ~name ~...@args
clojure.lang.IFn
(invoke [this# key#] (get this# key#
Thanks,
Alyssa
On Dec 30, 9:29 pm, Alex Baranosky
wrote:
> I've been playi
I'll also be at the Boston Coding Dojo sessions on the 6th and 20th, and
would be willing to split the room price if you all wanted to meet during
the week of the 9th-16th.
Alex
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, s
Well, I previously commented that Advocacy is Volunteering
and then I managed to advocate moving clojure to literate
form. Since I'm studying the details of the inner workings
of Clojure this seemed to be the right time to experiment
with a literate form.
I have put together the beginnings of a
Argh! Six minutes! :P
On Dec 30, 9:42 pm, Alyssa Kwan wrote:
> Technically, there's no possibility of variable capture, but you
> should use gensyms:
>
> (defmacro defrecord-ifn [name & args]
> `(defrecord ~name ~...@args
> clojure.lang.IFn
> (invoke [this# key#] (get this# key#
>
On Thu, Dec 30, 2010 at 7:41 PM, André Thieme
wrote:
> Do you observe this in a fresh Clojure?
> I ran into something similar, but with definterface.
> I had a definterface form and later added new functions to it, which I
> could not implement before restarting the JVM, as the interface has
> alr
I didn't think it was a problem with the clojure version because I was
using the maven plugin and tried several versions, but when I got to
my laptop the next day and ran the exact same programs and everything
worked just fine. At this point my plan is to delete my maven
repositories and if that d
I have this function
(defn floor
^int [^float x] x)
and (floor 1.5) returns 1.5 which confuses me as to how type hints
work, I was expecting the result to be truncated or for the program to
spit out some exception about expecting an int and getting a float.
--
You received this message becaus
thanks everybody for the responses .. with macros around ... you just have
to wish for it to get it .. but we need to be careful what we wish for :)
Sunil.
On Fri, Dec 31, 2010 at 8:18 AM, Alyssa Kwan wrote:
> Argh! Six minutes! :P
>
> On Dec 30, 9:42 pm, Alyssa Kwan wrote:
> > Technically, ther
I don't think type hints lead to auto casting .. May be somebody else can
throw more light on it. And it is this way by design.
Sunil.
On Fri, Dec 31, 2010 at 9:35 AM, Jarl Haggerty wrote:
> I have this function
>
> (defn floor
> ^int [^float x] x)
>
> and (floor 1.5) returns 1.5 which confuses
The first release of vsClojure is now available in the Visual Studio
Gallery. You can download it using the extension manager in Visual
Studio 2010 and searching for "vsClojure". There should be no manual
setup and the extension will work with the Visual Studio 2010 Shell.
This release focused o
Am 31.12.2010 03:29, schrieb Alex Baranosky:
I've been playing with making a macro to encapsulate Stuart's post, like
this:
(defmacro defrecord-ifn [name & args]
`(defrecord ~name ~...@args
clojure.lang.IFn
(invoke [this key] (get this key
(defrecord-ifn Foo [a b c])
(def foo
I think I asked the wrong question, not only that but I guess I
answered the question I asked, what I want to know is what exactly is
a type hint. I think I've failed to understand exactly what a type
hint is, I assumed to give a hint was to statically type something but
that doesn't seem to be wh
I spent a long time debugging some Clojure code yesterday. The
essence of it looked similar to this:
(defn items []
(mapcat expensive-function (range 0 4000 100)))
. . . (take 5 (items)) . . .
expensive-function is a function that issues an HTTP GET to retrieve a
vector of data. Since range'
On Fri, Dec 31, 2010 at 12:25 AM, ehanneken wrote:
> I spent a long time debugging some Clojure code yesterday. The
> essence of it looked similar to this:
>
> (defn items []
> (mapcat expensive-function (range 0 4000 100)))
>
> . . . (take 5 (items)) . . .
>
> expensive-function is a function t
On Thu, Dec 30, 2010 at 4:19 PM, Mark Engelberg
wrote:
> On Thu, Dec 30, 2010 at 11:01 AM, Ken Wesson wrote:
>> I hope that didn't include a naive benchmarking of
>> take/drop/concat/seq. Because three of those are lazy, you need to
>> wrap the output of an algorithm using them in a (doall ...) a
On Fri, Dec 31, 2010 at 12:25 AM, ehanneken wrote:
> I spent a long time debugging some Clojure code yesterday. The
> essence of it looked similar to this:
>
> (defn items []
> (mapcat expensive-function (range 0 4000 100)))
>
> . . . (take 5 (items)) . . .
>
> expensive-function is a functio
On Thu, Dec 30, 2010 at 9:50 PM, Ken Wesson wrote:
> Are these searches, which should be log n? Or full (e.g. in-order) traversals?
I'm talking about full traversals. Finger trees are sequences, and
after building the sequence, splitting, concatenating, or whatever, I
find I eventually need to v
I find this exciting! Thanks for starting this.
--
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
Note that posts from new members are moderated - please be patient with your
first post.
To
Hello.
Thank you for response, Stuart Sierra.
I'm looking forward to complete new build configuration work and I'll
use little build script for a while :-)
Thank you.
2010/12/30, Stuart Sierra :
> Currently, clojure-contrib's pom.xml is configured to build source-only JARs
> for all libraries ex
Hello everybody,
I am looking for parallel programming libraries in Clojure. I found JavaMPI
but its website does not seem to be updated since 2003. I would love to hear
anything about where Java stands in distributed parallel computing. I get
the feeling that the Parallel colt libraries are just
55 matches
Mail list logo