Re: Project Euler problem 28

2011-02-15 Thread Ken Wesson
On Tue, Feb 15, 2011 at 1:13 AM, Andreas Kostler andreas.koestler.le...@gmail.com wrote: Hi all, Does anyone wanna have a look at my solution for Project Euler Problem 28? (defn diagonal-sum [n-max]        (+ 1 (reduce +                (map (fn[n]                      (reduce + (map #(- (*

Re: Project Euler problem 28

2011-02-15 Thread Ken Wesson
On Tue, Feb 15, 2011 at 2:59 AM, Ken Wesson kwess...@gmail.com did NOT write: (defn diagonal-sum-4 [n-max]  (let [cores (.availableProcessors (Runtime/getRuntime))        step (* 2 cores)]    (inc      (reduce +        (map get          (doall            (map #(future (diagonal-sum-4a

Re: Realtime Clojure program

2011-02-15 Thread Marko Topolnik
4. Unless you're using 1.3 or later, put the innermost loop in a single function and try to avoid calling sub-functions, except for operators like + that can get inlined. This is interesting, can you be more specific about this point -- what exactly do we need to avoid? Calls that force the

Stream not closed when reading clojure-version

2011-02-15 Thread Olek
Hi, In 1.2 (line core.clj:5466) and 1.3 (line core.clj:5911) versions of Clojure, opened stream for reading clojure-version is not closed what causes problems in JEE env. Cheers, Olek -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this

Finding info about a function

2011-02-15 Thread Saul Hazledine
Hello, Apologies if this there is an obvious documented answer to this question. If I write a function: (defn example Get info about a function [f] (println Arity is (arity f)) (if (is-anonymous? f) (println Function is anonymous))) I believe I can implement

Re: Finding info about a function

2011-02-15 Thread Saul Hazledine
Very sorry. I should have searched before I wrote. http://groups.google.com/group/clojure/msg/fb9930ba2a25d2dd On Feb 15, 11:00 am, Saul Hazledine shaz...@gmail.com wrote: Hello,   Apologies if this there is an obvious documented answer to this question. If I write a function:    (defn

Re: Realtime Clojure program

2011-02-15 Thread Ken Wesson
On Tue, Feb 15, 2011 at 3:52 AM, Marko Topolnik marko.topol...@gmail.com wrote: 4. Unless you're using 1.3 or later, put the innermost loop in a single function and try to avoid calling sub-functions, except for operators like + that can get inlined. This is interesting, can you be more

(identical? foo foo) evaluates to true

2011-02-15 Thread C. Arel
Hi all, I am watching the data structure videos and there it evaluates to false. Does this mean that only one object is created now? (Clojure update on String objects?) Kind Regards, Can -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this

Better Workflow with App Engine?

2011-02-15 Thread Thorsten Wilms
Hi! I managed to get to a Hello world level using appengine-magic, plus an Emacs Swank/Slime setup. While I'm pretty sure I won't look back to Python regarding the language itself, I already miss the speed and simplicity of just saving, switching to a browser, reloading and seeing results.

Re: [ANN] emacs-nexus (Emacs client for Nexus Maven repository servers)

2011-02-15 Thread Don Jackson
On Feb 14, 2011, at 8:21 PM, Michael Ossareh wrote: Along with anything that is listed in :repositories in your project.clj ? +1 -- 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

Re: (identical? foo foo) evaluates to true

2011-02-15 Thread B Smith-Mannschott
On Tue, Feb 15, 2011 at 11:46, C. Arel java10c...@gmail.com wrote: Hi all, I am watching the data structure videos and there it evaluates to false. Does this mean that only one object is created now? (Clojure update on String objects?) I think this is a distinction without a difference since

Re: Realtime Clojure program

2011-02-15 Thread Marko Topolnik
Is really any call that isn't inlined that expensive? Yes, unfortunately. You saw the numbers. :) If you mean the earlier thread about the Euler problem, I see that the diagonal-sum-3 drastically outperforms diagonal-sum-2 by eliminating HOFs and working with unchecked primitive ops.

Re: (identical? foo foo) evaluates to true

2011-02-15 Thread Armando Blancas
For compilation and evaluation, yes. But not strings created at rumtime like: (def foo (str \f \o \o)) http://groups.google.com/group/clojure/browse_thread/thread/e43af17a0424b1cd On Feb 15, 2:46 am, C. Arel java10c...@gmail.com wrote: Hi all, I am watching the data structure videos and there

Re: Project Euler problem 28

2011-02-15 Thread Benny Tsai
My version follows the same algorithm (and so runs in the same amount of time), just arranged differently: (defn corner-nums [n] (for [i (range 4)] (- (* n n) (* i (dec n) (defn sum-all-corner-nums [max-n] (let [ns (range 3 (inc max-n) 2) all-corner-nums (mapcat corner-nums

Clojure CLR running exe

2011-02-15 Thread pkarvou
Hello everyone. I am using clojure-clr. I have compiled a simple hello world console application. However when I try to run the app I get: Unhandled Exception: System.TypeInitializationException: The type initializer fo r 'HelloWorld' threw an exception. --- System.IO.FileNotFoundException:

Functional program design concepts

2011-02-15 Thread MS
Hi, I just (mostly) finished reading the Programming Clojure book and while it gave a great overview of the language, I'm still at a loss for how to design programs. Maybe my mind has been polluted by OO concepts. For example, I'm trying to figure out how to do polymorphism in FP. Specifically,

Re: Project Euler problem 28

2011-02-15 Thread Marek Stępniowski
On Feb 14, 11:13 pm, Andreas Kostler andreas.koestler.le...@gmail.com wrote: Does anyone wanna have a look at my solution for Project Euler Problem 28? (defn diagonal-sum [n-max] (+ 1 (reduce + (map (fn[n] (reduce + (map #(- (* n n) (* % (- n

Re: Functional program design concepts

2011-02-15 Thread Saul Hazledine
On Feb 15, 9:04 pm, MS 5lvqbw...@sneakemail.com wrote: Hi, I just (mostly) finished reading the Programming Clojure book and while it gave a great overview of the language, I'm still at a loss for how to design programs. You'll get better answers later but here is my take on it. Maybe my

Re: Functional program design concepts

2011-02-15 Thread Raoul Duke
On Tue, Feb 15, 2011 at 1:07 PM, Saul Hazledine shaz...@gmail.com wrote: On Feb 15, 9:04 pm, MS 5lvqbw...@sneakemail.com wrote: Maybe my mind has been polluted by OO concepts. Maybe a combination of OO and static typing. for a functional take:

Re: Functional program design concepts

2011-02-15 Thread Raoul Duke
On Tue, Feb 15, 2011 at 1:12 PM, Raoul Duke rao...@gmail.com wrote: for a functional take: http://ac.aua.am/trietsch/web/Critical%20Path_Holistic%20Approach_final.pdf aw, crap. http://www.htdp.org/ is the link i really wanted to copy-paste. (i think the one i did paste is good reading if

Re: Functional program design concepts

2011-02-15 Thread Sean Corfield
On Tue, Feb 15, 2011 at 12:04 PM, MS 5lvqbw...@sneakemail.com wrote: Maybe my mind has been polluted by OO concepts. I was having this discussion on another list and it seems that the less OO folks know, the easier they find FP... so you may well be right :) For example, I'm trying to figure

Re: Functional program design concepts

2011-02-15 Thread Raoul Duke
On Tue, Feb 15, 2011 at 1:55 PM, Sean Corfield seancorfi...@gmail.com wrote: On Tue, Feb 15, 2011 at 12:04 PM, MS 5lvqbw...@sneakemail.com wrote: For example, I'm trying to figure out how to do polymorphism in FP. Why? because polymorphism makes code suck less, if done well. see typeclasses in

generic (works for any seq) levenshtein distance

2011-02-15 Thread Laurent PETIT
Hi, Was playing with levenshtein (argh, where do I place the h -sorry mister levenshtein-), and thougth it could be interesting to share my current result here, to get some feedback. The following version works with any seq-able (not only Strings), but hardwires function = for equality testing

Re: Functional program design concepts

2011-02-15 Thread MS
Thanks, I have HTDP on my computer but after the first chapter I got distracted and have been meaning to get to itI'll look for my answers there! :) On Feb 15, 1:13 pm, Raoul Duke rao...@gmail.com wrote: On Tue, Feb 15, 2011 at 1:12 PM, Raoul Duke rao...@gmail.com wrote: for a functional

Re: Functional program design concepts

2011-02-15 Thread MS
Cool, thanks for the tips. More inline below: For example, I'm trying to figure out how to do polymorphism in FP. Why? Because I'm not sure how else to use (for example) a graph library and still have it look like a circuit, rather than a graph. Specifically, an electrical circuit is a

Re: Functional program design concepts

2011-02-15 Thread Sean Corfield
On Tue, Feb 15, 2011 at 1:58 PM, Raoul Duke rao...@gmail.com wrote: because polymorphism makes code suck less, if done well. If polymorphism is the appropriate solution, yes. But for a lot of people steeped in OO thinking, polymorphism is a bit of a hammer for every problem that looks like a

Re: Functional program design concepts

2011-02-15 Thread Sean Corfield
On Tue, Feb 15, 2011 at 2:53 PM, MS 5lvqbw...@sneakemail.com wrote: Because I'm not sure how else to use (for example) a graph library and still have it look like a circuit, rather than a graph. Almost any such graph library is going to be a bunch of functions that operate on a data structure.

Re: Functional program design concepts

2011-02-15 Thread Raoul Duke
On Tue, Feb 15, 2011 at 3:03 PM, Sean Corfield seancorfi...@gmail.com wrote: If polymorphism is the appropriate solution, yes. But for a lot of people steeped in OO thinking, polymorphism is a bit of a hammer for every problem that looks like a nail. you might also sorta be saying that there

Re: (identical? foo foo) evaluates to true

2011-02-15 Thread Stuart Sierra
Since about 1.1, I think, the Clojure compiler calls String.intern() on String literals. So yes, they are the same object. -Stuart Sierra -- 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

Re: Stream not closed when reading clojure-version

2011-02-15 Thread Stuart Sierra
This is a bug. I created CLJ-739 for it. http://dev.clojure.org/jira/browse/CLJ-739 Thanks for the report, Olek! -Stuart Sierra clojure.com -- 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

Re: generic (works for any seq) levenshtein distance

2011-02-15 Thread Stuart Sierra
Cool! That's a very compact implementation. Could the same technique be adapted to give you the longest common substring? e.g. (foo fooba baab) = ba Or better yet, the length of the longest common substring and the starting indices of each common substring of that length, e.g. (foo baaboobaa

Re: Functional program design concepts

2011-02-15 Thread James Reeves
On 15 February 2011 22:53, MS 5lvqbw...@sneakemail.com wrote: So an electrical circuit is a data structure containing vertices and edges and describing how they are connected. Then you'll have some functions that operate on that data structure. So... how do I use someone else's implementation

Re: Functional program design concepts

2011-02-15 Thread Sean Corfield
On Tue, Feb 15, 2011 at 3:11 PM, Raoul Duke rao...@gmail.com wrote: you might also sorta be saying that there are lots of different kinds of polymorphism in programming, and that we need to know when to/not use any given form of it, which i'd agree with :-) We're probably in violent agreement,

Re: Functional program design concepts

2011-02-15 Thread Sean Corfield
There are two very interesting threads over on the Scala mailing lists at the moment that have some bearing on this thread - and I think illustrate the two very different ways of thinking about types and type systems: Benefits of static typing:

Re: generic (works for any seq) levenshtein distance

2011-02-15 Thread Andreas Kostler
Laurent, I've been studying your implementation for a while now and can't really fully grasp it. Can you elaborate a bit on the algorithm? Cheers Andreas On 16/02/2011, at 9:45 AM, Stuart Sierra wrote: Cool! That's a very compact implementation. Could the same technique be adapted to give

Re: Realtime Clojure program

2011-02-15 Thread Ken Wesson
On Tue, Feb 15, 2011 at 10:02 AM, Marko Topolnik marko.topol...@gmail.com wrote: Is really any call that isn't inlined that expensive? Yes, unfortunately. You saw the numbers. :) If you mean the earlier thread about the Euler problem, I see that the diagonal-sum-3 drastically outperforms

Re: generic (works for any seq) levenshtein distance

2011-02-15 Thread Base
I'm with Andreas, and would love some help dissecting this a bit further. On Feb 15, 6:53 pm, Andreas Kostler andreas.koestler.le...@gmail.com wrote: Laurent, I've been studying your implementation for a while now and can't really fully grasp it. Can you elaborate a bit on the algorithm?

[ANN] Clojure REPL for Android

2011-02-15 Thread Daniel Solano Gómez
Hello, all, Over the past week and a half or so, I have been working on getting Clojure working fully on Android. At last, I have released a Clojure REPL that is now available on the Android Market. For now it is primarily a proof-of-concept, so it does not include much in the way of features

Trouble with type hints

2011-02-15 Thread Nick
I'm having a bit of trouble getting type hinting to work. I've got these equal sized seqs that I'm mapping into a function. I'm running the function twice in a row in an inner loop that is seriously dragging down performance. (let [ newv1 (time (doall (map (fn [v u I] (+ ^java.lang.Double v

Re: generic (works for any seq) levenshtein distance

2011-02-15 Thread Brenton
Laurent, I have been doing some work on a diff library for Clojure sequences (I need to get back to it and finish it up). http://github.com/brentonashworth/clj-diff The main goal of this library is to compute sequential diffs quickly. Whenever I see someone doing something similar I like to

defrecord/deftype ...

2011-02-15 Thread Sunil S Nandihalli
Just thinking out loud... After listening to classes are a premature optimization lecture on infoQ .. I was just wondering if the only purpose of defrecord is spacespeed efficiency ... and could just use maps .. ofcourse .. I won't be able to use the protocols ..defrecord may improve the

Re: defrecord/deftype ...

2011-02-15 Thread Michael Ossareh
Am I missing something? types. -- 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

Re: generic (works for any seq) levenshtein distance

2011-02-15 Thread Tassilo Horn
Laurent PETIT laurent.pe...@gmail.com writes: Hi Laurent, Was playing with levenshtein (argh, where do I place the h -sorry mister levenshtein-), and thougth it could be interesting to share my current result here, to get some feedback. Looks really concise. Nice! The following version