Re: a library I'm working on for generating PDFs from Clojure

2012-04-20 Thread Tim Robinson
Also, wkhtmltopdf  has worked well for me.

http://code.google.com/p/wkhtmltopdf/

On Apr 20, 4:06 am, Patrick Wright pdoubl...@gmail.com wrote:
 Dmitri,

 you might look at delegating some of the effort to Flying Saucer, which can
 generate PDFs when given clean HTML and 
 CSS.http://code.google.com/p/flying-saucer/

 There is a blog somewhere (which is currently unreachable) of someone using
 FS from Clojure.

 HTH,
 Patrick

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Sumo: A new clojure client for the Riak datastore

2011-12-22 Thread Tim Robinson
I'm not involved in the development of this client library - I'm just
glad to see it get started. Many thanks to the folks a basho for
considering a Clojure client worthy of being on their roadmap.

https://github.com/reiddraper/sumo

Tim

-Original Message-
From: Reid Draper reiddra...@gmail.com
Sent: Thursday, December 22, 2011 8:45am
To: riak-us...@lists.basho.com
Subject: sumo: a riak clojure client

___
riak-users mailing list
riak-us...@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
All,

A few of us [1] have been working on a Riak Clojure client, and I
figured
there is enough now to open source. There is currently basic key/value
functionality present. Check it out here: https://github.com/reiddraper/sumo

[1]: myself, *Brett Hoerner and *Justin Shoffstall

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


How do I identify Clojars clojure libraries that are 1.3 compatible?

2011-12-03 Thread Tim Robinson
Hello,

I'm just starting to upgrade to 1.3 ( I know, I know I should have
done this before :)

Like many of you, I am using lein, only I'm just starting to update
the dependency list. Clojure contrib seems pretty straight forward and
documented, but for what about libraries that are found on Clojars?
Are they flagged compatible somehow? i.e. ring, clj-json, clj-unit,
clj-stacktrace etc... or is it a research project for each one? Also,
it looks like many of them appear to be independent anyway, so it may
not be all that bad, but still I'm just wondering how everyone else
approached it.

Thanks,
Tim

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Avout: Distributed State in Clojure

2011-11-29 Thread Tim Robinson
Fantastic !!!  I'm looking forward to giving this a try. It has
the potential to solve some problems I am currently working on.

so thanks for your efforts.
Tim

On Nov 29, 10:38 am, liebke lie...@gmail.com wrote:
 Today we are releasing Avout, which brings Clojure's in-memory model
 of state to distributed application development by providing a
 distributed implementation of Clojure's Multiversion Concurrency
 Control (MVCC) STM along with distributable, durable, and extendable
 versions of Clojure's Atom and Ref concurrency primitives.

 Here's the post announcing the 
 project:http://clojure.com/blog/2011/11/29/avout.html

 And here's the project's website:http://avout.io

 David

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Code problem: setting an atom from a deref'd atom that's inside a let.

2011-10-25 Thread Tim Robinson
This code probably will not make a whole lotta sense since I reduced
it down to show only the problem at hand, but I'm hoping someone can
explain why this doesn't work the way I expected it would:

= (def data (atom {:k1 v1 :k2 v2 :k3 v3}))
#'user/data

= (def flag (atom nil))
#'user/flag

= (defn oops! []
(let [x1  (atom (hash-map))
  v1  (filter
  #(let [xv1 (@data %)]
   (if (= xv1 v1)
   (swap! x1 assoc :k1 other)))
   (keys @data))
  rxv (reset! flag @x1)]
  (println v1)))

= (oops!)
(:k1)
nil

= @flag
{}

I had expected this flag would now hold the value from x1, but instead
it's empty.
Now if the only change I make is not to deref the x1 atom when
resetting:

= (def flag (atom nil))
#'user/flag

= (defn oops! []
(let [x1  (atom (hash-map))
  v1  (filter
  #(let [xv1 (@data %)]
   (if (= xv1 v1)
   (swap! x1 assoc :k1 other)))
   (keys @data))
  rxv (reset! flag x1)]
  (println v1)))

= (oops!)
(:k1)
nil

= @flag
#Atom@7dad453f: {:k1 other}

The atom value is available.
So why didn't the first version with deref work?

Please  Thanks,
Tim

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Code problem: setting an atom from a deref'd atom that's inside a let.

2011-10-25 Thread Tim Robinson


Yes, that does.
Thanks to both of you.
Tim

On Oct 25, 10:16 am, Chris Perkins chrisperkin...@gmail.com wrote:
 On Tuesday, October 25, 2011 12:00:04 PM UTC-4, Tim Robinson wrote:

  This code probably will not make a whole lotta sense since I reduced
  it down to show only the problem at hand, but I'm hoping someone can
  explain why this doesn't work the way I expected it would:

  = (def data (atom {:k1 v1 :k2 v2 :k3 v3}))
  #'user/data

  = (def flag (atom nil))
  #'user/flag

  = (defn oops! []
      (let [x1  (atom (hash-map))
            v1  (filter
               #(let [xv1 (@data %)]
                     (if (= xv1 v1)
                         (swap! x1 assoc :k1 other)))
                         (keys @data))
            rxv (reset! flag @x1)]
        (println v1)))

  = (oops!)
  (:k1)
  nil

  = @flag
  {}

  I had expected this flag would now hold the value from x1, but instead
  it's empty.

  No, it's not empty - it holds the value that x1 had at the time you swapped

 it, which is an empty map.

 Later, the x1 atom had its value changed, by then it was too late to affect
 flag. Specifically, x1 changed only when you printed v1, thus forcing
 realization of the lazy sequence that filter returned.

 Make sense?

 - Chris

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Code problem: setting an atom from a deref'd atom that's inside a let.

2011-10-25 Thread Tim Robinson
Good question.

Also, I wonder if there are any existing realize type functions?
i.e.
(realize (filter ...))

or how would I realize without printing?
Tim


On Oct 25, 10:12 am, Marshall T. Vandegrift llas...@gmail.com
wrote:
 Tim Robinson tim.blacks...@gmail.com writes:
  = (defn oops! []
      (let [x1  (atom (hash-map))
            v1  (filter
                   #(let [xv1 (@data %)]
                     (if (= xv1 v1)
                         (swap! x1 assoc :k1 other)))
                         (keys @data))
            rxv (reset! flag @x1)]
        (println v1)))
  So why didn't the first version with deref work?

 Because `filter' produces a lazy list, which isn't realized (and the
 side effects generated) until your call to `println'.

 Furthermore, the documentation for `filter' explicitly notes that pred
 must be free of side-effects.  Looking at the implementation, I'm not
 sure why function-argument purity matters more for `filter' than any
 other sequence-generating higher-order function.  Does anyone else know
 the reason?

 -Marshall

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Code problem: setting an atom from a deref'd atom that's inside a let.

2011-10-25 Thread Tim Robinson
Never mind... I just used 'count'.
And sorry to spam the group.

On Oct 25, 10:44 am, Tim Robinson tim.blacks...@gmail.com wrote:
 Good question.

 Also, I wonder if there are any existing realize type functions?
 i.e.
 (realize (filter ...))

 or how would I realize without printing?
 Tim

 On Oct 25, 10:12 am, Marshall T. Vandegrift llas...@gmail.com
 wrote:







  Tim Robinson tim.blacks...@gmail.com writes:
   = (defn oops! []
       (let [x1  (atom (hash-map))
             v1  (filter
                    #(let [xv1 (@data %)]
                      (if (= xv1 v1)
                          (swap! x1 assoc :k1 other)))
                          (keys @data))
             rxv (reset! flag @x1)]
         (println v1)))
   So why didn't the first version with deref work?

  Because `filter' produces a lazy list, which isn't realized (and the
  side effects generated) until your call to `println'.

  Furthermore, the documentation for `filter' explicitly notes that pred
  must be free of side-effects.  Looking at the implementation, I'm not
  sure why function-argument purity matters more for `filter' than any
  other sequence-generating higher-order function.  Does anyone else know
  the reason?

  -Marshall

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Is Clojure Simple?

2011-10-22 Thread Tim Robinson
So I've read the previous post   Rich Hickey: Simple Made Easy from
Strange Loop 2011, but I wanted to ask some simple questions not
complected by the interweaving path the other has post followed (is
'complected' even a word? - lol) .

I know the presentation was, while inclusive of Clojure, not specific
to Clojure and after having given some further thought I find myself
wondering where does Clojure sit in this continuum of simple to
complectness (ok,  yes I am now making up words).  And I wonder where
do the language designers think Clojure sits? How far along has
Clojure gone down this rabbit hole?

Is Rich planning to make a new language, because Clojure is 'here',
but not 'there' ? - and where is 'here' for Clojure anyway?  If your
were to rank, in accordance to Rich's inventory of complect items, is
Clojure a 5/10? or a 9/10?

Do the Clojure language designers plan to make changes to Clojure to
make it simpler? And if so, how so?

I don't want this to be a battle on Clojure doing 'this' but not
'that' (and I hope that's possible).
Tim







-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Question:Multi-Core processor affinity for load balancing Clojure Web apps

2011-10-20 Thread Tim Robinson
This may not be a Clojure specific kind of question, but this is for
my Clojure web app(s) so hopefully it's not too far off.

Currently when I deploy my web apps I run 1 app instance on 1 app
server. Given these are multi-core servers I am thinking about running
4 app instances on a server to get max IO capabilities at a lower
cost.  (Note that I currently using nginx, to route requests to a
Clojure/Ring+Jetty web app on a specified port. I am expecting that in
order to run 4 app instances I will need to load balance within nginx
to each port and also set the processor affinity for each app instance
to ensure they are balanced across cores).

So here are my questions:

1. Does this idea make sense? why/whynot?
2. Do you do currently do this for your web apps and can you provide
any insight/experiences that could be helpful?
3. Is there a way to specify processor affinity within the
application, such that I wouldn't need to manually set them
afterwards?
4. Are there better ideas to accomplish the same kind of thing?

Thanks for any help/ideas.

Tim



-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: about the lazy-seq

2011-08-24 Thread Tim Robinson
There's a pretty good explanation here:
http://stackoverflow.com/questions/4992298/clojure-lazy-sequence-usage

On Aug 23, 11:48 pm, xiaoguizi87 xiaogui...@gmail.com wrote:
 I feel it is too difficult to understand the 'lazy-seq'.Can someone
 recommend something may help me? I have goolge it, but found nothing
 helpful.

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: FleetDB or other NoSQL store for Clojure?

2011-07-17 Thread Tim Robinson
- it should support transactions

I love the word *should* :)

Question: Do you really need transactions? or is that you just need
conflict resolution?

I ask because many No-SQL datastores support the later which often is
good enough (or even better in my opinion).

For example look at the description for RIAKs model:

Riak’s approach ensures that the datastore is always write-available,
and that writes always succeed, even in the face of a network split or
hardware failure, so long as the client can reach at least one node in
the cluster. The tradeoff is that the client performing the read must
do a little extra work to resolve the conflict, or can optionally
choose to take the latest version of the object (this is the default
setting.)

Where...

take the latest version of the object (this is the default setting.)

is all I really ever need.

MongoDB is similar, in that it supports conflict resolution, only I
believe you only have the option for the last write wins. MongoDB is
better suited to an embedded db model, that doesn't have to support
large datasets... so if you're OK with the last write wins model - go
for mongo.

https://github.com/aboekhoff/congomongo

Also there's a few other no-sql database connectors I list out in my
blog (with links to the libraries):

http://blackstag.com/blog.posting?id=23#subsection8

On Jul 15, 1:17 am, Marko Kocić marko.ko...@gmail.com wrote:
 Hi all,
 I would like to try out some of those no-sql datastores for my next
 project, and need an advice which one, since I never used the one before.
 It needs to fulfill at least some of those following criteria, in order of
 importance:

 - is nicelly supported by Clojure (by this I mean idiomatic clojure
 driver, not java plain java wrapper)
 - it should be schemaless
 - it should support transactions
 - it's good if it can be used as embedded db
 - it doesn't have to support large datasets (in-memmory is ok)
 - it has to run on both Windows and Linux

 My first choice would be FleetDB, since it was written in Clojure and
 examples look nice, but I'm not sure if it is abandonware or not, and I
 havent heard that people are actually using it in production.

 What are my other options?

 Regards,
 Marko

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: FleetDB or other NoSQL store for Clojure?

2011-07-17 Thread Tim Robinson
I wasn't saying that MongoDB was similar in terms of master-master vs.
master-slave, I was saying MongoDB was similar in that it implements
conflict resolution rather that transactions.

http://www.mongodb.org/display/DOCS/Atomic+Operations

MongoDB supports atomic operations on single documents.  MongoDB does
not support traditional locking and complex transactions for a number
of reasons:...

And that MongoDB implements a currency check (Update if Current) to
resolve conflicts.


On Jul 17, 11:04 am, Sergey Didenko sergey.dide...@gmail.com wrote:
 Tim, I think you mean CouchDB, which indeed is master-master. MongoDB is
 extended master-slave.

 On Sun, Jul 17, 2011 at 6:45 PM, Tim Robinson tim.blacks...@gmail.comwrote:







  MongoDB is similar, in that it supports conflict resolution, only I
  believe you only have the option for the last write wins. MongoDB is
  better suited to an embedded db model, that doesn't have to support
  large datasets... so if you're OK with the last write wins model - go
  for mongo.

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: FleetDB or other NoSQL store for Clojure?

2011-07-17 Thread Tim Robinson
Could be that I am using the wrong wording with conflict resolution.
Tim

On Jul 17, 1:53 pm, Tim Robinson tim.blacks...@gmail.com wrote:
 I wasn't saying that MongoDB was similar in terms of master-master vs.
 master-slave, I was saying MongoDB was similar in that it implements
 conflict resolution rather that transactions.

 http://www.mongodb.org/display/DOCS/Atomic+Operations

 MongoDB supports atomic operations on single documents.  MongoDB does
 not support traditional locking and complex transactions for a number
 of reasons:...

 And that MongoDB implements a currency check (Update if Current) to
 resolve conflicts.

 On Jul 17, 11:04 am, Sergey Didenko sergey.dide...@gmail.com wrote:







  Tim, I think you mean CouchDB, which indeed is master-master. MongoDB is
  extended master-slave.

  On Sun, Jul 17, 2011 at 6:45 PM, Tim Robinson 
  tim.blacks...@gmail.comwrote:

   MongoDB is similar, in that it supports conflict resolution, only I
   believe you only have the option for the last write wins. MongoDB is
   better suited to an embedded db model, that doesn't have to support
   large datasets... so if you're OK with the last write wins model - go
   for mongo.

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


meta data question

2011-07-13 Thread Tim Robinson
I know I can get the meta data using the following form:

= (meta #'get)
{:ns #Namespace clojure.core, :name get, :file clojure/
core.clj

Is there a means to get the meta data from the stored function without
using its identifier?

ie. knowing this result:

= get
#core$get clojure.core$get@77036a6b

Can I somehow do this:

=(meta #core$get clojure.core$get@77036a6b)
java.lang.Exception: Unreadable form...

Thanks,
Tim

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: meta data question

2011-07-13 Thread Tim Robinson
That'll do - Thank you both.
Tim

On Jul 13, 8:12 pm, Luc Prefontaine lprefonta...@softaddicts.ca
wrote:
 By string I mean human readable...

 On Wed, 13 Jul 2011 21:56:58 -0400









 Luc Prefontaine lprefonta...@softaddicts.ca wrote:
  #core$get clojure.core$get@77036a6b is a string representation of
  the fn object, not the object itself.

  user= (def a get)
  #'user/a
  user= (meta a)
  {:ns #Namespace clojure.core, :name get, :file
  clojure/core.clj, :line 1154, :arglists ([map key] [map key
  not-found]), :added 1.0, :inline-arities #{2 3}, :inline
  #core$get__inliner clojure.core$get__inliner@3a1834, :doc Returns
  the value mapped to key, not-found or nil if key not present.}

  works because a contains the fn object (get in this case).

  If your intent is to get the meta data of an unnamed fn at runtime
  the above solves your issue.

  Luc P.

  On Wed, 13 Jul 2011 18:35:00 -0700 (PDT)
  Tim Robinson tim.blacks...@gmail.com wrote:

   I know I can get the meta data using the following form:

   = (meta #'get)
   {:ns #Namespace clojure.core, :name get, :file clojure/
   core.clj

   Is there a means to get the meta data from the stored function
   without using its identifier?

   ie. knowing this result:

   = get
   #core$get clojure.core$get@77036a6b

   Can I somehow do this:

   =(meta #core$get clojure.core$get@77036a6b)
   java.lang.Exception: Unreadable form...

   Thanks,
   Tim

 --
 Luc P.

 
 The rabid Muppet

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Correct way to define the else clause of a cond form?

2011-07-06 Thread Tim Robinson
In addition to Benny's suggestion -  I will suggest, for future
reference, that the ClojureDocs website does an brilliant job in
showing some examples. It really is a valuable resource that I've come
to rely on.

http://clojuredocs.org/clojure_core/clojure.core/cond

And what's interesting to note is the comment made near the bottom:

We should add a comment in the docstring for the final usage
of :else.

Isn't that a coincidence :)

On Jul 6, 6:34 pm, Conrad Taylor conra...@gmail.com wrote:
 Hi, what's the correct way to define an else clause of a cond form?
 For example,

 a)

 (cond
    (= total 20) 8.75
    (or (amount  20) (= country US) 9.75)
    (else 10.0))

 b)

 (cond
    (= total 20) 8.75
    (or (amount  20) (= country US) 9.75)
    :default 10.0)

 c)

 (cond
    (= total 20) 8.75
    (or (amount  20) (= country US) 9.75)
    10.0 )

 d)

 (cond
    (= total 20) 8.75
    (or (amount  20) (= country US) 9.75)
    :else 10.0 )

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Correct way to define the else clause of a cond form?

2011-07-06 Thread Tim Robinson
You have some rogue text cluttering your cond statement.
Remove the question mark... or whatever this is...



and you'll be fine.

On Jul 6, 8:58 pm, Conrad Taylor conra...@gmail.com wrote:
 On Jul 6, 7:33 pm, Benny Tsai benny.t...@gmail.com wrote:

  Could you please post the entire form, including the code surrounding the
  cond form (since total, amount, and country need to be defined somewhere)?

 Benny, that was just sample code to zero in on the initial issue.  I'm
 working
 through the SICP with a lot of pain but here's what I have so far:

 (def us-coins (list 50 25 10 5 1))
 (def uk-coins (list 100 50 20 10 5 2 1 0.5))

 (defn first-denomination [ coin-values ] (first coin-values))

 (defn except-first-denomination [ coin-values ] (rest coin-values))

 (defn no-more? [coin-values] (nil? coin-values))

 (defn cc [amount coin-values]
         (cond
                 (= amount 0) 1
                 (or ( amount 0) (no-more? coin-values)) 0
              :else (+ (cc amount (except-first-denomination coin-values))
                             (cc (- amount (first-denomination coin-
 values)) coin-values

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Correct way to define the else clause of a cond form?

2011-07-06 Thread Tim Robinson
Lol. not sure what to tell you... on Mac OSX Firefox I see what looks
like this

--
- OBJ -
--

in the middle line, but really really really small.

and when I copy his text and paste at the repl, I get his same error.
When I remove it its not a problem.


On Jul 6, 9:07 pm, Ken Wesson kwess...@gmail.com wrote:
 On Wed, Jul 6, 2011 at 11:06 PM, Tim Robinson tim.blacks...@gmail.com wrote:
  You have some rogue text cluttering your cond statement.
  Remove the question mark... or whatever this is...

  

  and you'll be fine.

 Whatever WHAT is? There's nothing in your post there but three blank lines.

 --
 Protege: What is this seething mass of parentheses?!
 Master: Your father's Lisp REPL. This is the language of a true
 hacker. Not as clumsy or random as C++; a language for a more
 civilized age.

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Guide to Programming in Clojure for Beginners

2011-06-28 Thread Tim Robinson
I'm fairly new to Programming, Clojure and Blogging, but I did manage
to write a few posts about Clojure in my spare time.

http://blackstag.com/blog.posting?id=5

I have now have a newly found appreciation for how much effort this
kind of stuff can be :)
Feedback is always welcome.

Regards,
Tim

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Cons vs List vs. ISeqs

2011-06-24 Thread Tim Robinson
I'm under the impression that traditional lisps have a greater
distinction between a cons operation vs. a list operation.
Specifically I had believed that consing was a more efficient and
better performing operation than using list.

Is this true? and if so, given both the Cons and Lists are actually
both just seqs in Clojure, does the above statement still hold true in
the Clojure world?

Thanks
Tim

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Cons vs List vs. ISeqs

2011-06-24 Thread Tim Robinson
Makes sense - Thanks (to all)!
Tim

On Jun 24, 8:29 pm, David Sletten da...@bosatsu.net wrote:
 On Jun 24, 2011, at 7:35 PM, Tim Robinson wrote:

  I'm under the impression that traditional lisps have a greater
  distinction between a cons operation vs. a list operation.
  Specifically I had believed that consing was a more efficient and
  better performing operation than using list.

 This is not true, but it is also not relevant. In historical Lisps, the list 
 datatype is a singly-linked list consisting of nodes known as CONS cells. In 
 Common Lisp, for example, the predicate (listp obj) is simply equivalent to 
 the test (typep obj '(or cons null)). A list is either a (chain of) CONS or 
 the empty list. Notice that this implicitly includes improper lists (dotted 
 pairs) such as (cons 1 2). In Clojure, on the other hand, it is illegal for 
 the second argument to 'cons' to be an atom:
 (cons 1 2) =
 java.lang.IllegalArgumentException: Don't know how to create ISeq from: 
 java.lang.Integer

 A Lisp form such as (list 1 2 3) is just a series of calls to cons: (cons 1 
 (cons 2 (cons 3 '(.

  Is this true? and if so, given both the Cons and Lists are actually
  both just seqs in Clojure, does the above statement still hold true in
  the Clojure world?

 As I mentioned, the correspondence between LIST and CONS in traditional Lisps 
 is not really relevant in Clojure, where the emphasis is on the sequence 
 abstraction. A sequence simply satisfies an interface that provides a 'first' 
 element, the 'rest' of the sequence, and allows you to construct ('cons') a 
 new sequence from an existing one. Lists and vectors are two concrete 
 sequence types, and they have significant differences in terms of behavior 
 and performance. But in Clojure you can 'cons' using a list or a vector. So 
 the rules are a little different from other Lisps.

 Have all good days,
 David Sletten

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Jesus, how the heck to do anything?

2011-03-23 Thread Tim Robinson
I suggest skipping right to leiningen:

https://github.com/technomancy/leiningen

Once you spend a few minutes creating a project template, you can
then run a simple command to create a jar file and run it.

Tim


On Mar 23, 1:50 am, ultranewb pineapple.l...@yahoo.com wrote:
 Short version:  How do I just open an editor, type in some Clojure
 code, save it in a file, and then run it?

 Long version:  Okay, I'm very new to Clojure.  But I'm not a Java
 programmer (don't want to be).  I'm not used to all this complexity
 just to do something simple.  What I want to do is the normal
 programming that I do with every other environment and language I
 work with, i.e. I edit some source code on screen, save it in a file,
 and either compile/run, or interpret it or whatever.  But I haven't
 figured out how to do that yet, and don't know if it's possible.

 I downloaded Netbeans and Enclojure.  It runs fine.  I can get a REPL,
 blah blah.  But have no idea how to do anything real i.e. execute a
 program saved in a file.  Again, I want to edit some code with the
 very nice editor, save it, and hit some button that says execute or
 perhaps compile and execute or perhaps build and execute or
 whatever.  But apparently there is a heck of a lot more to it than
 that.  I understand that you have to build a project or whatever.
 Fine - I did that.  Still, I have no idea which directory out of that
 huge structure I'm supposed to put code in, I have no idea how to set
 up all these dependencies or whatever.  I did try some random stuff,
 i.e. saving a file in various directories and hitting build but that
 didn't work.  I also tried editing various files that were already
 there, hoping one of them was the main file I was supposed to be
 dumping source code into, but that didn't work either.

 So I downloaded Clojure Box.  It installs and runs fine.  Again, I get
 a REPL no problem.  But there's only so much coding I can do in a
 REPL.  Again, I'd like to do more.

 I spent a long time trying to find some help online (googling, etc),
 but everything I've found assumes I know too much, i.e. how to set up
 all these projects and dependencies.

 Actually, I'm not interested in fooling with all the boilerplate and
 crap AT ALL.  So if I HAVE to do that, I'm outta here.  But something
 tells me I may not have to, i.e. there may be some automated tool
 somewhere, or some template files I can just use over and over, or
 some trick to use like just name your program 'main' and stick it
 in such-and-such directory.

 Any help?

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Jesus, how the heck to do anything?

2011-03-23 Thread Tim Robinson
 From what I've read and heard, TextMate would probably do exactly what I 
 want, but that only runs on Mac.

Note there is a Windows version of textmate.

http://www.e-texteditor.com/

And I've been able to use the bundles from the mac version in the
windows version (for other languages at least - I haven't tried the
clojure one yet).

Tim

On Mar 23, 9:15 am, Timothy Baldridge tbaldri...@gmail.com wrote:

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


complication using re-gsub having special chars in replacement string

2011-03-22 Thread Tim Robinson
I'm not well versed in regex functions., so I'm probably missing
something really obvious.

= (re-gsub #\$@ -- stuff$@stuff)
stuff--stuff

=(re-gsub #\$@ $@ stuff$@stuff)
java.lang.IllegalArgumentException: Illegal group reference
(NO_SOURCE_FILE:0)

Anyone run into this and have a simple solution?
Or maybe there's an alternative function?

Thanks,
Tim

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: complication using re-gsub having special chars in replacement string

2011-03-22 Thread Tim Robinson
Perfect. Thanks for the help.
Tim

On Mar 22, 9:11 pm, Alan a...@malloys.org wrote:
 $ is a special character in replacements as well, for indicating
 capturing-subgroups.

 user (require '[clojure.string :as s])
 nil
 user (s/replace stuff$@stuff #\$@ \\$@sub)
 stuff$@substuff

 On Mar 22, 8:05 pm, Tim Robinson tim.blacks...@gmail.com wrote:

  I'm not well versed in regex functions., so I'm probably missing
  something really obvious.

  = (re-gsub #\$@ -- stuff$@stuff)
  stuff--stuff

  =(re-gsub #\$@ $@ stuff$@stuff)
  java.lang.IllegalArgumentException: Illegal group reference
  (NO_SOURCE_FILE:0)

  Anyone run into this and have a simple solution?
  Or maybe there's an alternative function?

  Thanks,
  Tim

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Metadata on symbols differ with caret reader

2011-01-19 Thread Tim Robinson
I upgraded lein from 1.3.1 to 1.4.2, which fixed the problem.
:)

On Jan 10, 6:47 am, Stefan Kamphausen ska2...@googlemail.com wrote:
 Hi,

 I can't verify that a REPL created by lein behaves differently.  Did you
 perhaps update an old project.el without running lein deps?

 In addition to that: your defproject has too many ]'s

 Regards,
 Stefan

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Metadata on symbols differ with caret reader

2011-01-10 Thread Tim Robinson
Interesting.

My downloaded version of clojure 1.2.0 acts exactly as you describe.

However my basic lein project with only

  (defproject prj 1.0.0-SNAPSHOT
:dependencies [[org.clojure/clojure 1.2.0]]])

acts differently.

Well as I said, I can never sure about anything :)
Cheers
Tim

On Jan 9, 11:40 pm, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 On 10 Jan., 04:17, Tim Robinson tim.blacks...@gmail.com wrote:

  How does this happen when :tag is not even in the expression?
  If you launch a brand new repl and run it what happens?

 What I posted in the previous email is exactly a fresh repl session
 and what happens there with 1.2. And in fact, that it is what I would
 expect.

 ^String is a short-hand notation for ^{:tag String}. There was a
 change planned for using ^ with keywords, namely that ^:foo is short-
 hand for ^{:foo true}. But I don't know whether this change made it
 into 1.3.

 Sincerely
 Meikel

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Metadata on symbols differ with caret reader

2011-01-09 Thread Tim Robinson
You must have something messed up:

In line 1 (meta ^:k []) does not return {:tag :k}  it returns nil and
I am using Clojure 1.2.

Both lines 1 and 2, shouldn't return meta, because 'meta' only takes
an object as an input argument.
And only if the object already has metadata will metadata will return.

= (def o (with-meta ['mydatastructure] {:k []}))
= (meta o)
{:k []}


On Jan 9, 2:52 pm, mdzaebel mdzae...@web.de wrote:
 Hi,

 (meta ^:k [])  --  {:tag :k}
 (meta ^:k 'o)  --  nil
 (meta(with-meta 'o {:tag :k}))  --  {:tag :v}

 Why doesn't the second line return the metadata?

 Thanks, Marc

 Using Clj 1.2

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Metadata on symbols differ with caret reader

2011-01-09 Thread Tim Robinson
Am I sure?.. No, I'm never sure :)

But I am using 1.2 and when I run (meta ^:k []) or even (meta '^:k o)
I get nil.

Plus:

app= (doc meta)
-
clojure.core/meta
([obj])
  Returns the metadata of obj, returns nil if there is no metadata.
nil

I could be missing something?






On Jan 9, 5:17 pm, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 Am 10.01.2011 um 01:10 schrieb Tim Robinson:

  You must have something messed up:

  In line 1 (meta ^:k []) does not return {:tag :k}  it returns nil and
  I am using Clojure 1.2.

  Both lines 1 and 2, shouldn't return meta, because 'meta' only takes
  an object as an input argument.
  And only if the object already has metadata will metadata will return.

  = (def o (with-meta ['mydatastructure] {:k []}))
  = (meta o)
  {:k []}

 Are you sure?

 Clojure 1.2.0
 user= (meta '^:k o)
 {:tag :k}
 user= (meta ^:k [])
 {:tag :k}
 user= (meta (with-meta 'o {:tag :k}))
 {:tag :k}
 user= (meta ^:k 'o)
 nil

 The ^ stuff all works in the reader. So meta always sees only one argument 
 with metadata already attached. The question is: Where is the meta data 
 attached?

 Sincerely
 Meikel

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Metadata on symbols differ with caret reader

2011-01-09 Thread Tim Robinson
user= (meta '^:k o)
{:tag :k}

How does this happen when :tag is not even in the expression?
If you launch a brand new repl and run it what happens?

On Jan 9, 5:17 pm, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 Am 10.01.2011 um 01:10 schrieb Tim Robinson:

  You must have something messed up:

  In line 1 (meta ^:k []) does not return {:tag :k}  it returns nil and
  I am using Clojure 1.2.

  Both lines 1 and 2, shouldn't return meta, because 'meta' only takes
  an object as an input argument.
  And only if the object already has metadata will metadata will return.

  = (def o (with-meta ['mydatastructure] {:k []}))
  = (meta o)
  {:k []}

 Are you sure?

 Clojure 1.2.0
 user= (meta '^:k o)
 {:tag :k}
 user= (meta ^:k [])
 {:tag :k}
 user= (meta (with-meta 'o {:tag :k}))
 {:tag :k}
 user= (meta ^:k 'o)
 nil

 The ^ stuff all works in the reader. So meta always sees only one argument 
 with metadata already attached. The question is: Where is the meta data 
 attached?

 Sincerely
 Meikel

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ANN: ClojureQL 1.0.0 now released

2011-01-08 Thread Tim Robinson
Thank you for making this.
It's a great idea and really enjoyable to use.
Tim

On Jan 5, 7:14 am, LauJensen lau.jen...@bestinclass.dk wrote:
 Hey everybody,

 Just a quick heads up that ClojureQL 1.0.0 is now released. All
 interfaces should be final and there are no known bugs. Works out of
 the box with PostgreSQL and MySQL but the compiler is a multimethod so
 you can implement your own backend if you need to work with other
 database backends. If you do so, please consider contributing it to
 ClojureQL :)

 All the info is found onhttp://www.clojureql.orgbut for those of you
 who haven't tried it out yet, I recommend watching this (dated) 
 video:http://vimeo.com/16958466

 Big thanks to everybody who has helped make this happen,
 Lau

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Out of memory

2010-12-21 Thread Tim Robinson
You may want to consider the heap size you have allocated to java. I
believe the default is 128.

For example you can set this yourself:

java -Xms256m -Xmx1024m

This provides 256mb initial heap and permits heap to grow to 1024mb.

I've been using Leiningen, so in my case I just changed the settings
in the source, before install.

There's probably a list of pros/cons to upping the default heap size
that you may want to consider.

Tim

On Dec 21, 7:09 am, Miles Trebilco miles.van...@gmail.com wrote:
 Why does this cause an out of memory error:

 (def out_of_mem
   (reduce + 0 (range 5000)))

 while this does not:

 (def not_out_of_mem
  (let [result 0]
   (reduce + result (range 5000

 and neither does this in the REPL:
   (reduce + 0 (range 5000)))

  - Miles

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Community attitude

2010-12-21 Thread Tim Robinson
 You might be interested to google fundamental attribution error.

After a briefly read on Wikipedia, I'm glad you pointed that out. I'll
read more.
Any other comment I could make on  that seems to open too many doors
to discussions
not related to Clojure, but thank you for sharing.

As for the voting, I try not to get to close to specific details/
failures of hn/reddit style forums.
All I need to know is that when I look at the top voted posts/comments
vs. the bottom votes (on HN) I generally find they
do a much better job separating the good from the bad than not doing
it at all.

On Dec 21, 6:39 pm, Ken Wesson kwess...@gmail.com wrote:
 On Tue, Dec 21, 2010 at 7:47 PM, Tim Robinson tim.blacks...@gmail.com wrote:
  In my humble opinion, I don't think what you're experiencing will get
  any better, but here are a few thoughts:

  1. You can still enjoy the community by changing your expectations and
  adopting 1 single rule (which I constantly try to remind myself with
  all the time):

  See people in a positive light, abrasive comment or otherwise. You're
  more likely to treat people with respect when you see them as
  genuinely good people than if you let adhoc comments dictate your
  feelings for that person.

 You might be interested to google fundamental attribution error.

  2. With intentional over the top flare, adding to a fire. Why on
  Gods earth are we using Google groups as a community forum? It's
  kinda, really, truly, sucky.
  Lol :)

  I mean really - voting based forums like hackernews/reddit have been
  around for years.
  The single most useful tool that moderators/community leaders have at
  their disposal is to place value based incentives which will get large
  masses following a set of expectations.

  Note: I know Google groups has voting, but frankly the implementation
  bites (Lol) it does not elevate the good and drown the bad which
  would allow us to read the valuable and ignore the crap.
  I don't even register votes happen in google groups.

 Not only that, but the votes are only visible in the sucky Google
 Groups interface. I expect most of us go there only to subscribe and
 then subsequently set various account options; we do our reading and
 replying in our email clients. Even gmail's web interface provides a
 superior user experience to Google Groups (including having a handy
 draft autosave feature), though it also doesn't show Groups ratings
 for Groups emails.

 But yes, there are problems with the Groups votes besides that. It's
 exposed only as a one-to-five-star rating plus the sample size, rather
 than being a digg or reddit style positive or negative number; there's
 no filtering option based on it; and it's apparently fairly easy to
 game. I've seen Groups showing Usenet posts with larger numbers of
 votes (good or bad) than there are active participants in the
 newsgroup, for instance. Likely you can vote, disconnect and reconnect
 to the net with a different IP, and then vote again, up to 256 times
 if you have a typical ISP. (You'd actually hit diminishing returns
 around halfway there when more often than not you'd log in with an IP
 that had already voted and have to try again. But I can see someone
 with patience and a will to pervert the vote manage to get forty, or
 fifty, or even sixty votes out of it before deciding it would suffice.
 :))

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Ah-hah! Clojure is a Lisp

2010-12-20 Thread Tim Robinson
I think too many posters here are equating Clojure with Lisp.
Clojure is a LISP, but it is not LISP itself.

* Mutability is not a given in all LISP implementations, only some of
them.
* STM transactions (i.e. state and time management upon non-mutable
objects) is a Clojure concept, that no other LISP's have.

So I will suggest the OP is not having a LISP ah-ha moment, but rather
a Clojure ah-ha moment. Lisp does have it's ah-ha moments in other
regards as I am sure is the case with any other language when you move
from being able use the language for general programming to being able
to use the language abstractions  ideology to change how you approach
programs. It's not like programmers didn't have this when everyone
moved to OO languages in the first place - they too had an ah-ha I get
OO now.


On Dec 19, 6:25 pm, Tim Daly d...@axiom-developer.org wrote:
 On 12/19/2010 8:20 PM, Ken Wesson wrote: On Sun, Dec 19, 2010 at 8:18 PM, 
 Tim Dalyd...@axiom-developer.org  wrote:
    I didn't mean to imply that other people
  don't have the ah-hah! experience with
  other languages. However, I have only had
  the (before lisp)|(after lisp) experience
  with lisp.

  Your enlightenment might vary.

  Rich gave his Whitehead talk and brought
  up the fact that OO languages get several
  things wrong.
  Out of curiosity, which several things were these?

 http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Ah-hah! Clojure is a Lisp

2010-12-20 Thread Tim Robinson
Hi Ken,

I'd like to nominate you on behalf of the Clojure community to convert
all non-text resources into text only resources. You officially have
my vote. I think your passion makes you the perfect candidate to do
this work. In the mean time I'd like to extend a thanks to all the
folks having taken the time producing these resources - they have
helped immensely.


On Dec 20, 11:50 am, Ken Wesson kwess...@gmail.com wrote:
 On Mon, Dec 20, 2010 at 1:48 PM, Meikel Brandmeyer m...@kotka.de wrote:
 http://clojure.googlegroups.com/web/AreWeThereYet.pdf

  *giggle*

  It figures.

  I ask for text instead of video so, naturally, I get a PDF link.

  *falls over laughing*

  How rude. Searching in the PDF (yes, that works), one finds with ease the 
  definition of all discussed terms like value, identity and state. All on 
  one sheet. How much shorter do you want it?

 I'd like it to fit in under 10KB if at all possible. :) I sometimes
 browse with mobile devices.

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Free Compojure Hosting? (or mostly free)

2010-12-18 Thread Tim Robinson
Free for 1 year:
http://aws.amazon.com/free/


On Dec 18, 10:55 am, Alex Baranosky alexander.barano...@gmail.com
wrote:
 Hi guys,

 I've got a simple toy app I'm writing wrote for fun to help my friend figure
 out where in the Boston area he should move to.  If I was using Rails I
 could throw it up on Heroku, essentially for free, because I have no plan to
 ever have any real traffic go there.  mostly I just want to show it to some
 friends at work, etc.

 Is there a similar free service to use with Compojure?  If not free, then
 what are the cheap options?

 Best,
 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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: String-friendly first/rest?

2010-12-08 Thread Tim Robinson
Laurent is right.

Best to use substring:

 (.substring test 1 (count test))
bc

On Dec 8, 12:43 pm, Surgo morgon.kan...@gmail.com wrote:
 To help myself learn Clojure, I figured I would write a pattern
 matching / destructing macro to better look like languages I'm more
 familiar with; i.e., destructuring by [first|second|rest] instead of
 [first second  rest]. To do this I'm turning the aforementioned
 vector into a string (via str) and looking for / replacing the |
 character. However, this led to the following issue...

 (def test abc)
 (first test) \a
 (rest test)
  (\b \c)

 (string? (rest test))

  false

 It would be really helpful if first/rest returned strings (or a
 character in the case of first), not lists, when given string input.
 Is there a design reason for the current behaviour and, if so, are
 there equivalent built-in functions that do the right thing for
 strings?

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Unable to run Clojure (jline is missing)

2010-12-08 Thread Tim Robinson
Did you download jline and put it in a location where it can been
accessed with the classpath?

http://jline.sourceforge.net/


On Dec 8, 6:47 pm, HB hubaghd...@gmail.com wrote:
 Hi,
 I downloaded Clojure 
 1.2https://github.com/downloads/clojure/clojure/clojure-1.2.0.zip
 and extract it.
 I created CLOJURE_HOME and added $CLOJURE_HOME/script to my $PATH
 Upon trying clj or repl , I got this error:

 Exception in thread main java.lang.NoClassDefFoundError: jline/
 ConsoleRunner
 Caused by: java.lang.ClassNotFoundException: jline.ConsoleRunner
         at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

 Any idea what is going wrong?
 I'm on OS X 10.6

 Thanks for help and time.

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Creating map from string

2010-12-04 Thread Tim Robinson
Using 'apply hash-map' doesn't handle the transformations.
Note the original post requested keywords for keys and integers for
vals in the output.


On Dec 4, 11:49 am, Tyler Perkins thinks.outs...@gmail.com wrote:
 How about just

 (apply hash-map (split (slurp data) #,))

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: why not change type compare functions do a compare on strings as well?

2010-12-03 Thread Tim Robinson
Hi ka,

I do already use compare in my functions, but compare alone is costly
to performance and isn't as meaningful given it doesn't evaluate true/
false.
It's really just about convenience and code-readability while trying
not to sacrifice too much speed.

To give you an example here's my over-riding Clojure defaults in a
patch file:

(defn  [x y]
 (if (coll? y)
 (if (string? x)
 (empty? (filter #(. clojure.lang.Numbers (isNeg (.compareTo
x %))) y))
 (empty? (filter #(. clojure.lang.Numbers (gt % x)) y)))
   (if (string? x)
   (. clojure.lang.Numbers (isPos (.compareTo x y)))
   (. clojure.lang.Numbers (gt x y)

(defn  [x y]
 (if (coll? y)
 (if (string? x)
 (empty? (filter #(. clojure.lang.Numbers (isPos (.compareTo
x %))) y))
 (empty? (filter #(. clojure.lang.Numbers (lt % x)) y)))
   (if (string? x)
   (. clojure.lang.Numbers (isNeg (.compareTo x y)))
   (. clojure.lang.Numbers (lt x y)


Using these I can write shorter, more readable code. So let's compare
the two:

(if ( 2010-11-01  [2010-06-09 2010-06-08 2010-06-04
2010-06-10])
(run-my-function-to-upate-data))

vs.

(if (empty? (filter #(neg? (compare 2010-11-01 %))[2010-06-09
2010-06-08 2010-06-04 2010-06-10]))
(run-my-function-to-upate-data))

~ there's probably 10 different other ways to write the above, but
it's an example.

So while this may seem trivial to many, cumulatively I have quite a
few of these functions built that have helped me
not only cut my code size in half, but have made my code really easy
to read and maintain. Furthermore my rule is to
favour code readability and only optimize performance when
meaningfully required.

P.S.

It's also worth noting that while my version of  is uglier and longer
than say:

(defn  [x y]
 (if (coll? y)
 (empty? (filter #(. clojure.lang.Numbers (isNeg (.compareTo x
%))) y))
 (. clojure.lang.Numbers (isPos (.compareTo x y)

My version performs well. Using (compare n) on a number is much more
costly than doing a string check.
Since I use it as a library function I never have to see it's
ugliness.

:)

On Dec 3, 7:47 pm, ka sancha...@gmail.com wrote:
 Hi Tim,

 How about compare?

 user= (compare a b)
 -1
 user= (compare b b)
 0
 user= (compare b a)
 1
 user= (compare 1 2)
 -1
 user= (compare 2 2)
 0
 user= (compare 2 1)
 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 that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: IDE and editors for Clojure

2010-12-02 Thread Tim Robinson
Textmate + Clojure Bundle.

There was a Textmate bundle that came out about a month ago that
allows the REPL to be called from within the editor. Really slick.
There was a video demo and all, I don't remember the name. When I get
home, if no one has posted it already, I will provide the link.

On Dec 2, 8:22 am, Heinz N. Gies he...@licenser.net wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 On Nov 22, 2010, at 14:36 , HB wrote:

  Hi,
  I'm pretty sure that this question is already been asked but failed to
  find it.
  What is your editor/IDE for Clojure?
  I didn't try them all, which IDE has the best Clojure support these
  days: IntelliJ, NetBeans or Eclipse?
  I'm not pretty happy with IntelliJ plugin.
  Thanks for help and time.

 Hi,
 I haven't tried IntelliJ but Emacs, Netbeans, Eclipse.

 What I have found:

 Emacs:
 If you are on windows don't use emacs unless you are happy with the absolute 
 are minimum or have a lot of time on your hand to dig out every single screw 
 to tweak. Generally it is more work especially if you are not a emacs guru 
 already - so on *nix it is very neat since it lets you use your own tools 
 like lein or git or whatever without too much interfering. Again if something 
 changes you've a lot of work ahead of you (Took me a day to get everything to 
 run with 1.2 and it still is throwing problems - so I guess that is only part 
 emac's fault since my incompetence is to blame here ;).

 Netbeans/Eclipse:
 I put them together for the start since they are very much the same. Neither 
 plugins gave me the same stability as emacs, they force you to use their 
 project setup (perhaps you can change it bit again it means extra work). It 
 is good that you can use them on about any platform with the same lookfeel - 
 sadly I'm tied to windows at work. the newer netbeans plugin forces you to 
 use maven which made me cry and try out eclipse then I noticed that since I 
 already had the silly pom file it was easyer to use it them shoving my 
 dependencies down it's throat all by myself.

 In the end I ended using eclipse  ccw on windows since it feelt the best 
 there, emacs and eclipse on my mac. But all in all I found none a really 
 pleasant experience but rather felt like the entire IDE's force me to do 
 things their way (which they perfectly manage to choose entirely differently) 
 instead of letting me do my work, so once you resign and give up on having 
 things to just work and accept to do it the EMACS/Eclipse/Netbeans way they 
 are all bearable.

 I hope you much luck so ;),
 Heinz
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.9 (Darwin)

 iEYEARECAAYFAkz3uaAACgkQHwrnTfuX/fXYcwCfXrPTxv9sMArSdCaaot7j3lQa
 N4oAn3C7jJdvhkbnSE8LpQ8UWiJlOee1
 =1CyF
 -END PGP SIGNATURE-

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: why not change type compare functions do a compare on strings as well?

2010-12-01 Thread Tim Robinson
Actually, it was one of the features I liked about Arc, which is built
on scheme.

That being said Arc doesn't have as many data type's or structures,
quite likely making it better suited for building generic functions,
most of which can be applied
across the majority of data types/structure's.

Clojure, on the other hand, has a plethora of options for data type/
structures and with that (I notice) comes with a small price tag -
often having create more code to handle  convert data more often.

Overall I really enjoy using Clojure and do have an appreciation for
it having the rich feature set (no pun intended with  a 'Rich feature
set') .
I know my girlfriend doesn't think my jokes are funny either. ^_^

 ...but they should be named something that doesn't carry so much
intuitive baggage already
Not sure I understand this. I hadn't realized there was pre-existing
baggage with the names, but I will defer.

On Dec 1, 5:54 pm, Ryan Sattler xgravi...@gmail.com wrote:
 I'd be highly dubious of this even if it was free, performance-wise. 
 and  are not clearly defined on strings and in general this kind of
 thing seems like an inroad for the kind of baffling implicit
 conversion-type behaviours you can see in PHP or JavaScript. Functions
 that do something like those in the OP might be useful, but they
 should be named something that doesn't carry so much intuitive baggage
 already.

 --
 Ryan Sattler

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: why not change type compare functions do a compare on strings as well?

2010-11-29 Thread Tim Robinson
I dunno,

Where is this arbitrary point people set where language improvements/
ease-of-use become less important than negligible performance impacts?
I ran several benchmarks, with warm up and correct time measurements,
and didn't get the impression the change was in anyway significant.

Take the existing function. I'm guessing 90+% of all usage is
comparing 2 items, or at least not needing to handle a list of
monotonically decreasing ordered items. Using the performance
argument,  I could suggest stripping out the (next more) check and
instead break it further down into 2 separate functions. And I would
also argue that handling strings, is a more valuable check than
handling monotonically decreasing ordered items.

Not trying to knock your comment, but unless there's more to your
comment not being shared, I'm not sold on it being a real issue.


On Nov 29, 7:45 am, Stuart Halloway stuart.hallo...@gmail.com wrote:
 Performance.

  why not change   type compare functions do a compare on strings as
  well?

  (defn 
     ([x] true)
   ([x y](if (string? x)
             (. clojure.lang.Numbers (isPos (.compareTo x y)))
             (. clojure.lang.Numbers (gt x y
   ([x y  more]
       (if ( x y)
         (if (next more)
             (recur y (first more) (next more))
             ( y (first more)))
         false)))

  (defn 
     ([x] true)
   ([x y](if (string? x)
             (. clojure.lang.Numbers (isNeg (.compareTo x y)))
             (. clojure.lang.Numbers (gt x y
   ([x y  more]
       (if ( x y)
         (if (next more)
             (recur y (first more) (next more))
             ( y (first more)))
         false)))

  It's just cleaner so we can do things like:

  user= ( 2010-06-11 2010-11-01)
  true

  user= ( Banana Apple)
  false

  make sense?

  Notes:
  * I ran a bunch of benchmarks, showing no real impact on performance.
  * probably would need to include = and = too.

  --
  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 from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: why not change type compare functions do a compare on strings as well?

2010-11-29 Thread Tim Robinson
huh? Making a change to the  function  doesn't mean you *can't* write
high performance data structures in Clojure. It just means, you *may*
need to use a different fn name as opposed to the common one.
Similarly I could simply use a different name to accomplish my own
function that includes strings, but that's not the point.

The point is that the common name should benefit the common user (not
typically the folks who appear in this group, but still representing
90+ percent of usage). Many people would benefit by having a cleaner
easy-to-use intuitive language. i.e '=' works on strings, so why not
'' ? It's not like I don't get the benefits listed, but I think this
group should also consider audiences outside the arena of expert
language programmers (who are capable of making functions to suit
their needs).  IMHO.

On Nov 29, 1:23 pm, David Nolen dnolen.li...@gmail.com wrote:
 On Mon, Nov 29, 2010 at 2:28 PM, Tim Robinson tim.blacks...@gmail.comwrote:

  I dunno,

  Where is this arbitrary point people set where language improvements/
  ease-of-use become less important than negligible performance impacts?
  I ran several benchmarks, with warm up and correct time measurements,
  and didn't get the impression the change was in anyway significant.

 Perhaps not significant to you. But to others it means that they can write
 high performance data structures in Clojure itself that other people can
 benefit from. To me that's far more compelling than convenient string
 comparison operators. Consider the implementation of 
 gvec.clj:https://github.com/clojure/clojure/blob/master/src/clj/clojure/gvec.clj.
  I
 wonder what negligible performance impact you change would have on that?

 It might more sense to put what you're suggesting in clojure.string.

 David

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: why not change type compare functions do a compare on strings as well?

2010-11-29 Thread Tim Robinson
I already do that, but that doesn't help general masses of people who
would benefit from consistent  intuitive language constructs.


On Nov 29, 5:57 pm, David Nolen dnolen.li...@gmail.com wrote:
 But the facilities for what you want are already there. Define a more
 generic   and exclude the ones from core.

 I'm constantly excluding fns from core which have names I'd rather use
 in my own source.

 David

 On Monday, November 29, 2010, Tim Robinson tim.blacks...@gmail.com wrote:
  huh? Making a change to the  function  doesn't mean you *can't* write
  high performance data structures in Clojure. It just means, you *may*
  need to use a different fn name as opposed to the common one.
  Similarly I could simply use a different name to accomplish my own
  function that includes strings, but that's not the point.

  The point is that the common name should benefit the common user (not
  typically the folks who appear in this group, but still representing
  90+ percent of usage). Many people would benefit by having a cleaner
  easy-to-use intuitive language. i.e '=' works on strings, so why not
  '' ? It's not like I don't get the benefits listed, but I think this
  group should also consider audiences outside the arena of expert
  language programmers (who are capable of making functions to suit
  their needs).  IMHO.

  On Nov 29, 1:23 pm, David Nolen dnolen.li...@gmail.com wrote:
  On Mon, Nov 29, 2010 at 2:28 PM, Tim Robinson 
  tim.blacks...@gmail.comwrote:

   I dunno,

   Where is this arbitrary point people set where language improvements/
   ease-of-use become less important than negligible performance impacts?
   I ran several benchmarks, with warm up and correct time measurements,
   and didn't get the impression the change was in anyway significant.

  Perhaps not significant to you. But to others it means that they can write
  high performance data structures in Clojure itself that other people can
  benefit from. To me that's far more compelling than convenient string
  comparison operators. Consider the implementation of 
  gvec.clj:https://github.com/clojure/clojure/blob/master/src/clj/clojure/gvec.clj.
   I
  wonder what negligible performance impact you change would have on that?

  It might more sense to put what you're suggesting in clojure.string.

  David

  --
  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 from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: why not change type compare functions do a compare on strings as well?

2010-11-29 Thread Tim Robinson
2. I agree with having both.

3.  Lol. I love that you asked your wife and kids that's where I
always go.

However, I don't think they represent a reasonable audience. When I
say the general  masses for intuition, I'm speaking about the average
programmer whom reasonably would want to compare things that
programmers typically compare:  ie. to handle stepping through
alphabetical names dynamically, or date-strings checks. It's not like
you couldn't do a google search on how to compare datestrings in Java
or Clojure and not find a bunch of Question/Answers addressing such.

Just my 2 cents.

The notion or   being used to handle string comparisons is not
foreign to programming languages, using them for the examples you
provided are.



On Nov 29, 7:40 pm, Stuart Halloway stuart.hallo...@gmail.com wrote:
 Reasonable people can certainly disagree here, but to elaborate on my earlier 
 reply:

 1. If you provide only a primitive feature, and users want a compound, they 
 can always create it for themselves. On the other hand, if you provide only a 
 compound, and the user wants the primitive, then they are screwed. So if you 
 are doing only one, the  answer, IMO, is clear.

 2. That said, one could have both, e.g. math/ and polymorphic/. Whether 
 this is a good idea might be explored through community experience. 
 Namespaces let you have both and use whichever one you prefer unadorned, and 
 contrib provides a place to give it a try.

 3. The appeal to intuition is perilous. I just explained the notion of a 
 string of characters to my wife and daughter (who are not  programmers) and 
 asked them if they thought  or  was meaningful for strings. They answered 
 Of course! and followed with some examples:

 ;; anybody knows this!
 ( seven eight)  

 ;; specificity
 ( green mint)

 ;; excellence
 ( poor good great)

 ;; descriptive uniqueness
 ( hattie the quick brown fox)

 One of the first things they said was Of course  and  of strings is only 
 meaningful in context.

 Stu

  huh? Making a change to the  function  doesn't mean you *can't* write
  high performance data structures in Clojure. It just means, you *may*
  need to use a different fn name as opposed to the common one.
  Similarly I could simply use a different name to accomplish my own
  function that includes strings, but that's not the point.

  The point is that the common name should benefit the common user (not
  typically the folks who appear in this group, but still representing
  90+ percent of usage). Many people would benefit by having a cleaner
  easy-to-use intuitive language. i.e '=' works on strings, so why not
  '' ? It's not like I don't get the benefits listed, but I think this
  group should also consider audiences outside the arena of expert
  language programmers (who are capable of making functions to suit
  their needs).  IMHO.

  On Nov 29, 1:23 pm, David Nolen dnolen.li...@gmail.com wrote:
  On Mon, Nov 29, 2010 at 2:28 PM, Tim Robinson 
  tim.blacks...@gmail.comwrote:

  I dunno,

  Where is this arbitrary point people set where language improvements/
  ease-of-use become less important than negligible performance impacts?
  I ran several benchmarks, with warm up and correct time measurements,
  and didn't get the impression the change was in anyway significant.

  Perhaps not significant to you. But to others it means that they can write
  high performance data structures in Clojure itself that other people can
  benefit from. To me that's far more compelling than convenient string
  comparison operators. Consider the implementation of 
  gvec.clj:https://github.com/clojure/clojure/blob/master/src/clj/clojure/gvec.clj.
   I
  wonder what negligible performance impact you change would have on that?

  It might more sense to put what you're suggesting in clojure.string.

  David

  --
  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 from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


why not change type compare functions do a compare on strings as well?

2010-11-28 Thread Tim Robinson
why not change   type compare functions do a compare on strings as
well?

(defn 
([x] true)
  ([x y](if (string? x)
(. clojure.lang.Numbers (isPos (.compareTo x y)))
(. clojure.lang.Numbers (gt x y
  ([x y  more]
  (if ( x y)
(if (next more)
(recur y (first more) (next more))
( y (first more)))
false)))

(defn 
([x] true)
  ([x y](if (string? x)
(. clojure.lang.Numbers (isNeg (.compareTo x y)))
(. clojure.lang.Numbers (gt x y
  ([x y  more]
  (if ( x y)
(if (next more)
(recur y (first more) (next more))
( y (first more)))
false)))


It's just cleaner so we can do things like:

user= ( 2010-06-11 2010-11-01)
true

user= ( Banana Apple)
false

make sense?

Notes:
* I ran a bunch of benchmarks, showing no real impact on performance.
* probably would need to include = and = too.

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Understanding clojure bindings

2010-11-27 Thread Tim Robinson
This works as I would expect it to.

'rule' brings in 'state' from the global binding into it's scope
giving it priority over the outer scope bindings found in the parent
function.

On Nov 27, 9:15 pm, Andreas Kostler andreas.koest...@leica-
geosystems.com wrote:
 Is this a 'bug' with eval?

 On 28 November 2010 14:09, Ken Wesson kwess...@gmail.com wrote:



  On Sat, Nov 27, 2010 at 10:42 PM, Andreas Kostler
  andreas.koestler.le...@gmail.com wrote:
   Hi all,
   Sorry for my noob question (again). I'm trying to understand clojures
   binding model.
   Typing:
   (def state {:status foo})
   (def rule '(if (= (:status sate) foo) (println foo) (println
   (bar)))

   (defn fn []
    (let [state {:status bar}]
      (eval rule)))

   This prints foo. However, I would have expected the binding of state
   created by let would shadow the global binding of state.
   Now

   (defn fn1 []
    (binding [state {:status bar}]
      (eval rule)))
   Does the right thing. Can someone explain what's going on here please?

  This is eval not seeing local bindings. There is a workaround:

  (defmacro eval-with-local-vars [vars sexp]
   (let [quoted-vars (vec (map #(list 'quote %) vars))]
    `(let [varvals# (vec (interleave ~quoted-vars ~vars))]
       (eval (list 'clojure.core/let varvals# ~sexp)

  user= (let [a 1 b 2] (eval-with-local-vars [a b] '(+ a b)))
  3
  user= (def state {:status foo})
  #'user/state
  user= (def rule
          '(if (= (:status state) foo)
             (println foo)
             (println bar)))
  #'user/rule
  user= (let [state {:status bar}]
          (eval rule))
  foo
  nil
  user= (let [state {:status bar}]
          (eval-with-local-vars [state] rule))
  bar
  nil

  --
  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 from this group, send email to
  clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

 --
 **
 Andreas Koestler, Software Engineer
 Leica Geosystems Pty Ltd
 270 Gladstone Road, Dutton Park QLD 4102
 Main: +61 7 3891 9772     Direct: +61 7 3117 8808
 Fax: +61 7 3891 9336
 Email: andreas.koest...@leica-geosystems.com

 www.leica-geosystems.com*

 when it has to be right, Leica Geosystems

 Please  consider the environment before printing this email.

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: REQUEST for feedback on http://clojure.org

2010-11-15 Thread Tim Robinson
The main page link to API is a little confusing/annoying.

I expect it to go here: http://clojure.org/api
( I expect this because doing a google search on clojure api brings
it up)

However the main page link to API goes directly to here:
http://clojure.github.com/clojure/

It's kind of annoying/confusing to new users, maybe instead have 2
links on the main page?

- Clojure API
- Clojure Contrib API

Tim





On Oct 30, 7:38 pm, Alex Miller alexdmil...@yahoo.com wrote:
 Hi all,

 I'm doing a bit of doc cleanup onhttp://clojure.organd I'd welcome
 your feedback on things that are broken or could be improved.  I'm not
 looking (or likely authorized :) to make any drastic changes but if
 there are things that you have run into, please drop a line here or in
 email to alexdmiller at yahoo.com.  Ideally, I'd like people to be
 logging tickets in jira, but I'm not sure it's quite ready for that
 yet.

 Some recent changes I've already made:
 - switched all of the old richhickey github references to clojure
 - cleaned up some factually wrong or out of date stuff on getting
 started and download pages
 - added Protocol and Datatypes pages to left nav (the pages have
 existed for 6 months)
 - added a page on starting a user group (still in review, not yet
 linked)
 - currently working on updating the cheat sheet to the 1.2 version
 (and adding links!)

 I'm particularly interested in:
 - new user groups or suggestions for the community page
 - stuff that is just wrong or out of date

 This DOES NOT include stuff in the API or Contrib autodoc pages.
 Please raise those issues or file tickets on those but that's not what
 I'm focusing on at the moment.

 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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: to macro or not?

2010-10-29 Thread Tim Robinson
 one is told to avoid macros as long as possible.

I've heard this before, but I believe it's intended to be interpreted
differently. I believe, it's meant to more like don't use them unless
you need them, which some people translate into avoid them. I have
heard, as a rule of thumb, that less than 5% of your code should be
macros. That's not to suggest they shouldn't be used, but rather to be
selective when using them. There are probably some people who love
them so much they're using them when it's not needed - resulting in
code being more complex than needed, therefore difficult to maintain.

 if you aren't using macros, then sorta why bother use a Lisp since you are 
 missing out on one of the most powerful differentiators. then

Very true.

 any way of teasing out when macros are ok?

I try writing code without macros, first, then I look at my code and
ask myself a few questions:

1. Can I create a macro which would make my code shorter and more
readable/mainatainable?
2. Are there areas in my code where performance matters and macro
logic could help in that regard?
   * This one's tricky since you really need to understand when
evaluations occur and if added complexity causes bad operations or
poor sequencing.

Recently I've been discovering that some macro's in a more verbose/
uglier/non-idiomatic, yet strategically structured form can sometimes
create 30 - 40% in run time savings. So for me, I've been challenging
my dependency upon the idiomatic, to see if I can improve things. *I
KNOW, I KNOW - Can you believe it? - Idiomatic code may not always be
the best way! *

^_^

Tim




-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Any Clojure2js Libraries?

2010-07-09 Thread Tim Robinson
Scriptjure will do just perfectly.

Thanks.
Tim

On Jul 8, 2:00 pm, Scott Jaderholm jaderh...@gmail.com wrote:
 Clojurescript is the only thing I know of like scheme2js. There are a
 couple parenscript like programs, the best 
 beinghttp://github.com/arohner/scriptjure

 Scott



 On Thu, Jul 8, 2010 at 1:17 PM, Tim Robinson tim.blacks...@gmail.com wrote:
  All I got from google was Clojurescript, but I'm wondering what
  options are out there.

  I was looking for something like scheme2js[1] only in Clojure.

  Thanks,
  Tim

  [1]http://www-sop.inria.fr/mimosa/scheme2js/

  --
  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 from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Any Clojure2js Libraries?

2010-07-08 Thread Tim Robinson
All I got from google was Clojurescript, but I'm wondering what
options are out there.

I was looking for something like scheme2js[1] only in Clojure.

Thanks,
Tim

[1] http://www-sop.inria.fr/mimosa/scheme2js/



-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Getting Clojure into the workplace, how do you do it?

2010-07-06 Thread Tim Robinson
I don't plan to let it stop me

(def typical-estimated-cost 5)

(defn propose-cost-with [choice]
(if  (= choice Clojure)
( * typical-estimated-cost .7)
 typical-estimated-cost))

 (propose-cost-with Clojure)
...

 (propose-cost-with Other)
...


In my opinion many large companies will chuck this out the door since
your cost does not represent the organizational cost, which depends
upon their ability to maintain your code [1] + no one ever gets fired
for picking Microsoft. For smaller companies not afraid of the dark,
or a start-up the above will work.

[1] Object-oriented programming is popular in big companies, because
it suits the way they write software. At big companies, software tends
to be written by large (and frequently changing) teams of mediocre
programmers. Object-oriented programming imposes a discipline on these
programmers that prevents any one of them from doing too much damage.
The price is that the resulting code is bloated with protocols and
full of duplication. This is not too high a price for big companies,
because their software is probably going to be bloated and full of
duplication anyway. - Paul Graham http://www.paulgraham.com/noop.html

Tim


On Jul 6, 9:48 am, Thomas Kjeldahl Nilsson
tho...@kjeldahlnilsson.net wrote:
 Nick,

 I'm not doing proper paid work in Clojure yet, but I convinced my department
 manager that learning Clojure on company time was ok. So that's a start at
 least. :)

 I used the concurrency features of Clojure as a main selling point, as well
 as the value of getting started early on in promising young
 languages/platforms. (high risk, high reward).

 --
 Med vennlig hilsen
 Thomas Kjeldahl Nilssonhttp://kjeldahlnilsson.net

 On Tue, Jul 6, 2010 at 10:50 AM, Nick Mudge mud...@gmail.com wrote:
  One of the things I like about Clojure is it is a way to get lisp and
  functional programming into workaday programming work; into the many
  places and businesses that use Java.

  I'd be very interested to hear stories or experiences of getting
  Clojure into the workplace and how it was done. That is, convincing
  customers and business people and other programmers that it is okay
  that you start doing your work in Clojure in your job. And similar
  such experiences.

  --
  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 from this group, send email to
  clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: How to: an anonymous recursive function

2010-07-01 Thread Tim Robinson
Hi folks,
I found some time this morning to look at this:

Mikes Letfn example worked out best for me:


(defmacro anaphoric-recur [parm-binds parms  body]
   An anaphoric recursive function that takes a vector of blind
bindable vars, parameters and a function that can handle the
bindable vars. 'self' is used to call the function recursively.
  `(letfn [(~'self ~parm-binds
 (do ~...@body))]
   (~'self ~parms)))

 (anaphoric-recur [x] 5 (if (= x 0) 1 (* 2 (self (dec x)
32

To answer Mike on CL or scheme?,
This is roughly equivalent to the arc 'afn' function (a scheme
variation).

Thanks everyone.
Tim

On Jun 30, 2:13 pm, Tim Robinson tim.blacks...@gmail.com wrote:
 Thanks for all the replies. Sorry if my responses are delayed. I'm
 still on newb moderation mode, so I find my response can take 2 - 10
 hours to be published.

  note that z is free in that expression, which looks suspicious.

 yup, it was supposed to be x. It was a copy paste error. I normally
 would evaluate the function, but in this case I was expecting errors.

 As for acc or other options, I was hoping to create a recursive fn
 that could generically accept an anonymous function as an argument,
 which was what I was
 thinking.

 Using a form like:

 ((recursive-fn #(do-stuff (self (dec %))) (recur self))  5)

 (obviously not the way - just the notion)

 kind of thing.

 When I am home tonight I can play aorund with the examples provided.

 Thanks,
 Tim

 On Jun 30, 8:59 am, Dominic Cooney dominic.coo...@gmail.com wrote:



  If you name the Y combinator, then you can write recursive anonymous 
  functions:

  http://rosettacode.org/wiki/Y_combinator#Clojure

  You can't use Clojure's recur as written because it isn't in tail
  position--the result of the function isn't just the value of the recur
  expression (in the first instance it is (* 2 (recur ...)) however I
  note that z is free in that expression, which looks suspicious.

  If your goal is to define a function that computes 2^n with
  tail-recursion, then consider threading an accumulator parameter
  through the recursive function; something like this:

  ((fun [acc x]
      (if (= x 0)
        acc
        (recur (* 2 acc) (dec x))) 1 5)

  Of course, you might consider a helper wrapper function that supplies
  the 1 default accumulator.

  Many functional languages optimize tail calls to jmp instructions;
  that's hard to do efficiently in general on the JVM because it doesn't
  support tail calls. I expect Clojure has designed recur to work the
  way it does because some algorithms depend on the tail call
  optimization, but the restrictions of recur make it possible to
  compile efficiently as a jmp. So it's a nice compromise.

  http://clojure.org/special_forms#SpecialForms--(recurexprs*)

  HTH,

  Dominic

  On Wed, Jun 30, 2010 at 2:44 PM, Tim Robinson tim.blacks...@gmail.com 
  wrote:
   So I am reading On Lisp + some blogs while learning Clojure (I know,
   scary stuff :)

   Anyway, I've been playing around to see if I can get an anonymous
   recursive function to work, but alas I am still a n00b and not even
   sure what Clojure's approach to this would be.

   How would I do this in Clojure?:

   My first attempt:

   ((fn [x]
     (if (= x 0)
         1
         (* 2 (recur (dec z) 5)

   Then my second:

   ((fn [x]
         (let [z (if (= x 0)
                     1
                     (* 2 x))]
            (recur (dec z  5)

   Ideally one could do:

   ((recursive-fn #( if (= % 0) 1 (* 2 %)) (recur it))  5)

   Obviously none work, and I believe I understand why. I just don't
   understand how to actually do this or if for some reason Clojure
   avoids this for some reason.

   I am not actually trying to accomplish a specific task, so the example
   was made to be simple not meaningful. I'm just playing around to learn
   recursive functions and Clojure style.

   Thanks,
   Tim

   --
   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 from this group, send email to
   clojure+unsubscr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: How to: an anonymous recursive function

2010-07-01 Thread Tim Robinson
and now  corrected!

(defmacro anaphoric-recur [parm-binds expr  parms]
An anaphoric recursive function that takes a vector of blind
 bindable vars, an expression that can handle the bindable vars.
 and the parameters. 'self' is used to call the function
recursively.
  `(letfn [(~'self ~parm-binds
 (do ~expr))]
   (~'self ~...@parms)))

 (anaphoric-recur [x] (if (= x 0) 1 (* 2 (self (dec x 5)
32

On Jun 30, 2:13 pm, Tim Robinson tim.blacks...@gmail.com wrote:
 Thanks for all the replies. Sorry if my responses are delayed. I'm
 still on newb moderation mode, so I find my response can take 2 - 10
 hours to be published.

  note that z is free in that expression, which looks suspicious.

 yup, it was supposed to be x. It was a copy paste error. I normally
 would evaluate the function, but in this case I was expecting errors.

 As for acc or other options, I was hoping to create a recursive fn
 that could generically accept an anonymous function as an argument,
 which was what I was
 thinking.

 Using a form like:

 ((recursive-fn #(do-stuff (self (dec %))) (recur self))  5)

 (obviously not the way - just the notion)

 kind of thing.

 When I am home tonight I can play aorund with the examples provided.

 Thanks,
 Tim

 On Jun 30, 8:59 am, Dominic Cooney dominic.coo...@gmail.com wrote:



  If you name the Y combinator, then you can write recursive anonymous 
  functions:

  http://rosettacode.org/wiki/Y_combinator#Clojure

  You can't use Clojure's recur as written because it isn't in tail
  position--the result of the function isn't just the value of the recur
  expression (in the first instance it is (* 2 (recur ...)) however I
  note that z is free in that expression, which looks suspicious.

  If your goal is to define a function that computes 2^n with
  tail-recursion, then consider threading an accumulator parameter
  through the recursive function; something like this:

  ((fun [acc x]
      (if (= x 0)
        acc
        (recur (* 2 acc) (dec x))) 1 5)

  Of course, you might consider a helper wrapper function that supplies
  the 1 default accumulator.

  Many functional languages optimize tail calls to jmp instructions;
  that's hard to do efficiently in general on the JVM because it doesn't
  support tail calls. I expect Clojure has designed recur to work the
  way it does because some algorithms depend on the tail call
  optimization, but the restrictions of recur make it possible to
  compile efficiently as a jmp. So it's a nice compromise.

  http://clojure.org/special_forms#SpecialForms--(recurexprs*)

  HTH,

  Dominic

  On Wed, Jun 30, 2010 at 2:44 PM, Tim Robinson tim.blacks...@gmail.com 
  wrote:
   So I am reading On Lisp + some blogs while learning Clojure (I know,
   scary stuff :)

   Anyway, I've been playing around to see if I can get an anonymous
   recursive function to work, but alas I am still a n00b and not even
   sure what Clojure's approach to this would be.

   How would I do this in Clojure?:

   My first attempt:

   ((fn [x]
     (if (= x 0)
         1
         (* 2 (recur (dec z) 5)

   Then my second:

   ((fn [x]
         (let [z (if (= x 0)
                     1
                     (* 2 x))]
            (recur (dec z  5)

   Ideally one could do:

   ((recursive-fn #( if (= % 0) 1 (* 2 %)) (recur it))  5)

   Obviously none work, and I believe I understand why. I just don't
   understand how to actually do this or if for some reason Clojure
   avoids this for some reason.

   I am not actually trying to accomplish a specific task, so the example
   was made to be simple not meaningful. I'm just playing around to learn
   recursive functions and Clojure style.

   Thanks,
   Tim

   --
   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 from this group, send email to
   clojure+unsubscr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


How to: an anonymous recursive function

2010-06-30 Thread Tim Robinson
So I am reading On Lisp + some blogs while learning Clojure (I know,
scary stuff :)

Anyway, I've been playing around to see if I can get an anonymous
recursive function to work, but alas I am still a n00b and not even
sure what Clojure's approach to this would be.

How would I do this in Clojure?:

My first attempt:

((fn [x]
   (if (= x 0)
   1
   (* 2 (recur (dec z) 5)

Then my second:

((fn [x]
   (let [z (if (= x 0)
   1
   (* 2 x))]
  (recur (dec z  5)

Ideally one could do:

((recursive-fn #( if (= % 0) 1 (* 2 %)) (recur it))  5)


Obviously none work, and I believe I understand why. I just don't
understand how to actually do this or if for some reason Clojure
avoids this for some reason.

I am not actually trying to accomplish a specific task, so the example
was made to be simple not meaningful. I'm just playing around to learn
recursive functions and Clojure style.

Thanks,
Tim



-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: How to: an anonymous recursive function

2010-06-30 Thread Tim Robinson
Thanks for all the replies. Sorry if my responses are delayed. I'm
still on newb moderation mode, so I find my response can take 2 - 10
hours to be published.

 note that z is free in that expression, which looks suspicious.

yup, it was supposed to be x. It was a copy paste error. I normally
would evaluate the function, but in this case I was expecting errors.

As for acc or other options, I was hoping to create a recursive fn
that could generically accept an anonymous function as an argument,
which was what I was
thinking.

Using a form like:

((recursive-fn #(do-stuff (self (dec %))) (recur self))  5)

(obviously not the way - just the notion)

kind of thing.

When I am home tonight I can play aorund with the examples provided.

Thanks,
Tim





On Jun 30, 8:59 am, Dominic Cooney dominic.coo...@gmail.com wrote:
 If you name the Y combinator, then you can write recursive anonymous 
 functions:

 http://rosettacode.org/wiki/Y_combinator#Clojure

 You can't use Clojure's recur as written because it isn't in tail
 position--the result of the function isn't just the value of the recur
 expression (in the first instance it is (* 2 (recur ...)) however I
 note that z is free in that expression, which looks suspicious.

 If your goal is to define a function that computes 2^n with
 tail-recursion, then consider threading an accumulator parameter
 through the recursive function; something like this:

 ((fun [acc x]
     (if (= x 0)
       acc
       (recur (* 2 acc) (dec x))) 1 5)

 Of course, you might consider a helper wrapper function that supplies
 the 1 default accumulator.

 Many functional languages optimize tail calls to jmp instructions;
 that's hard to do efficiently in general on the JVM because it doesn't
 support tail calls. I expect Clojure has designed recur to work the
 way it does because some algorithms depend on the tail call
 optimization, but the restrictions of recur make it possible to
 compile efficiently as a jmp. So it's a nice compromise.

 http://clojure.org/special_forms#SpecialForms--(recur exprs*)

 HTH,

 Dominic

 On Wed, Jun 30, 2010 at 2:44 PM, Tim Robinson tim.blacks...@gmail.com wrote:
  So I am reading On Lisp + some blogs while learning Clojure (I know,
  scary stuff :)

  Anyway, I've been playing around to see if I can get an anonymous
  recursive function to work, but alas I am still a n00b and not even
  sure what Clojure's approach to this would be.

  How would I do this in Clojure?:

  My first attempt:

  ((fn [x]
    (if (= x 0)
        1
        (* 2 (recur (dec z) 5)

  Then my second:

  ((fn [x]
        (let [z (if (= x 0)
                    1
                    (* 2 x))]
           (recur (dec z  5)

  Ideally one could do:

  ((recursive-fn #( if (= % 0) 1 (* 2 %)) (recur it))  5)

  Obviously none work, and I believe I understand why. I just don't
  understand how to actually do this or if for some reason Clojure
  avoids this for some reason.

  I am not actually trying to accomplish a specific task, so the example
  was made to be simple not meaningful. I'm just playing around to learn
  recursive functions and Clojure style.

  Thanks,
  Tim

  --
  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 from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojure's n00b attraction problem

2010-06-29 Thread Tim Robinson
Being a n00b, 1 year programming, not formally educated in such, 2
weeks with Clojure
I am going to agree. Clojure is NOT n00b friendly. The easiest setup I
have ever seen dealt with is python.

* Most n00bs want a hello world in an application output (via script
or compojure). Not in a repl. The repl is a tool to get you there. In
order to do this users should really have a 7 step guide on leinington
and optionally compojure, unfortunately it's so poorly documented and
incorrectly documented it's frustrating for n00bs. In my case I
thought I was downloading the current version @4.0, which quite
frankly bites because it won't run version 1.2 clojure, which most
blogs use functions from. And almost every blog/doc on leinington is
old omits/incorrectly states basic steps.(ie they walk you all the way
through to lein uberjar, but don't actually put a namespace in the
project.clj example), therefore none of the classes compile). If
you're on macsox, and get the namespaces down even then the current
leinington release barfs on DS_store files (the hot to trot release
doesn't however).

Quite frankly I love Clojure, but I TOTALLY agree - The clojure world
is not stable even if clojure core is.

The thing is that it's S close. After days of sifting through all
the BS, I don't know why we couldn't have the relevant 7 easy steps
documented linked from the front page of clojure.org. To do so however
still requires all the bleeding edge versions.

My 2 cents.
Tim







On Jun 27, 3:58 pm, Greg g...@kinostudios.com wrote:
 This weekend I've been diving head-first into Clojure, and I've documented a 
 lot of the sticking points that I've run into as a n00b.

 I'd like to share them with the community here, in the hopes that we might be 
 able to improve the getting started experience for people considering Clojure:

 http://gregslepak.posterous.com/clojures-n00b-attraction-problem

 In the post I cover issues with:

 - Obtaining Clojure
 - Running Clojure
 - IDEs
 - Emacs/VIM
 - Build systems
 - Documentation

 Cheers,
 Greg

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Duplicate key bug in hash-maps

2010-06-27 Thread Tim Robinson
Can I change the title to:

Duplicate key error handling feature in hash-sets ?

I was using the '#'  thinking it was short for a hash-map, rather than
a hash-set.

Clojure has more data structures available than I'm used to working
with.
So thanks for the error handling.

Tim


On Jun 25, 9:37 am, Stuart Halloway stuart.hallo...@gmail.com wrote:
 I think there are two important considerations in favor of how it works now:

 (1) The common case presumptions (which admittedly may need to be learned).

 (2) The need for both flavors. If there wasn't a flavor that rejected 
 duplicate keys, somebody would surely ask for it.

 Add to these considerations the names of the functions already in play, and 
 you get the implementation you see.



  On Fri, 25 Jun 2010 10:31:57 -0400
  Stuart Halloway stuart.hallo...@gmail.com wrote:

  Duplicate keys in maps/sets are disallowed in literals and factory 
  functions, where data is generally literal  inline and therefore likely 
  represents coder error:

  ; all disallowed
  #{:a :a}
  {:a 1 :a 2}
  (hash-map :a 1 :a 2)
  (hash-set :a :a)

  Maps I can see being an error - you lose data in the process.

  However, since you can plug variables of unknown provenance into
  either the constructor or the literal, that's liable to create a nasty
  surprise for someone at some point.

  user= (def a :a)
  #'user/b
  user= (def b :a)
  #'user/b
  user= (hash-set a b)
  java.lang.IllegalArgumentException: Duplicate key: :a (NO_SOURCE_FILE:6)
  user= #{a b}
  java.lang.IllegalArgumentException: Duplicate key: :a (NO_SOURCE_FILE:0)
  user=

  They are allowed in other contexts, where the data could come from 
  anywhere:

  It could come from anywhere in the two forbidden contexts as well.

  ; dumb, but these forms not generally called with a literal
  (set [:a :a])
  (into #{} [:a :a])

  I find this behavior consistent and easy to explain, but I was involved in 
  the design conversation so maybe I have participant blindness. :-)

  My initial reaction was that's a bit odd, but probably a good idea.
  However, given that I can use variables inside the literal and
  constructor, I'm leaning the other way.

  Or is (set [a b c]) idiomatic usage in this case, and (hash-set a b c)
  or #{a b c} to be avoided?

    mike
  --
  Mike Meyer m...@mired.org              
  http://www.mired.org/consulting.html
  Independent Network/Unix/Perforce consultant, email for more information.

  O ascii ribbon campaign - stop html mail -www.asciiribbon.org

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Duplicate key bug in hash-maps

2010-06-25 Thread Tim Robinson
I tried Clojure via Githhub today.

Anyone notice this bug that hadn't existed in Version 1.1

user= #{:item1 {:a A :b B} :item2 {:a A :b B}}
java.lang.IllegalArgumentException: Duplicate key: {:a A, :b B}

Tim

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Is it possible to define custom atom/data types?

2010-06-24 Thread Tim Robinson
Is it possible to define custom atom/data types?

Example: I would like an atom prefixed with $ to maintain it's own
type/class.

i.e.
 (class $myatom)
clojure.lang.CustomeName

Thanks,
Tim

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Is it possible to define custom atom/data types?

2010-06-24 Thread Tim Robinson
Thanks! I think that should do it for me.

I've been writing my own custom *semi* JSON parser/combinator (JSON
only hacked to  let me to include js functions).
My first cut works, but I had implemented string searches for js
qualifiers. I didn't like the implementation since it string searches
every string, js-fn or not.
And since I have to check type already I can use that without adding
any real overhead.

Thanks.
Tim


On Jun 24, 11:42 am, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 Am 24.06.2010 um 07:36 schrieb Tim Robinson:

  Is it possible to define custom atom/data types?

  Example: I would like an atom prefixed with $ to maintain it's own
  type/class.

  i.e.
  (class $myatom)
  clojure.lang.CustomeName

 You can use the old way of defining types: by adding a tag to the metadata 
 of the atom.

 user= (def a (atom nil :meta {:type ::MyType}))
 #'user/a
 user= (type a)
 :user/MyType
 user= (def b (atom nil))
 #'user/b
 user= (type b)
 clojure.lang.Atom

 Sincerely
 Meikel

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: State of Clojure web development

2010-06-24 Thread Tim Robinson


1. Have you written, or are you writing, a web application that uses
Clojure? What does it do?

I am new to Clojure, I've ported over most of my code for an ad-hoc
application creator / with reporting and GIS integration.
I'm pretty much finished. I benchmarking speed.

2. Which libraries or frameworks are you using? Which versions?

My own custom frameworks. I use some contrib stuff.

3. What made you choose Clojure to develop web applications in? What
are the strengths of Clojure web development?

Strengths:
* Allows for creating succinct code to manage complex data.
* Access to many libraries (that are current and active).
* Not forced to include BS code for OO abstractions.

Weakness:

REPL errors. Seems fragile. If I hit an error, some errors corrupt
something under the hood,
ie. reloading the corrections doesn't help I have to close the REPL
then restart.
I'm familiar with REPLs - This is odd, but it's probably a JVM issue.

4. What do you think are the current weaknesses of web development in
Clojure? What could be improved?

Nothing big yet.

5. Anything else you want to comment on?

Only one week into Clojure I could be too green, but:

I would like some chaining to less the brackets.
i.e.

 (def stuff {:key1 {:item1 {:sub1 val1}})
 (((stuff :key1) :item1) sub1)  --- YUCK
val1

Instead do this:
 stuff:key1:item1:sub1
val1

Also, some of the function names don't make sense:
(def stuff (list 1 2 3 4 5))
 (rest stuff)
(2 3 4 5)
 (next stuff)
(2 3 4 5)  this can be done with rest.

In my mind 'next' should:
 (next stuff)
2
 (next 2 stuff)
(2 3)

etc etc..

Tim
On Jun 23, 3:23 pm, James Reeves weavejes...@googlemail.com wrote:
 Hello there!

 Chas Emerick's recent State of Clojure survey [http://bit.ly/dtdAwb]
 indicated that a significant proportion of Clojure users are beginning
 to use Clojure for web development. A recent Hacker News posting
 [http://bit.ly/91Bu5J] seems to corroborate these results, with
 several Clojure-based web applications already out in the wild.

 As one of the main developers of Ring and Compojure, I'd be very
 interested to hear more about how people are using Clojure to build
 web apps. To this end, I have a few questions I'd like to quiz Clojure
 web developers about:

 1. Have you written, or are you writing, a web application that uses
 Clojure? What does it do?

 2. Which libraries or frameworks are you using? Which versions?

 3. What made you choose Clojure to develop web applications in? What
 are the strengths of Clojure web development?

 4. What do you think are the current weaknesses of web development in
 Clojure? What could be improved?

 5. Anything else you want to comment on?

 Please reply to this thread with your answers, and thank you very much
 in advance for your time. I really appreciate any feedback you can
 provide.

 - James

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: State of Clojure web development

2010-06-24 Thread Tim Robinson

Thanks for both the replies.

(get-in m [:key1 :item1 :sub1]) --- YUM ;)

(- stuff :key1 :item1 sub1)

are better than what I've been doing!

Re: (next...)

I still like mine better, fortunately I can create my own functions,
but I was just highlighted that some of the function names are not
intuitive (to me).
Most of them are good.

Along this vein, I find the documentation is great, but a little hard
to navigate around.
Example to find a list of predicates requires hunting. Is there a
trick?  I know ' source' and 'find-doc', but I'm constantly
searching :)
This is a really niggly point since relatively speaking it's well
done.

As I said, I'm green. I'll get there soon I promise :)

Tim



On Jun 24, 1:48 pm, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 Am 24.06.2010 um 21:12 schrieb Tim Robinson:

  I would like some chaining to less the brackets.
  i.e.

  (def stuff {:key1 {:item1 {:sub1 val1}})
  (((stuff :key1) :item1) sub1)  --- YUCK
  val1

  Instead do this:
  stuff:key1:item1:sub1
  val1

 (- stuff :key1 :item1 sub1)

  Also, some of the function names don't make sense:
  (def stuff (list 1 2 3 4 5))
  (rest stuff)
  (2 3 4 5)
  (next stuff)
  (2 3 4 5)  this can be done with rest.

 next and rest are not the same. Seehttp://clojure.org/lazy.

 Sincerely
 Meikel

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: I am unclear on how I can call an Ifn stored in a map usefully

2010-06-23 Thread Tim Robinson
Perfect! And Thanks!
Tim
On Jun 22, 7:00 pm, Michał Marczyk michal.marc...@gmail.com wrote:
 Firstly, consider using Delays rather than IFn. See (doc delay) and
 (doc delay?). In Clojure, many sorts of things are IFns, including
 (among others) sets, vectors and maps, and you probably don't want to
 call those.

 (def uhoh* (ref {:event {:date (delay (java.util.Date.)) :name EOW}}))
 (def why* (ref {:event {:stuff ELI}}))

 Then you could do something like

 (def current*
            (zipmap (mapcat keys [(uhoh* :event) (why* :event)])
                    (mapcat #(- % vals
                                  (map (fn [item] (if (delay? item)
 @item item
                            [(uhoh* :event) (why* :event)])))

 If you really want to use IFns and not Delays, change (delay? item) to
 (ifn? item) and @item to (item).

 For more general tree walking, see clojure.walk. E.g.

 (def current*
      (walk/prewalk #(if (delay? %) @% %)
                    (merge (uhoh* :event)
                           (why* :event

 will give you the same thing.

 Sincerely,
 Michał

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


I am unclear on how I can call an Ifn stored in a map usefully

2010-06-22 Thread Tim Robinson
Hello Folks,

I'm a noob to both programming (1 year part-time) and to Clojure (1
week).

I am unclear on how I can call an Ifn stored in a map usefully
and I am hoping you can help me.

I have stored data in a few maps (both functions and data):

   user= (def uhoh* (ref {:event {:date #(date) :name EOW}}))
   #'user/uhoh*

user= (def why* (ref {:event {:stuff ELI}}))
#'user/why*

I call the key having a string:

user= ((uhoh* :event) :name)
EOW

sweet!

I call the key having an Ifn:

user= ((uhoh* :event) :date)
#user$fn__2476 user$fn__2...@273f212a

hm. not what I wanted!
let's try this another way:

user= (((uhoh* :event) :date))
Tue 22 Jun 2010 17:41:23 MDT
nil

sweet!

let's pull my maps together:

user=(def current* (merge (uhoh* :event)(why* :event)))
#'user/current*

here's my problem:

user= current*
{:stuff ELI, :date #user$fn__2507
user$fn__2...@4fa3551c, :name EOW}

I was hoping this kind of a call would yield:

 {:stuff ELI, :date Tue 22 Jun 2010 17:45:32 MDT, :name
EOW}

I need the date representing the time I assign the def (evaluated at
call time) and I don't know which keys will have an Ifn or just a
string etc.

Is there existing falicilites to make this happen? An existing
function call perhaps not obvious to me? Or do I need to write custom
loops to cycle through and handle each item?

Thanks,
Tim

-- 
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 from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en