Re: how to packge lein project in a maven-style?

2014-01-06 Thread Qiu Xiafei
yes, lein-libdir help copy depencencies, maybe i have to copy other
resource files by hand.


On Tue, Jan 7, 2014 at 12:34 AM, Chris Jeris  wrote:

> https://github.com/djpowell/lein-libdir may do what you want for
> assembling dependencies.
>
> peace, Chris Jeris
>
>
> On Mon, Jan 6, 2014 at 12:33 AM, Qiu Xiafei  wrote:
>
>>
>>
>> Using maven, we usually package the project in a directory with sub dirs
>> like:
>> bin/ # bash/python scripts
>> lib/  # all jars
>> conf/   # resources/configuration files
>>
>> And, we often use the *maven-dependency-plugin* to copy dependency jars
>> and use the *maven-resources-plugin* to copy scripts and other resource
>> files. But I find no alernertives in lein.
>>
>> Is there any lein plugin can help me about this?
>>
>> thanks!
>>
>>  --
>> --
>> 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 unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> --
> Chris Jeris
> cje...@brightcove.com
> freenode/twitter/github: ystael
>
> --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


how to packge lein project in a maven-style?

2014-01-05 Thread Qiu Xiafei
Using maven, we usually package the project in a directory with sub dirs
like:
bin/ # bash/python scripts
lib/  # all jars
conf/   # resources/configuration files

And, we often use the *maven-dependency-plugin* to copy dependency jars and
use the *maven-resources-plugin* to copy scripts and other resource files.
But I find no alernertives in lein.

Is there any lein plugin can help me about this?

thanks!

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: newbie question: how to include external libraries from Leiningen REPL

2013-11-07 Thread Qiu Xiafei
you may have a look at alembic: https://github.com/pallet/alembic

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to type hint a String array?

2013-10-09 Thread Qiu Xiafei
Thanks, Jim.


On Wed, Oct 9, 2013 at 9:27 PM, Jim - FooBar(); wrote:

> On 09/10/13 14:12, Jim - FooBar(); wrote:
>
>> ps: also, non-primitive arrays are hinted like this if I'm not mistaken:
>> #^"[Ljava.lang.String;"
>>
>
> actually you can use both #^ & ^ in regular 'defn'
>
> Jim
>
>
>
>
>
>
>
> --
> --
> 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+unsubscribe@**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 unsubscribe from this group and stop receiving emails from it, send an
> email to 
> clojure+unsubscribe@**googlegroups.com
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out
> .
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


How to type hint a String array?

2013-10-09 Thread Qiu Xiafei
Clojure provide built-in type hint for primitive types such as: ^ints,
^doubles, but how to type hint an array of arbitrary Class?
The following way dosn't work, too:

user=> (definterface MyInterface
  #_=>  (^"[Ljava.lang.String" method1 []))
user.MyInterface
user=> (.method1 (reify MyInterface (^"[Ljava.lang.String;" method1 [this]
)))

CompilerException java.lang.NoClassDefFoundError: [Ljava/lang/String,
compiling:(NO_SOURCE_PATH:1:11)



thanks!

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Ambiguous error message with lazy sequence.

2013-08-06 Thread Qiu Xiafei
I have a test.clj file like the following:

$ cat test.clj
(defn some-lazy-seq [n]
  (lazy-cat
 (concat n;; should be [n] here
 (some-lazy-seq (inc n)
(println (take 100 (some-lazy-seq 0)))

It's obviously wrong on line 3, the concat function shoud take a seq as
first argments.

But when i run this file, the error is reported on line 5, where the
function is invocated, but not on where it's ocurred. It's really hard to
locate the bug espacially in big project.

Any suggestions to avoid this kind of error message or better solutioins?

thanks!

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Get digits of a number

2013-01-20 Thread Qiu Xiafei
yes... it would be better.

On Sun, Jan 20, 2013 at 2:30 AM, David Brown  wrote:

> Qiu Xiafei  writes:
>
> > (defn num->digits
> >   [num]
> >   (loop [n num res []]
> > (if (zero? n)
> >   res
> >   (recur (long (/ n 10)) (cons (mod n 10) res)
>
> How about  (quot n 10)  instead of (long (/ n 10))?  No sense in the
> extra step.
>
> 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: Get digits of a number

2013-01-19 Thread Qiu Xiafei
(defn num->digits
  [num]
  (loop [n num res []]
(if (zero? n)
  res
  (recur (long (/ n 10)) (cons (mod n 10) res)

在 2011年2月17日星期四UTC+8下午1时29分10秒,Andreas Kostler写道:
>
> Is there an easy and idiomatic way of getting the digits of a number in 
> clojure?
>
> (defn explode-to-digits [number]
> (map #(- (int %) (int \0)) (str number)))
> (explode-to-digits 123456)
> => (1 2 3 4 5 6)
>
> Seems a bit clunky...
> Andreas
>
>
>

-- 
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: Searching for a picture

2012-12-28 Thread Qiu Xiafei
good job!! thanks a lot!


On Fri, Dec 28, 2012 at 9:39 PM, Mayank Jain  wrote:

> Nice :)
>
> On Fri, Dec 28, 2012 at 3:26 PM, Sébastien Wagener
>  wrote:
> > Hi, you probably mean this:
> > http://machinegestalt.posterous.com/if-programming-languages-were-cars
> >
> >
> > 2012/12/28 Qiu Xiafei 
> >>
> >> I'am preparing an introduce of clojure to my colleague.
> >> I remember that there's a picture showing that clojure = java + lisp,
> the
> >> picture must be a good example in my keynote, I think I should refer to
> it.
> >> In that picture, java is like a powful SUV with very big wheels, lisp is
> >> like a cool sedan with two "wings", and clojur is like a monster car
> with
> >> big wheels and wings.
> >> So forget where i saw the picture last time, it seems in some one's
> >> lecture.
> >> I will be very priciate if u knonw it, Thanks!
> >>
> >> --
> >> 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
>
>
>
> --
> Regards,
> Mayank.
>
> --
> 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

Searching for a picture

2012-12-27 Thread Qiu Xiafei
I'am preparing an introduce of clojure to my colleague.
I remember that there's a picture showing that clojure = java + lisp, the
picture must be a good example in my keynote, I think I should refer to it.
In that picture, java is like a powful SUV with very big wheels, lisp is
like a cool sedan with two "wings", and clojur is like a monster car with
big wheels and wings.
So forget where i saw the picture last time, it seems in some one's lecture.
I will be very priciate if u knonw it, Thanks!

-- 
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

[ANN] zk-web 1.0 release

2012-11-18 Thread Qiu Xiafei
zk-web is a Web UI of Zookeeper , just making
it easier to use. It helps you read stat and data of a zookeeper node, and
logged in user can add/modify/delete/rmr a node. I hope zk-web could help
you.

zk-web is hostd on github: https://github.com/qiuxiafei/zk-web

This is also my first clojure project, I think I'm falling love this this
magic language!

thanks!

-- 
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: A tutorial for how to setup your clojure development environment for: Emacs, Leiningen and Linux.

2012-06-22 Thread Qiu Xiafei
p.s. I think idea + la enclosure works quite wellwhy beginners are
always introduced to emacs solution?

On Sat, Jun 23, 2012 at 4:45 AM, fenton  wrote:

> Hi Brad, I've updated my doc with your questions.  Here is how I responded
> to your particular queries.  Note the answer may not be correct as I'm a
> clojure newbie myself.
>
> -
>
> Leiningen is a build tool like maven for java, or rake (i think) for
> ruby.  You can use it to publish your jar into maven repositories for
> example.
>
> Slime is a protocol that lets you communicate from emacs to a
> listening server.  In clojure, we start a swank server, which is the
> clojure REPL process, and connect to it from emacs, speaking 'slime'.
> The net effect is that we can have a REPL inside our emacs editor.
>
> -
>
>
> On Thursday, June 21, 2012 5:58:23 PM UTC-7, brad bowman wrote:
>>
>> On Thursday, June 21, 2012 12:58:19 PM UTC+10, John Gabriele wrote:
>>>
>>> On Jun 18, 10:23 pm, Chris Zheng  wrote:
>>> > {snip}
>>> > So basically, if a 'lead clojure evangelist' can either 'officially'
>>> or
>>> > 'unofficially' recommend ONE emacs setup, along with a bunch of
>>> > videos/tutorials that demonstrate how to code and how fast it is to
>>> design
>>> > and code using the repl. Then that be enough to get people at least
>>> > interested.
>>>
>>> People are very opinionated about their editor/IDE. I think the Getting
>>> +Started docs are good --- they separate:
>>>
>>>   * if you want just Emacs plus the repl, here you go (clojure-mode
>>> readme)
>>>   * if you want Emacs + inferior-lisp, do this (this doc needs work)
>>>   * if you want Emacs + swank/slime, do this (swank-clojure readme)
>>>
>>> and of course also info on Eclipse, Clooj, and other editors/ide's as
>>> well.
>>>
>>
>> I'm right at the start of this process, completely unfamiliar with
>> Clojure,
>> Leiningen, Emacs, Java and all of the projects with cute names.
>> I don't even know what I want.
>>
>> I've cut and pasted various git-clone and lein commands, but have no idea
>> about the bigger picture.  I'm happy to dawdle along on my own, but if my
>> current (and hopefully temporary) ignorance can provide feedback on a
>> start-up guide then let me know.
>>
>> At present I'm often wondering "what is this thing? why do I want it?".
>> Slime for example.  I don't especially want answers here, but something
>> like
>> a glossary for the clojure ecosystem would be handy (not that I've looked
>> hard).
>>
>> Another document that might useful is a platform Rosetta stone
>> matching clojure tools and libraries to those that fill a similar role in
>> other
>> languages (Java and Ruby for starters).  This is more of a "nice to have".
>>
>> Thanks,
>>
>> Brad
>>
>  --
> 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: A tutorial for how to setup your clojure development environment for: Emacs, Leiningen and Linux.

2012-06-13 Thread Qiu Xiafei
how about add something about auto completion, it's pretty useful for
working around large project or java interop.

On Thu, Jun 14, 2012 at 9:27 AM, fenton  wrote:

> I totally understand the value of having a single source of truth (DRY
> principle).  My main problem was that to get from 0-60 for doing clojure
> development is quite challenging.
>
> Say you want to do what my document describes, that is setup Leiningen,
> setup emacs, etc..., it took me weeks to get it working.  That is going to
> turn off a lot of people who'd like to get started.
>
> I'm sure I've made many misguided recommendations, I'm a newbie myself.
>  But I've been tasked to help other people get on board with Clojure and I
> need to be able to send them to one link.
>
> I had a major piss around trying to get the marmelade repo working.
>  Finally, someone suggested emacs 24, which itself is fairly hard to find
> without a link to alpa.
>
> So say I start at: http://marmalade-repo.org/, well then it says:
> "Install package.el", it doesn't say how to install package.el, so now I
> gotta google that.  So say eventually I figure that out.  Well it says to
> add it to your ~/.emacs.  I was helping someone out the other day, and in
> their instance it needed to go into ~/.emacs.d/init.el.  Another face
> plant.  Then if they aren't on emacs 24, there is a chance that their 23
> won't load more than one repo, that happened to me.  Face plant.  Then I
> head over to lein: https://github.com/technomancy/leiningen, well this
> one is better than most install instructions, but still IMO, isn't as
> simple to follow as my instructions.  Which I'd agree I should update to
> use Lein 2.  However it doesn't talk about the dependencies of Lein, like
> rlwrap, since understandably that is out of scope, but for a newbie, it's
> darn handy to have that stuff.  Say you were running the jre instead of the
> jdk, which I was, and my swank-cdt debugger wasn't working, again I have a
> note for that.  Then we get back to marmalade.  The steps to install
> package.el are quite a few.  You should put ~/.emacs.d/ on your load path,
> you've got to (require 'package).  It doesn't mention anything about
> (package-initialize), which seems to be helpful.  Next I want to get
> swank-slime-clojure server going.  Do I need slime?  I don't really know.
>  So I head over to: https://github.com/technomancy/swank-clojure, which
> is not bad, but it doesn't tell me that I have to do a 'lein deps' after I
> put the entry into my emacs.  It doesn't tell me that if I jack-in and then
> modify my project.clj that I need to re-jack-in.  Face plant.  I still
> don't know if I need both clojure and clojure-contrib in my project.clj
> files or not.  They are different versions, should they be in sync?  After
> that I don't even know where I found the info about how to setup my *.clj
> files so that they'd auto load into the REPL after saving them, certainly
> another website.  Did it also have the nice tip that: "C-c A-p" is what you
> can use to update the namespace in your REPL.  Now I want debugging, off to
> somewhere else.  Here: http://georgejahad.com/clojure/swank-cdt.html.
>  Well it doesn't tell me that swank-clojure is NOT a plugin, but rather a
> dependency.  Face plant.  Didn't help with JDK/JRE issue.
>
> And I'm not even listing all the other issues which would bore anyone on
> this list to tears.  Maybe an appropriate solution is the one you alluded
> to, which is to have a link to the websites I mentioned about at each point
> in the 0-60 doc?
>
> I did find myself getting a bit angry writing this, because I'd really
> like to see clojure displace java, but I think its fair to say that there
> is a gap in helping people who have little
> emacs/clojure/leiningen/swank/slime/cdt/lisp exposure getting on board.  I
> think there is value in reducing that complexity as far as possible to let
> them get going doing some coding.
>
> I think github is a better place to document this stuff than confluence.
>  Confluence just doesn't have the prettifying abilities of github.  Also,
> whats the right solution around contributors, etc...?  Well again git is
> pretty good.  Someone could clone this stuff, put it somewhere legitimate,
> and accept patches to the documentation.  Github also makes it quite
> trivial to share contribution permissions and to manage revisions.
>
> I don't want to piss of the good people of this community that I'd like to
> be accepted into...is that possible?  I hope so. :)
>
> ft
>
> On Wednesday, June 13, 2012 12:33:38 PM UTC-7, fenton wrote:
>
>> https://github.com/ftravers/**PublicDocumentation/blob/**
>> master/clojure-development-**setup.md
>>
>> An index to other clojure tutorials:
>>
>> https://github.com/ftravers/**PublicDocumentation/blob/**
>> master/clojure-index.md

Slow 'quick sort'

2012-06-08 Thread Qiu Xiafei
I wrote a quick sort function in clojure, but it runs extremely slow.
Sometimes, if the input collection grows lager, it may even overflow the
stack?

Anything wrong with my code?

(defn qsort [coll]
  (if (<= (count coll) 1)
coll
(let [pivot (last coll)
  head-half (filter #(< % pivot) (drop-last coll))
  tail-half (filter #(>= % pivot) (drop-last coll))]
  (concat (qsort head-half) (vector pivot) (qsort tail-half)

I also read the sort function in clojure.core, but it make confused.

01 (defn sort
02   "Returns a sorted sequence of the items in coll. If no comparator is
03   supplied, uses compare. comparator must
04   implement java.util.Comparator."
05   {:added "1.0"
06:static true}
07   ([coll]
08(sort compare coll))
09   ([^java.util.Comparator comp coll]
10(if (seq coll)
11  (let [a (to-array coll)]
12(. java.util.Arrays (sort a comp))
13(seq a))
14  (

The only palace where recursive happens is at line 12. It just swap the two
input parameters!
Could you please explain to me why this piece of code is runs?

-- 
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: question with macro!

2012-05-02 Thread Qiu Xiafei
all function arguments will be evaluated  so, 123 was printed

On Thu, May 3, 2012 at 4:06 AM, thomas  wrote:

> the arguments to randomly-fn are evaluated before the macro-expansion of
> randomly kicks in.
> (that's what macros are for: control if, where and how often an expression
> is evaluated)
> So why would you need randomly-fn anyway?
> You can just write
>
> randomly (print 1) (print 2) (print 3))
>
> and this works.
>
>
> Am 02.05.2012 um 16:09 schrieb 金山:
>
> > I defined a macro like this:
> > (defmacro randomly [& exprs]
> >  (let [len (count exprs)
> >ind (rand-int len)
> >conditions (map #(list '= ind %) (range len))]
> >`(cond ~@(interleave conditions exprs
> >
> > and then defined a function :
> > (defn randomly-fn [& exprs]
> > (randomly exprs))
> >
> > I think there may be a mistake because of the randomly-fn didn't work
> > as expected.
> >
> > (randomly-fn (print 1) (print 2) (print 3))
> >
> > expected:
> > 1 or 2 or 3.
> > but returned:
> > 123
> >
> > where is the mistake?
> >
> > --
> > 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
>

-- 
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 Do I Install New Version Of Clojure?

2012-04-15 Thread Qiu Xiafei
I advice you download the clojure package from clojure.org, and unzip it.
Then you can put it to any where you want. Finally, write a shell script
named clojure, and put the script to $PATH
#! /bin/sh
java -cp /path/to/your/downloaded/clojure.jar clojure.main

On Sun, Apr 15, 2012 at 1:45 PM, Anto  wrote:

> I want to install clojure version 1.3, which I guess is the latest.
>
> I tried "sudo apt-get install clojure" which installs clojure 1.1 by
> default. I use Ubuntu 10.10
>
>
>
> Thanks in advance.
>
> --
> 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: Practical Clojure

2012-04-14 Thread Qiu Xiafei
how about Programming Clojure? I am reading it as a start point of learn
clojure

On Sat, Apr 14, 2012 at 4:52 PM, faenvie  wrote:

> light table looks like a candidate for the book ...
> btw 'professional clojure' is not a good title ... better: 'beyond
> clojure' ? etc.
>
> --
> 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