On Sat, Sep 18, 2010 at 10:40 AM, Sean Corfield wrote:
> Since memoize seems to be 'forever' and caching in general smells of
> mutable state, I wondered how folks are tackling this sort of thing in
> Clojure? Are you simply dropping down to Java libraries and being
> 'non-functional' or is there
On Fri, Sep 17, 2010 at 10:49 AM, Nicolas Oury wrote:
> I was just saying that not returning something that is a pair, for
> example nil, is good enough.
The implement is equivalent, most languages I know that has unfold use
your approach(i.e. return Maybe or None).
This link use the unfold p f
On Fri, Sep 10, 2010 at 3:06 PM, Isaac Gouy wrote:
> So what are we to do when there's a problem that has "no acceptable
> elegant Haskell form"?
Depending on the intend, for you benchmark program, write something
like what it is now.
For real life cases, call an exnternal library, use another la
On Fri, Sep 10, 2010 at 2:04 PM, Isaac Gouy wrote:
> It's starting to look like actually there was a point you wanted to
> make ;-)
You mean the 'no chice' part ? yes.
You mean the why not Data.Hashtable comment ? I don't think so.
>
> If you change the requirement to something else you'd simpl
On Fri, Sep 10, 2010 at 11:13 AM, Isaac Gouy wrote:
> Clearly, they did choose "to write all that code" "in order to get a
> much faster program" - I can't tell you if Andy had noticed the
> benchmark was about "Hashtable update and k-nucleotide strings" or
> whether he knew about Data.HashTable.
On Fri, Sep 10, 2010 at 8:49 AM, Isaac Gouy wrote:
>> Huh ? point ? it was just a casual comment, no point was intended. And
>> I have read some comments by Don that what is in the shoutout is way
>> faster than Data.HashTable
>
>
> If you knew there was another option why write "I doubt there is
On Fri, Sep 10, 2010 at 4:47 AM, John Cromartie wrote:
> #!/usr/local/bin/clj
>
> (println "Content-type: text/plain\n")
> (println "Hello, World!")
> ^D
>
> Is that simple enough?
>
That was my thought too, java/clojure console app should not be more
complex than python etc. The issue is the star
On Thu, Sep 9, 2010 at 10:04 PM, Isaac Gouy wrote:
> Is there any point speculating about this as outsiders?
>
> It was available - Data.HashTable seems to be copyright 2003.
>
> http://ogi.altocumulus.org/~hallgren/Programatica/tools/pfe.cgi?Data.HashTable
Huh ? point ? it was just a casual comm
On Thu, Sep 9, 2010 at 7:02 PM, Isaac Gouy wrote:
> iirc the Haskell programs, and the Clean programs, and the Pascal
> programs, and ... use translations of the simple hash table used by
> the C programs.
>
> If I ever knew, I don't recall why the Haskell program does not use
> Data.HashTable
>
C
On Thu, Sep 2, 2010 at 6:07 PM, John Fingerhut wrote:
> Some of the Haskell submissions are quite long for what they do. The
> k-nucleotide one, for example, implements a mutable hash table using
> features in Haskell that I had never seen before looking at that program.
> Did they need to write
On Mon, Sep 6, 2010 at 10:47 AM, Robert McIntyre wrote:
> Why is it that clojure maps aren't lazy though?
> Wouldn't that be just as useful an abstraction as lazy sequences?
> Aren't map really just lists of pairs in the end anyway?
>
how can laziness benefit map usage pattern ? efficient search r
On Mon, Sep 6, 2010 at 10:09 AM, Justin Kramer wrote:
> reduce returns a single value; there's no collection to make lazy.
> There is reductions, which returns the intermediate results of reduce
> as a lazy sequence.
>
if f = cons in 'reduce f a seq', there is a collection. Though in this
case, on
On Mon, Sep 6, 2010 at 9:49 AM, Robert McIntyre wrote:
> I thought that since into uses reduce, it would be lazy, but I was wrong.
> reduce just plows through everything with a non-lazy recursion.
>
> Why is reduce not lazy?
>
reduce in clojure == foldl in Haskell
and as far as I know, there are
On Wed, Sep 1, 2010 at 7:46 PM, Sean Corfield wrote:
> If not, how do you build a Clojure web app that runs on Tomcat / JBoss / etc?
>
> (so the underlying question is: what's the raw Servlet implementation
> that folks use to power Clojure-based web apps on containers other
> than Jetty?)
> --
T
On Wed, Sep 1, 2010 at 11:58 AM, Laurent PETIT wrote:
>> The ideal setup, in my opinion, after using all sorts of different web
>> frameworks and languages over the last 14 years, is to have all the
>> HTML in the template - code never generates HTML - and to have *some*
>> markup in the HTML temp
On Mon, Aug 30, 2010 at 3:57 PM, Mark Nutter wrote:
> This may or may not be related, but I had similar problems when I
> tried to install from the downloadable .nbm file for enclojure. I
> solved it by poking around the enclojure.org site -- there's
> instructions for updating the plugins setup s
On Sat, Aug 28, 2010 at 8:37 AM, HB wrote:
> Ok, I understand what it does but I don't understand -yet- how it is
> works.
> Why vector and its parameters aren't in ( ) ?
> What are the parameters to the vector and what are the parameters to
> the map in the example?
>
vector is used as a 'functio
On Fri, Aug 27, 2010 at 8:17 AM, Btsai wrote:
> How are you grabbing the sources? I'm also running under Windows, and
> get the source from github via msysgit, which handles the crlf vs. cr
> issue nicely.
>
same here. that only handles the source crlf I assume. What I did was
specifically for th
On Fri, Aug 27, 2010 at 7:02 AM, B Smith-Mannschott
wrote:
> What test failures are you seeing? I'm not seeing any building
> github.com/clojure/clojure-contrib 1.2.0-RC3
> (e4ea06c9ff93df3b3f667ab5768618ece5a98b6e).
> Ran 365 tests containing 1298 assertions.
> 0 failures, 0 errors.
I need to exc
On Wed, Aug 25, 2010 at 7:06 AM, Glen Rubin wrote:
> After toying around at the REPL I realize that I have been working
> with a heretofore invalid understanding of collections. For example,
> working with the following collection(s):
>
> signal:
> (((1 2 3 4) (2 3 4 5) (3 4 5 6)) ((3 4 5 6) (4 5
On Mon, Aug 23, 2010 at 5:41 PM, Randy Hudson wrote:
> Well, #(<= lo % hi) is to my mind much more readable than (fn [x] (<=
> lo x hi)), especially embedded in another form or two (as it would
> be).
>
that may be true. though this IMO is partly due to the (<=)
construct's argument order. This i
On Mon, Aug 23, 2010 at 8:26 AM, Glen Rubin wrote:
> I am trying to write a fn to correlate 2 signals using 3 nested map
> fn. I have 2 collections of data. THe first group of signals called
> target looks something like this.
>
>
> target:
> ( (1,2,3,4) (2,3,4,5) ...)
>
>
> The second collectio
On Mon, Aug 23, 2010 at 9:01 AM, Joop Kiefte wrote:
> bad example =/
>
> Yes, it is
>
> but you get the gist I hope
>
> better example: #(first (sort %)) ;)
>
Yes, though I think it is still cleaner if it is expressed as:
(map (comp first sort) [[3 2] [4 5]])
In other words, if it is a single ar
On Mon, Aug 23, 2010 at 8:50 AM, Joop Kiefte wrote:
> uses like #(first %) keeps the code cleaner
>
Is that the same as just 'first' like :
(map first [[1 2] [3 4]])
(map #(first %) [[1 2] [3 4]))
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To
On Mon, Aug 23, 2010 at 8:31 AM, Luka Stojanovic wrote:
> It's not about nested maps, but about nested anonymous functions: if you
> nest anonimous functions you must use (fn [] ...) like:
>
> (map (fn [t s] (map #(map * %1 %2) t s)) target signal)
>
This has me question, how useful the #(...) fo
On Sat, Aug 21, 2010 at 10:32 AM, Nicolas Oury wrote:
> I am not sure but I think filter will always output a sequence.
filter is lazy but the function like (byte-array ..) would still
realize the sequence(i.e. list created) then copy.
(byte-array (count (filter ...)) (filter ...)) should work, a
On Mon, Aug 9, 2010 at 5:24 PM, Carlos Torres wrote:
> Hi to everyone,
> I'm trying to create a function that takes a simple list and returns the
> number of zeros in the list.
> So I'm assuming that they will enter a list containing only numbers.
> This is what I have so far, but it only works wh
On Sun, Aug 8, 2010 at 10:50 PM, Meikel Brandmeyer wrote:
> Hi,
>
> On Aug 8, 6:19 pm, gary ng wrote:
>
>> I wrote a similar version in F# which does have the advantage of
>> handling infinite input or a very long partition in the sense that I
>> can still consume
On Sun, Aug 8, 2010 at 10:32 PM, Meikel Brandmeyer wrote:
> I'm bit confused about what you mean here, but vector append (read:
> conj) is O(1) (don't nail me down on whether it's amortised). There is
> no array copying going on underneath.
>
Assuming vector is implemented in some form of array(we
On Sat, Aug 7, 2010 at 9:30 PM, David Cabana wrote:
> conj is not the same as append; it will insert the new element in the
> smart (most efficient) way. For instance:
> user> (conj '(1 2 3) 0)
> (0 1 2 3)
> user> (conj [1 2 3] 0)
> [1 2 3 0]
>
> There is no performance hit from using conj to in
On Sun, Aug 8, 2010 at 12:12 AM, Meikel Brandmeyer wrote:
> Just for fun another low-level solution:
>
> (defn partition-when
> [pred coll]
> (let [step (fn [p s]
> (if s
> (let [fst (first s)]
> (if (pred fst)
> [p s]
>
On Sat, Aug 7, 2010 at 8:56 PM, Michał Marczyk wrote:
> Yet another version:
>
> (defn take-while-acc [f pred coll]
> (map (fn [_ x] x)
> (take-while pred (reductions f coll))
> coll))
>
> Seems to work:
>
> user> (take-while-acc + #(< % 100) (range))
> (0 1 2 3 4 5 6 7 8 9 10 11 12 1
On Sat, Aug 7, 2010 at 8:27 PM, David Cabana wrote:
> Using a vector instead of a list as the accumulator makes it possible
> to skip the mapping of reverse used in the earlier version of pw:
>
> (defn pw [f? x]
> (let [phi (fn [a e]
> (if (f? e)
> (cons [e] a )
>
On Sat, Aug 7, 2010 at 6:55 PM, Michael Gardner wrote:
> On Aug 7, 2010, at 8:48 PM, Michael Gardner wrote:
>
>> On Aug 7, 2010, at 8:39 PM, gary ng wrote:
>>
>>> nice, why do I need the gensym ?
>>
>> The gensym was just a cheesy way of generating a uniqu
On Sat, Aug 7, 2010 at 6:39 PM, gary ng wrote:
> On Sat, Aug 7, 2010 at 6:35 PM, Michael Gardner wrote:
>> (partition-by #(when (even? %) (gensym))
> nice, why do I need the gensym ?
ah, the gensym is for 'break'. but why does it behave like this
user=> (partition-by
On Sat, Aug 7, 2010 at 6:35 PM, Michael Gardner wrote:
> (partition-by #(when (even? %) (gensym))
nice, why do I need the gensym ?
--
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
On Sat, Aug 7, 2010 at 6:12 PM, David Cabana wrote:
> Speed is no big deal for me; the sequences I'm handling are short, say
> about length100. BTW, one of these is considerably faster than the
> other for longish sequences. Can you guess which?
>
if you don't mind about performance, this seems to
On Sat, Aug 7, 2010 at 10:44 AM, Andreas Liljeqvist wrote:
> Thanks that works.
> What I really want is a function like in my initial posting.
> Is there something like that in core or contrib?
> Your example code can be quite slow since all sublists are summed before
> comparision.
I believe my v
On Sat, Aug 7, 2010 at 12:46 PM, Steve Purcell wrote:
>
> Nice - that's about twice as fast as my version (with the 100 limit scaled up
> to 1 million), though perhaps a less general pattern since the code structure
> assumes knowledge of +'s cumulative nature.
>
Yes, it needs a proper initiali
On Sat, Aug 7, 2010 at 8:14 AM, Steve Purcell wrote:
> Oh, right, so maybe:
> (last (take-while #(< (apply + %) 100) (reductions conj [] (iterate inc
> 0
> => [0 1 2 3 4 5 6 7 8 9 10 11 12 13]
> -Steve
or
user=> (map second (take-while (fn [e] (< (first e) 100)) (rest
(reductions (fn [a x] [
On Sat, Jul 24, 2010 at 3:16 PM, samnardoni wrote:
>
> I have a simple string (or list of characters to be precise) in a form
> of: "1234<5678<<9".
>
> I want to parse this string and end up with: "123569".
>
> The "<" is essentially the same as a "backspace".
>
I think reduce(or fold/foldl' in Ha
J(a language of the APL family) excels at this problem domain. It is
functional and very efficient.
conv =: +//@*/
It looks like line noise but that is the whole implementation
(1 1 ) conv (1 1)
=> 1 2 1
http://www.jsoftware.com/
--
You received this message because you are subscribed to
On Sat, May 8, 2010 at 4:00 PM, Anne Ogborn wrote:
> >Have you seen Leiningen? [1]. It seems like it will do what
> you want
> >with "lein repl", and additionally it has some nice features for
> >acquiring dependencies and building a .jar from your project.
>
> Unfortunately lein repl is apparent
On Sat, May 8, 2010 at 1:01 PM, Meikel Brandmeyer wrote:
> Hi,
>
> if you want to go low-level you can use lazy-seq.
>
> (defn replace-first
> [needle replacement coll]
> (lazy-seq
>(when-let [s (seq coll)]
> (let [fst (first s)]
>(if (= fst needle)
> (cons replacement
I would use reductions(i.e. Haskell's scanl) given my understanding that
clojure sequence is just as lazy as Haskell.
(rest (map first (reductions (fn [ [v a b] x ] (if (= a x) [b nil b] [x a
b]))
[nil 2 3] '(1 1 2 2 3 4
I use nil here as 'something that would not appear in the list', I am su
On Sat, May 8, 2010 at 9:20 AM, Adam Jones wrote:
> Have you seen Leiningen? [1]. It seems like it will do what you want
> with "lein repl", and additionally it has some nice features for
> acquiring dependencies and building a .jar from your project.
>
> [1] http://github.com/technomancy/leining
On Thu, May 6, 2010 at 10:49 AM, Heinz N. Gies wrote:
> If I may :) since I'm the sandbox guy.
>
>
Is it possible to use the sandbox functionalities without the future/thread
part ?
Basically, I am trying to create a chatty REPL(say HTTP POST based).
the thread would be created by the app conta
On Thu, May 6, 2010 at 4:19 AM, Mibu wrote:
> As far as I can tell, clj-sandbox works by a set whitelist of
> arbitrary functions, which is not a very generic approach. It works
> for sandboxes like clojurebot, but not for other stuff.
>
> A restricted eval in all likelihood will not refer direct
On Wed, May 5, 2010 at 10:34 PM, Meikel Brandmeyer wrote:
> I'm deeply suspicious of such a behaviour. Why would + on a
> date mean adding days? Why not hours? minutes? seconds?
> months? years? I would always prefer plus-days over such a
> behaviour, because I wouldn't have to think everytime, w
On Wed, May 5, 2010 at 3:18 PM, Meikel Brandmeyer wrote:
> Hi,
>
> On Wed, May 05, 2010 at 02:56:09PM -0700, gary ng wrote:
> Right now, this can be handled as:
>
> (ns foo
> (:refer-clojure :as core :exclude (+)))
>
> (defn +
> [matrix1 matrix2]
> ... (co
I have a question related to this.
(ns foo (:use clojure.core))
(defn + [x y] x)
'+' is already referred because of the use and is an error right now. But
this is a legitimate use of the symbol as 'foo' can be matrix and matrix
addition is different from standard number addition. Or is there a b
On Thu, Apr 29, 2010 at 10:43 PM, David Nolen wrote:
> My rule of thumb is:
>
> use + :only
> require + :as
>
> I believe this should be documented as the 'suggested usage'. As contrary
to Python where 'from module import *'(which is 'use' in clojure) is right
in there saying 'you know what you ar
On Thu, Apr 29, 2010 at 9:11 PM, Meikel Brandmeyer wrote:
>
> c.c.string is not designed to be used like that. Use require plus an
> alias: (require '[clojure.contrib.string :as s]). Then repeat is the
> core repeat and s/repeat is the string repeat.
>
> What would be the use case of 'use' then ?
On Thu, Apr 29, 2010 at 7:24 PM, ataggart wrote:
> user=> (defn repeat [x] x)
> java.lang.Exception: Name conflict, can't def repeat because
> namespace: user refers to:#'clojure.core/repeat (NO_SOURCE_FILE:1)
> user=> (ns my.ns (:refer-clojure :exclude [repeat]))
> nil
> my.ns=> (defn repeat [x]
Clojure 1.2.0-master-SNAPSHOT
user=> (use `clojure.contrib.string)
java.lang.IllegalStateException: repeat already refers to:
#'clojure.core/repeat
in namespace: user (NO_SOURCE_FILE:0)
By going through the source, I see c.c.s deliberately exclude certain
symbols but don't know how to do it in th
On Mon, Apr 26, 2010 at 6:26 PM, gary ng wrote:
>
>
> On Sun, Apr 25, 2010 at 4:47 PM, ataggart wrote:
>
>> Yeah, the fix-patch was submitted prior to the final release of 1.1.0,
>> but alas none of those with the power to actually commit the patch got
>> arou
On Sun, Apr 25, 2010 at 4:47 PM, ataggart wrote:
> Yeah, the fix-patch was submitted prior to the final release of 1.1.0,
> but alas none of those with the power to actually commit the patch got
> around to it until it was too late.
>
>
I have built the 1.2.0-snapshot which seems to be even worse
Hi,
I am wondering if there is any windows user who is familiar with
clojure-contrib project.
The reason I asked is that I encountered quite some issues when trying to
build my own copy of clojure-contrib(on windows). That includes:
1. I cannot clone http://github.com/richhickey/clojure-contrib.
On Sun, Apr 25, 2010 at 3:34 PM, ataggart wrote:
> Was the problem you're having occurring with the latest version of
> cc.logging (the one that uses eval)?
>
> The logging macros do not emit calls to the logging implementation,
> but rather to c.c.logging functions that are implemented at runtim
On Sun, Apr 25, 2010 at 1:17 PM, Allen Johnson wrote:
> > What seems to be happening is that when I build my 'gen-class' package,
> the
> > class is nailed down even though logging.clj itself is not gen-classed.
>
> I'm not familiar with GAE but as a workaround can you include the
> commons-loggin
On Sun, Apr 25, 2010 at 11:08 AM, gary ng wrote:
> Hi,
>
> I am trying to use clojure to write servlets for GAE and is encountering
> problem with clojure.contrib.logging. When trying to use the logging
> function, I get the following exception:
>
> java.lang.C
Hi,
I am trying to use clojure to write servlets for GAE and is encountering
problem with clojure.contrib.logging. When trying to use the logging
function, I get the following exception:
java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(URLC
On Sat, Apr 24, 2010 at 12:56 PM, Allen Johnson wrote:
> Here's my attempt. I don't think you can do much about the imperative
> style when you are calling Java APIs unless someone was nice and wrote
> a clojure wrapper. But I'm just a n00b.
>
thanks for the help. When deployed to GAE, I got the
Hi,
As a newbie learning clojure, I would like to code in clojure rather than
'java disguised as clojure' and I am wondering what would it looks like for
the following typical java(shown below) implementation. which has:
1. a static class member for the logger
2. and typical imperative style codi
I would choose the one with glassfish which includes the web app things that
even though you may not need immediately(if compojure comes with embedded
jetty) will be very likely in the future when you use other app
containers(be it GAE or tomcat etc.)
I picked the base Java SE version and needs to
Hi,
I just start to learn about clojure and is wondering if there is any erlang
like environment for clojure ? By that, I mean not just the messaging
passing(which as far as I can tell for clojure is within the same process)
but its live update and sending symbols(and as far as I know functions as
66 matches
Mail list logo