Re: What Emacs framework do you prefer?

2021-08-10 Thread Jiacai Liu

https://github.com/flyingmachine/emacs-for-clojure

I recommend flyingmachine's config, tailored for clojure 
development.

Also his awesome book https://www.braveclojure.com/basic-emacs/

On Tue, Aug 10, 2021 at 10:50:04 AM +0800, Laws wrote:

I've been away from Clojure for 3 years but I've decided my next 
project
will be pure Clojure. I'm setting everything up on a new MacBook 
Pro that I
just bought. I just installed Emacs and I'm wondering what kind 
of
starter-kit or framework do people prefer nowadays? Does anyone 
want to

either recommend a framework or share an init file that has some
customizations for Clojure?



--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/6112444b.1c69fb81.43c55.6a4cSMTPIN_ADDED_BROKEN%40gmr-mx.google.com.


[ANN] blog-backup 0.2.0 (Backup blogposts to PDF)

2020-08-09 Thread Jiacai Liu
Hi Everyone,
I'm glad to release 0.2.0 of blog-backup. New blogs can be supported in edn
config file, no code required.

https://github.com/jiacai2050/blog-backup

Enjoy

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/CAG65Qx%3DdU44YcZ88LS2MDpOhuWu1LWgpj-AYiT-Y-A_nGd586w%40mail.gmail.com.


[ANN] hystrix-dynamicvar -- Clojure dynamic var binding through hystrix command

2018-08-08 Thread Jiacai Liu
https://github.com/Netflix/Hystrix does its job quiet good.
However, its thread-style isolation makes dynamic var not work any more.
hystrix-dynamicvar to the rescue. More refer:
- https://github.com/jiacai2050/hystrix-dynamicvar
- https://github.com/Netflix/Hystrix/wiki/Plugins#concurrencystrategy

-- 
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/d/optout.


1.8 vs 1.9 performance

2017-12-24 Thread Jiacai Liu
Clojure 1.9 has been out for a while, are there any companies updating to 
Clojure 1.9 ? How is the performance compared to 1.8 ? Is the migration 
smooth?

-- 
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/d/optout.


Re: Unexpected performace of transducers

2017-11-27 Thread Jiacai Liu
Thanks Alex. Good summary.
I think this can be added to https://clojure.org/reference/transducers

On Tue, Nov 28, 2017 at 10:54 AM, Alex Miller  wrote:

> I would say transducers are preferable when:
>
> 1) you have reducible collections
> 2) you have a lot of pipelined transformations (transducers handle these
> in one pass with no intermediate data)
> 3) the number of elements is "large" (this amplifies the memory and perf
> savings from #2)
> 4) you put to produce a concrete output collection (seqs need an extra
> step to pour the seq into a collection; transducers can create it directly)
> 5) you want a reusable transformation that can be used in multiple
> contexts (reduction, sequence, core.async, etc)
>
> On Monday, November 27, 2017 at 8:33:50 PM UTC-6, Jiacai Liu wrote:
>>
>> > Also, most of the performance boost from transducers is due to less
>> garbage being created, and some times the heap of the JVM is so large
>> you'll never see much change from switching to transducers.
>>
>> Thanks for this tip. I seldom use transducers in my daily work, and I was
>> convinced transducers are a better choice in whatever situation after
>> reading some articles. But the test shows it isn't an easy choice, only
>> when do something reducible, will transducers make more sense.
>>
>> On Tuesday, November 28, 2017 at 5:07:10 AM UTC+8, tbc++ wrote:
>>>
>>> >> Also, I think the transducer version should always be faster, no
>>> matter the size of the source collection (no threshold).
>>>
>>> It's a bit more complicated than that, mostly because transducer
>>> pipelines require about 2 allocations per step during creation. Also, most
>>> of the performance boost from transducers is due to less garbage being
>>> created, and some times the heap of the JVM is so large you'll never see
>>> much change from switching to transducers.
>>>
>>> Don't get me wrong, transducers are great and I often default to them
>>> over seqs, but in micro-benchmarks like this there's too much in play to
>>> always see a 100% performance boost.
>>>
>>> On Mon, Nov 27, 2017 at 12:55 PM, David Bürgin  wrote:
>>>
>>>> Jiacai –
>>>>
>>>> I saw you updated the gist. Just in case it passed you by: performance
>>>> profits from the source collection being reducible. So pouring ‘dataset’
>>>> into a vector beforehand should speed up the processing quite a bit.
>>>>
>>>> Also, I think the transducer version should always be faster, no matter
>>>> the size of the source collection (no threshold).
>>>>
>>>>
>>>> --
>>>> David
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Clojure" group.
>>>> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>>
>>> --
>>> “One of the main causes of the fall of the Roman Empire was that–lacking
>>> zero–they had no way to indicate successful termination of their C
>>> programs.”
>>> (Robert Firth)
>>>
>> --
> 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/d/optout.
>

-- 
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/d/optout.


Re: Unexpected performace of transducers

2017-11-27 Thread Jiacai Liu
> Also, most of the performance boost from transducers is due to less 
garbage being created, and some times the heap of the JVM is so large 
you'll never see much change from switching to transducers. 

Thanks for this tip. I seldom use transducers in my daily work, and I was 
convinced transducers are a better choice in whatever situation after 
reading some articles. But the test shows it isn't an easy choice, only 
when do something reducible, will transducers make more sense.

On Tuesday, November 28, 2017 at 5:07:10 AM UTC+8, tbc++ wrote:
>
> >> Also, I think the transducer version should always be faster, no matter 
> >> the 
> size of the source collection (no threshold).
>
> It's a bit more complicated than that, mostly because transducer pipelines 
> require about 2 allocations per step during creation. Also, most of the 
> performance boost from transducers is due to less garbage being created, 
> and some times the heap of the JVM is so large you'll never see much change 
> from switching to transducers. 
>
> Don't get me wrong, transducers are great and I often default to them over 
> seqs, but in micro-benchmarks like this there's too much in play to always 
> see a 100% performance boost. 
>
> On Mon, Nov 27, 2017 at 12:55 PM, David Bürgin  > wrote:
>
>> Jiacai –
>>
>> I saw you updated the gist. Just in case it passed you by: performance
>> profits from the source collection being reducible. So pouring ‘dataset’
>> into a vector beforehand should speed up the processing quite a bit.
>>
>> Also, I think the transducer version should always be faster, no matter
>> the size of the source collection (no threshold).
>>
>>
>> --
>> David
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> “One of the main causes of the fall of the Roman Empire was that–lacking 
> zero–they had no way to indicate successful termination of their C 
> programs.”
> (Robert Firth) 
>

-- 
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/d/optout.


Re: [ANN] Ring Jetty servlet adapter

2017-11-19 Thread Jiacai Liu
Glad I can help.
If you have any questions, open a issue
<https://github.com/jiacai2050/ring-jetty-servlet-adapter/issues> on
github, I will look into it ASAP.

On Sun, Nov 19, 2017 at 11:55 PM, Michael Blume 
wrote:

> I was just about to start figuring out how to do this, for pretty much
> exactly the same reason (the Hystrix metrics stream). Thanks for this, I'm
> looking forward to trying it out.
>
> On Thu, Nov 16, 2017 at 5:23 AM Jiacai Liu  wrote:
>
>> Fork of official jetty adapter
>> <https://github.com/ring-clojure/ring/tree/master/ring-jetty-adapter> 
>> enhanced
>> with servlet-mapping support.
>>
>>
>> <https://github.com/jiacai2050/ring-jetty-servlet-adapter#why-another-adapter>Why
>> another adapter
>>
>> Some Java libraries, such as hystrix-metrics-event-stream
>> <https://github.com/Netflix/Hystrix/tree/master/hystrix-contrib/hystrix-metrics-event-stream>,
>> come with util servlets for exposing statistic infomation. But in a purely
>> Ring-based app we can't use those directly, you must convert the servlet
>> into a Ring handler function for use. This is cumbersome, and servlet
>> support should be supported out of box.
>>
>>
>> The codebase stays in step with the official, with version number
>> unchanged. So you can replace the official adapter with this in the least
>> amount of effort.
>>
>>
>>
>> https://github.com/jiacai2050/ring-jetty-servlet-adapter
>>
>>
>>
>> Let me know if you have any suggestions :-)
>>
>> --
>> 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/d/optout.
>>
> --
> 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/d/optout.
>

-- 
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/d/optout.


[ANN] Ring Jetty servlet adapter

2017-11-16 Thread Jiacai Liu


Fork of official jetty adapter 
 enhanced 
with servlet-mapping support.

Why
 
another adapter

Some Java libraries, such as hystrix-metrics-event-stream 
,
 
come with util servlets for exposing statistic infomation. But in a purely 
Ring-based app we can't use those directly, you must convert the servlet 
into a Ring handler function for use. This is cumbersome, and servlet 
support should be supported out of box.


The codebase stays in step with the official, with version number 
unchanged. So you can replace the official adapter with this in the least 
amount of effort.



https://github.com/jiacai2050/ring-jetty-servlet-adapter



Let me know if you have any suggestions :-)

-- 
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/d/optout.


Re: Releasing scope-capture, a library for easing REPL-based debugging

2017-10-08 Thread Jiacai Liu
Wow, what a good idea. Thanks for sharing.

On Mon, Oct 9, 2017 at 7:05 AM, Mike <145...@gmail.com> wrote:

> Cool! Thanks, Val!
>
> воскресенье, 8 октября 2017 г., 10:09:19 UTC+3 пользователь Val Waeselynck
> написал:
>
>> Hi, I'm happy to release a tiny Clojure/Script library called
>> scope-capture .
>>
>> https://github.com/alvalval/scope-capture
>>
>> Loosely speaking, scope-capture makes it trivial to reproduce from the
>> REPL the context of a piece of code after it executed.
>>
>> It was inspired by Stuart Halloway's article *REPL Debugging: no
>> stacktrace required
>> *.
>> Thanks Stu!
>>
>> I've been using it professionally for a few weeks now, and it's been a
>> significant productivity boost for me. In my view the benefits are:
>>
>>- easier debugging
>>- making Clojure code / projects more accessible to beginners
>>- easier ad-hoc exploration
>>
>> Please let me know what you think!
>>
>> Valentin Waeselynck
>>
> --
> 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/d/optout.
>

-- 
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/d/optout.


Re: The performance of plain map vs. defrecord

2017-10-08 Thread Jiacai Liu
Ooh, thanks for your tips.

On Sun, Oct 8, 2017 at 7:19 PM, dennis zhuang  wrote:

> First, the  alphabet-macro is wrong, it should use name instead of str in
> comp:
>
> user=> (macroexpand-1 '(alphabet-macro))
> (do (clojure.core/defrecord Alphabet [:a :b :c :d :e :f :g :h :i :j :k :l
> :m :n :o :p :q :r :s :t :u :w :v :x :y :z]) (def dummy-record (Alphabet. 0
> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25)))
> user=> (get dummy-record  :a)
> nil
>
> fixed it with name:
>
> (defmacro alphabet-macro []
>   `(do
>  (defrecord ~'Alphabet [~@(map (comp symbol name) a-z-ks)])
>  (def ~'dummy-record (~'Alphabet. ~@(range 26)
>
> (alphabet-macro)
> user=> (macroexpand-1  '(alphabet-macro))
> (do (clojure.core/defrecord Alphabet [a b c d e f g h i j k l m n o p q r
> s t u w v x y z]) (def dummy-record (Alphabet. 0 1 2 3 4 5 6 7 8 9 10 11 12
> 13 14 15 16 17 18 19 20 21 22 23 24 25)))
>
> user=> (get dummy-record  :a)
> 0
>
> After fixed, the benchmark result is as expected.
>
>
>
> 2017-10-08 16:40 GMT+08:00 Jiacai Liu :
>
>> As I read JoyOfClojure, it says one of reasons that prefer record over
>> plain map is speed, out of curiosity I test this using
>> https://github.com/hugoduncan/criterium, but the result is just contrary
>> to  my expectation. record is slower than map. Is there any optimizations
>> made to clojure 1.8.0 ?
>>
>> test  code: https://gist.github.com/jiacai2050/cdaaffa93079a4b8451727ace
>> 0c13064
>>
>> --
>> 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/d/optout.
>>
>
>
>
> --
> 庄晓丹
> Email:killme2...@gmail.com
> Site:   http://fnil.net
>
> 不学习,毋宁死
>
> --
> 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/d/optout.
>

-- 
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/d/optout.


The performance of plain map vs. defrecord

2017-10-08 Thread Jiacai Liu
As I read JoyOfClojure, it says one of reasons that prefer record over 
plain map is speed, out of curiosity I test this using 
https://github.com/hugoduncan/criterium, but the result is just contrary 
to  my expectation. record is slower than map. Is there any optimizations 
made to clojure 1.8.0 ?

test  code: 
https://gist.github.com/jiacai2050/cdaaffa93079a4b8451727ace0c13064

-- 
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/d/optout.


Re: [inheritable-var] A wrapper of InheritableThreadLocal to define thread-inheritable variable

2017-07-30 Thread Jiacai Liu
Oh, it's the same issue with your first example, we need to change executor 
that core/async use. I will add some hook to decorate those frequently-used 
executor.

On Sunday, July 30, 2017 at 3:32:34 PM UTC+8, Didier wrote:
>
> I think it would be nice if inheritable-var would set! the future executor 
> service on load, so the user doesn't have to. This way it will just work 
> with future also. Just my 2 cent.
>
> Here's how to reproduce the issue with core.async:
>
> (let [t 1000]
>   (dotimes [x t]
> (let [foo (inheritable-var (constantly "Main"))
>   chan (async/chan)]
>   (inheritable-binding [foo "In chan Thread."]
>(async/go
> (async/>! chan @foo))
>(let [res (async/  (when (= x (dec t))
>        (print res)))
>
>
>
>
> On Saturday, 29 July 2017 23:52:44 UTC-7, Jiacai Liu wrote:
>>
>> For your first example, we should decorate the executor future use, see 
>> TransmittableThreadLocal 
>> doc 
>> <https://github.com/alibaba/transmittable-thread-local/blob/master/README-EN.md#22-decorate-thread-pool>
>>
>> (let [foo (inheritable-var (constantly "Main"))]
>>   (set! clojure.lang.Agent/soloExecutor (->inheritable 
>> clojure.lang.Agent/soloExecutor))  (inheritable-binding [foo "In future 
>> thread"]
>>@(future @foo)))
>>
>> For core/async example, this should return In chan Thread, are you using 
>> v0.1.3 ?
>>
>> (let [foo (inheritable-var (constantly "Main"))
>>   chan (async/chan)]
>>   (inheritable-binding [foo "In chan Thread."]
>>(async/go
>> (async/>! chan @foo))
>>(async/>
>> I will add binding conveyance and usage to decorate executor when using 
>> thread pool in my doc
>>
>> Many thanks. 👍
>>
>> On Sunday, July 30, 2017 at 1:28:46 PM UTC+8, Didier wrote:
>>>
>>> Your doc says this doesn't work with dynamic binding:
>>>
>>> (def ^:dynamic *foo* 5)
>>> (defn adder
>>>   [param]
>>>   (+ *foo* param))
>>> (binding [*foo* 10]
>>>  (doseq [v (pmap adder (repeat 3 5))]
>>>(println v)))
>>>
>>> But it does since Clojure 1.3. They added binding conveyance: 
>>> https://github.com/clojure/clojure/blob/master/changes.md#234-binding-conveyance
>>>
>>> This means that in Clojure 1.3+, when using dynamic binding and future, 
>>> agent, pmap or core.async, child threads will inherit the bounded vars 
>>> properly.
>>>
>>> You might want to make that clear in your doc.
>>>
>>> I also believe there's an issue with your library, this does not work:
>>>
>>> (definheritable foo "Main thread.")
>>> (inheritable-binding [foo "In thread inside future, running on Clojure 
>>> ThreadPools."]
>>>  @(future @foo))
>>>
>>> It also doesn't seem to play nice with core.async, whereas dynamic vars 
>>> do:
>>>
>>> (let [chan (async/chan)]
>>>   (inheritable-binding [foo "In chan Thread."]
>>>(async/go
>>> (async/>! chan @foo))
>>>(async/>> => CompilerException java.lang.RuntimeException: Unable to resolve 
>>> symbol: foo in this context
>>>
>>> (def ^:dynamic bar "In main thread.")
>>> (let [chan (async/chan)]
>>>   (binding [bar "In chan Thread."]
>>>(async/go
>>> (async/>! chan bar))
>>>(async/>> => "In chan Thread."
>>>
>>>
>>>
>>> On Saturday, 29 July 2017 19:37:13 UTC-7, Jiacai Liu wrote:
>>>>
>>>> Thanks for your tips.
>>>>
>>>> I have updated my code to wrap TransmittableThreadLocal 
>>>> <https://github.com/alibaba/transmittable-thread-local/blob/master/README-EN.md>,
>>>>  an 
>>>> enhanced version of InheritableThreadLocal, to solve threadpool problem.
>>>>
>>>> On Sunday, July 30, 2017 at 3:11:59 AM UTC+8, Didier wrote:
>>>>>
>>>>> InheritableThreadLocal is not safe to use with ThreadPools. And a lot 
>>>>> of the Clojure par

Re: [inheritable-var] A wrapper of InheritableThreadLocal to define thread-inheritable variable

2017-07-29 Thread Jiacai Liu


For your first example, we should decorate the executor future use, see 
TransmittableThreadLocal 
doc 
<https://github.com/alibaba/transmittable-thread-local/blob/master/README-EN.md#22-decorate-thread-pool>

(let [foo (inheritable-var (constantly "Main"))]
  (set! clojure.lang.Agent/soloExecutor (->inheritable 
clojure.lang.Agent/soloExecutor))  (inheritable-binding [foo "In future thread"]
   @(future @foo)))

For core/async example, this should return In chan Thread, are you using 
v0.1.3 ?

(let [foo (inheritable-var (constantly "Main"))
  chan (async/chan)]
  (inheritable-binding [foo "In chan Thread."]
   (async/go
(async/>! chan @foo))
   (async/
> Your doc says this doesn't work with dynamic binding:
>
> (def ^:dynamic *foo* 5)
> (defn adder
>   [param]
>   (+ *foo* param))
> (binding [*foo* 10]
>  (doseq [v (pmap adder (repeat 3 5))]
>(println v)))
>
> But it does since Clojure 1.3. They added binding conveyance: 
> https://github.com/clojure/clojure/blob/master/changes.md#234-binding-conveyance
>
> This means that in Clojure 1.3+, when using dynamic binding and future, 
> agent, pmap or core.async, child threads will inherit the bounded vars 
> properly.
>
> You might want to make that clear in your doc.
>
> I also believe there's an issue with your library, this does not work:
>
> (definheritable foo "Main thread.")
> (inheritable-binding [foo "In thread inside future, running on Clojure 
> ThreadPools."]
>  @(future @foo))
>
> It also doesn't seem to play nice with core.async, whereas dynamic vars do:
>
> (let [chan (async/chan)]
>   (inheritable-binding [foo "In chan Thread."]
>(async/go
> (async/>! chan @foo))
>(async/ => CompilerException java.lang.RuntimeException: Unable to resolve symbol: 
> foo in this context
>
> (def ^:dynamic bar "In main thread.")
> (let [chan (async/chan)]
>   (binding [bar "In chan Thread."]
>(async/go
> (async/>! chan bar))
>(async/ => "In chan Thread."
>
>
>
> On Saturday, 29 July 2017 19:37:13 UTC-7, Jiacai Liu wrote:
>>
>> Thanks for your tips.
>>
>> I have updated my code to wrap TransmittableThreadLocal 
>> <https://github.com/alibaba/transmittable-thread-local/blob/master/README-EN.md>,
>>  an 
>> enhanced version of InheritableThreadLocal, to solve threadpool problem.
>>
>> On Sunday, July 30, 2017 at 3:11:59 AM UTC+8, Didier wrote:
>>>
>>> InheritableThreadLocal is not safe to use with ThreadPools. And a lot of 
>>> the Clojure parallel constructs rely on ThreadPools.
>>>
>>> I'd recommend you rely on dynamic Vars instead and use bound-fn when you 
>>> want child threads to inherit parent's bindings. 
>>>
>>> If you knew this already, then I see no harm in using 
>>> InheritableThreadLocal, but just be sure you understand its risk. In most 
>>> cases, it is unsafe. 
>>>
>>>

-- 
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/d/optout.


Re: [inheritable-var] A wrapper of InheritableThreadLocal to define thread-inheritable variable

2017-07-29 Thread Jiacai Liu
Thanks for your tips.

I have updated my code to wrap TransmittableThreadLocal 
,
 an 
enhanced version of InheritableThreadLocal, to solve threadpool problem.

On Sunday, July 30, 2017 at 3:11:59 AM UTC+8, Didier wrote:
>
> InheritableThreadLocal is not safe to use with ThreadPools. And a lot of 
> the Clojure parallel constructs rely on ThreadPools.
>
> I'd recommend you rely on dynamic Vars instead and use bound-fn when you 
> want child threads to inherit parent's bindings. 
>
> If you knew this already, then I see no harm in using 
> InheritableThreadLocal, but just be sure you understand its risk. In most 
> cases, it is unsafe. 
>
>

-- 
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/d/optout.


[inheritable-var] A wrapper of InheritableThreadLocal to define thread-inheritable variable

2017-07-29 Thread Jiacai Liu
After digging into dynamic + binding doesn't work in multithread, I create 
a simple wrap to define thread-inheritable var.
Any suggestions(bugs) are welcome.

https://github.com/jiacai2050/inheritable-var

-- 
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/d/optout.


Re: [ANN] Miraj: functional, idiomatic Clojure web programming, including web components

2017-06-18 Thread Jiacai Liu
Cool.
One question: Is miraj compatible with https://github.com/weavejester/hiccup
?

On Mon, Jun 19, 2017 at 2:29 AM, Gregg Reynolds  wrote:

> Hi folks,
>
> The goal of the Miraj project is to  support web programming, including
> definition and use of web components (specifically Polymer 1.9.x
>  in
> this version), in seamless and idiomatic Clojure.  It seems to be somewhere
> in the vicinity of Alpha, so I'm looking for feedback and help.
>
> The homepage at https://miraj-project.github.io/ contains high-level docs
> and brief examples (and is implemented in Miraj).  I've also got a bunch of
> graded and commented demos at https://github.com/miraj-
> project/demos/tree/master/hello-world .  I would be grateful to anybody
> who gives them a whirl and provides feedback.
>
> Very briefly, it contains a functional HTML library, supports bits of
> sugar (e.g. :#foo for id attributes, etc.), and provides macros for
> defining pages, components and component libraries, such that the shape of
> such code is similar to that of ordinary deftype or defrecord.  It tries to
> hide and automate as much low-level detail as possible (e.g. construction
> of the  element).
>
> The code it generates could be used in production, but the libraries
> themselves should be considered alpha, since they depend on Clojure 1.9.0
> alpha, and currently only Polymer version 1 is supported.  There are a few
> loose ends in the Polymer support that will only be tied off in version 2.
>
> For help:  I've taken the liberty of creating a #miraj channel on
> Clojurians slack; I also monitor this list, #clojure, #clojurescript etc.
>
> Thanks,
>
> Gregg
>
> --
> 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/d/optout.
>

-- 
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/d/optout.


How to invoke StaticMethodExpr.eval?

2017-02-04 Thread Jiacai Liu


I am following this series 
 
to learn how clojure compiler works.

I tried to invoke eval method of StaticMethodExpr using below codes

(ns clojure.lang
  (:use clojure.core)
  (:import [clojure.lang Compiler Compiler$C]))

(def form (read-string "(+ 1 1)") )

(def expr (Compiler/analyze Compiler$C/EXPRESSION form))

(.eval expr)

but no luck and throw IllegalArgumentException:

Unhandled java.lang.IllegalArgumentException
   Can't call public method of non-public class: public
   java.lang.Object clojure.lang.Compiler$StaticMethodExpr.eval()

Is there anything I was missing or is this a bug in jdk 
 ?


StackOverflow 
link: 
http://stackoverflow.com/questions/42048786/how-to-invoke-staticmethodexpr-eval


​

-- 
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/d/optout.


Re: Stack Overflow Question

2016-12-25 Thread Jiacai Liu
I have left a comment below your answer on StackOverflow, can you explain 
it a little more. thanks

On Saturday, December 24, 2016 at 11:12:03 PM UTC+8, James Reeves wrote:
>
> On 24 December 2016 at 11:48, Jiacai Liu 
> > wrote:
>
>> how to make correct fn args when create fn using macro
>> http://stackoverflow.com/q/41312963/2163429?sem=2
>>
>
> For reference, I posted an answer on StackOverflow.
>
> - 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
--- 
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/d/optout.


Re: Stack Overflow Question

2016-12-24 Thread Jiacai Liu


your version is obviously wrong, when '~param will try to resolve param, 
but no luck

On Saturday, December 24, 2016 at 10:07:15 PM UTC+8, Jim foo.bar wrote:
>
> try the following:
>
> (defmacro defapihandler [handler-name params & body]
>   `(defn ~handler-name ['~passed-param]
>  (let [param-keys# (vec (map (comp symbol name :key)
> ~params))
>{:keys param-keys#} '~passed-param]
>;; some check
>~@body)))
>
>
>
> Sorry for brevity, I'm on my phone...
> Dimitris
>
> On 24/12/16 13:23, Jiacai Liu wrote:
>
> I don’t think your answer is correct. From the expaned macro
>
> (defn create-user [passed-param__10243__auto__]
>   (let [param-keys__10244__auto__ (vec
> (map
>   (comp symbol name :key)
>   [{:key :username,
> :checkers []}]))
> {:keys param-keys__10244__auto__} passed-param__10243__auto__]
> (do (println username
>
> and following test
>
> (let [some-keys '[a b]
>   {:keys some-keys} {:a 1 :b 2}]
>   ; thows Don't know how to create ISeq from: clojure.lang.Symbol
>   (println a b))
>
> (let [{:keys [a b]} {:a 1 :b 2}]
>   ; ok
>   (println a b))
>
> I think it is in let destructuring form, we can’t use dynamic var to 
> represent symbols
>
>
>
> On Saturday, December 24, 2016 at 8:43:42 PM UTC+8, Jim foo.bar wrote: 
>>
>> you need to use `'~passed-param` in your arg-vector, and the same 
>> whenever you use it inside the newly defined fn.
>>
>>
>> HTH,
>>
>> Dimitris
>>
>> On 24/12/16 11:48, Jiacai Liu wrote:
>>
>> how to make correct fn args when create fn using macro
>> http://stackoverflow.com/q/41312963/2163429?sem=2
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
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/d/optout.


Re: Stack Overflow Question

2016-12-24 Thread Jiacai Liu


I don’t think your answer is correct. From the expaned macro

(defn create-user [passed-param__10243__auto__]
  (let [param-keys__10244__auto__ (vec
(map
  (comp symbol name :key)
  [{:key :username,
:checkers []}]))
{:keys param-keys__10244__auto__} passed-param__10243__auto__]
(do (println username

and following test

(let [some-keys '[a b]
  {:keys some-keys} {:a 1 :b 2}]
  ; thows Don't know how to create ISeq from: clojure.lang.Symbol
  (println a b))

(let [{:keys [a b]} {:a 1 :b 2}]
  ; ok
  (println a b))

I think it is in let destructuring form, we can’t use dynamic var to 
represent symbols



On Saturday, December 24, 2016 at 8:43:42 PM UTC+8, Jim foo.bar wrote:
>
> you need to use `'~passed-param` in your arg-vector, and the same whenever 
> you use it inside the newly defined fn.
>
>
> HTH,
>
> Dimitris
>
> On 24/12/16 11:48, Jiacai Liu wrote:
>
> how to make correct fn args when create fn using macro
> http://stackoverflow.com/q/41312963/2163429?sem=2
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
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/d/optout.


Stack Overflow Question

2016-12-24 Thread Jiacai Liu
how to make correct fn args when create fn using macro
http://stackoverflow.com/q/41312963/2163429?sem=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
--- 
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/d/optout.


Re: ClojureScript Quick-Start node_repl java.lang.IllegalArgumentException: Value out of range for char: -1

2016-09-22 Thread Jiacai Liu
It turns out that jdk7 is to blame. When I change to jdk8, everything goes
well.

On Thu, Sep 22, 2016 at 2:08 PM, Jiacai Liu  wrote:

> http://stackoverflow.com/questions/39629743/clojurescript-quick-start-
> node-repl-java-lang-illegalargumentexception-value-ou
>
> --
> 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/d/optout.
>

-- 
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/d/optout.


ClojureScript Quick-Start node_repl java.lang.IllegalArgumentException: Value out of range for char: -1

2016-09-21 Thread Jiacai Liu
http://stackoverflow.com/questions/39629743/clojurescript-quick-start-node-repl-java-lang-illegalargumentexception-value-ou

-- 
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/d/optout.


Re: why is it so annoying to run clojure code

2016-06-11 Thread Jiacai Liu
Thank all above suggestions, I have tried emacs + cider, which seems great 
for me

<https://lh3.googleusercontent.com/-QH52eABuaY8/V1v__vICr_I/Aco/13kqdkItrlgdZL6ray3zBP_YrawCIiREgCLcB/s1600/Snip20160611_57.png>


在 2016年6月10日星期五 UTC+8上午12:08:39,Jiacai Liu写道:
>
> I  started learning clojure recently, and I am annoyed at the way to run 
> it (aka. lein run). why clojure script can't be run like python,ruby or 
> scala, like python .py
>

-- 
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/d/optout.


why is it so annoying to run clojure code

2016-06-09 Thread Jiacai Liu
I  started learning clojure recently, and I am annoyed at the way to run it 
(aka. lein run). why clojure script can't be run like python,ruby or scala, 
like python .py

-- 
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/d/optout.


Re: Clojure cons vs. conj

2014-04-24 Thread Jiacai Liu
thank Guru,the solution of my problem may not difficult,I first didn't 
understand the usage of cons and conj,now I can grasp them deeper than 
before.
Clojure is so  flexible that it both have cons and conj for different 
situation,which accounts for its advantages over mit-lisp.

On Friday, April 25, 2014 12:59:34 AM UTC+8, Guru Devanla wrote:
>
> Another option is to explore "concat"
>
>
> On Thu, Apr 24, 2014 at 8:46 AM, Jiacai Liu 
> > wrote:
>
>> Well,I understand you.
>> list only support front insert since it only takes O(1).
>> If insert in the back,it would require O(n) time.
>> Maybe clojure has its own reasons for having both cons and conj. 
>> Thank again for telling me their differences.
>>
>>
>> On Thursday, April 24, 2014 11:36:13 PM UTC+8, Gary Trakhman wrote:
>>
>>> Well, maybe I shouldn't bash MIT-scheme unintentionally :-).  I bet some 
>>> people use it for serious stuff, and I have no bad experiences with it.
>>>
>>>
>>> On Thu, Apr 24, 2014 at 11:33 AM, Gary Trakhman wrote:
>>>
>>>>  MIT-lisp is more for teaching than industrial use..
>>>>
>>>> We also have hash-maps, vectors, sets, queues, conj works with all of 
>>>> them, leaving the details up to the collection.
>>>>
>>>> Cons always adds to the front.  Conj only adds to the back for certain 
>>>> collections (vector, queue).
>>>>
>>>> You could work around it by reversing, consing, then reversing again, 
>>>> or just use vectors and conj if you're always working on the tail.
>>>>
>>>>
>>>> On Thu, Apr 24, 2014 at 11:27 AM, Jiacai Liu wrote:
>>>>
>>>>> Oh,Thank you for answer.
>>>>> But if I just want to insert a element to list,and meantime want to 
>>>>> insert in the back.How should I do?
>>>>> Another question: why clojure need both cons and conj? In mit-lisp 
>>>>> cons just do all things.
>>>>>
>>>>>
>>>>> On Thursday, April 24, 2014 11:12:49 PM UTC+8, Gary Trakhman wrote:
>>>>>
>>>>>> Conj is polymorphic on its first argument. If you pass it a vector, 
>>>>>> it'll add to the back, if a list, the front.  The collection is 
>>>>>> responsible 
>>>>>> for deciding the most efficient way to add an element.
>>>>>>
>>>>>> Cons always adds to the front, creating a linked-list node pointing 
>>>>>> to the rest.  Also, cons takes the sequence as the second argument.
>>>>>>
>>>>>>
>>>>>> On Thu, Apr 24, 2014 at 11:10 AM, Jiacai Liu wrote:
>>>>>>
>>>>>>> hi everyone:
>>>>>>> I use Clojure to solve SICP 2.22 
>>>>>>> <http://www.billthelizard.com/2011/01/sicp-221-223-mapping-over-lists.html>
>>>>>>> .
>>>>>>> The problem is to rewrite a map fn in a iterative way,here it want 
>>>>>>> to get the square of each element in a list
>>>>>>> Method 1:
>>>>>>> (defn square-list [items]
>>>>>>>   (defn iter [things answer]
>>>>>>> (if (empty? things)
>>>>>>>   answer
>>>>>>>   (iter 
>>>>>>> (rest things)
>>>>>>> (cons (square (first things)) answer  
>>>>>>>   (iter items nil)) 
>>>>>>> This method just return opposite result.
>>>>>>> (square-list (range 1 10))   
>>>>>>> ;===>(81 64 49 36 25 16 9 4 1)
>>>>>>>
>>>>>>> I think all I need is to swap the position of (square (first 
>>>>>>> things)) and answer,then I can get the right order
>>>>>>> I write fn below:
>>>>>>> Method 2
>>>>>>> (defn square-list [items]
>>>>>>>   (defn iter [things answer]
>>>>>>> (if (empty? things)
>>>>>>>   answer
>>>>>>>   (iter 
>>>>>>> (rest things)
>>>>>>> (conj answer (square (first things))  
>>>>>>>   (iter items nil)) 
>>>>>>> However, it still return opposite order.
>>>>>>> Did I misuse cons and conj or I ignore something?
>>>>>&

Re: Clojure cons vs. conj

2014-04-24 Thread Jiacai Liu
Well,I understand you.
list only support front insert since it only takes O(1).
If insert in the back,it would require O(n) time.
Maybe clojure has its own reasons for having both cons and conj. 
Thank again for telling me their differences.

On Thursday, April 24, 2014 11:36:13 PM UTC+8, Gary Trakhman wrote:
>
> Well, maybe I shouldn't bash MIT-scheme unintentionally :-).  I bet some 
> people use it for serious stuff, and I have no bad experiences with it.
>
>
> On Thu, Apr 24, 2014 at 11:33 AM, Gary Trakhman 
> 
> > wrote:
>
>> MIT-lisp is more for teaching than industrial use..
>>
>> We also have hash-maps, vectors, sets, queues, conj works with all of 
>> them, leaving the details up to the collection.
>>
>> Cons always adds to the front.  Conj only adds to the back for certain 
>> collections (vector, queue).
>>
>> You could work around it by reversing, consing, then reversing again, or 
>> just use vectors and conj if you're always working on the tail.
>>
>>
>> On Thu, Apr 24, 2014 at 11:27 AM, Jiacai Liu 
>> > wrote:
>>
>>> Oh,Thank you for answer.
>>> But if I just want to insert a element to list,and meantime want to 
>>> insert in the back.How should I do?
>>> Another question: why clojure need both cons and conj? In mit-lisp cons 
>>> just do all things.
>>>
>>>
>>> On Thursday, April 24, 2014 11:12:49 PM UTC+8, Gary Trakhman wrote:
>>>
>>>> Conj is polymorphic on its first argument. If you pass it a vector, 
>>>> it'll add to the back, if a list, the front.  The collection is 
>>>> responsible 
>>>> for deciding the most efficient way to add an element.
>>>>
>>>> Cons always adds to the front, creating a linked-list node pointing to 
>>>> the rest.  Also, cons takes the sequence as the second argument.
>>>>
>>>>
>>>> On Thu, Apr 24, 2014 at 11:10 AM, Jiacai Liu wrote:
>>>>
>>>>> hi everyone:
>>>>> I use Clojure to solve SICP 2.22 
>>>>> <http://www.billthelizard.com/2011/01/sicp-221-223-mapping-over-lists.html>
>>>>> .
>>>>> The problem is to rewrite a map fn in a iterative way,here it want to 
>>>>> get the square of each element in a list
>>>>> Method 1:
>>>>> (defn square-list [items]
>>>>>   (defn iter [things answer]
>>>>> (if (empty? things)
>>>>>   answer
>>>>>   (iter 
>>>>> (rest things)
>>>>> (cons (square (first things)) answer  
>>>>>   (iter items nil)) 
>>>>> This method just return opposite result.
>>>>> (square-list (range 1 10))   
>>>>> ;===>(81 64 49 36 25 16 9 4 1)
>>>>>
>>>>> I think all I need is to swap the position of (square (first 
>>>>> things))andanswer,then 
>>>>> I can get the right order
>>>>> I write fn below:
>>>>> Method 2
>>>>> (defn square-list [items]
>>>>>   (defn iter [things answer]
>>>>> (if (empty? things)
>>>>>   answer
>>>>>   (iter 
>>>>> (rest things)
>>>>> (conj answer (square (first things))  
>>>>>   (iter items nil)) 
>>>>> However, it still return opposite order.
>>>>> Did I misuse cons and conj or I ignore something?
>>>>>
>>>>>
>>>>>  -- 
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Clojure" group.
>>>>> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
>>>>>
>>>>> For more options, visit https://groups.google

Re: Clojure cons vs. conj

2014-04-24 Thread Jiacai Liu
Oh,Thank you for answer.
But if I just want to insert a element to list,and meantime want to insert 
in the back.How should I do?
Another question: why clojure need both cons and conj? In mit-lisp cons 
just do all things.

On Thursday, April 24, 2014 11:12:49 PM UTC+8, Gary Trakhman wrote:
>
> Conj is polymorphic on its first argument. If you pass it a vector, it'll 
> add to the back, if a list, the front.  The collection is responsible for 
> deciding the most efficient way to add an element.
>
> Cons always adds to the front, creating a linked-list node pointing to the 
> rest.  Also, cons takes the sequence as the second argument.
>
>
> On Thu, Apr 24, 2014 at 11:10 AM, Jiacai Liu 
> > wrote:
>
>> hi everyone:
>> I use Clojure to solve SICP 2.22 
>> <http://www.billthelizard.com/2011/01/sicp-221-223-mapping-over-lists.html>
>> .
>> The problem is to rewrite a map fn in a iterative way,here it want to get 
>> the square of each element in a list
>> Method 1:
>> (defn square-list [items]
>>   (defn iter [things answer]
>> (if (empty? things)
>>   answer
>>   (iter 
>> (rest things)
>> (cons (square (first things)) answer  
>>   (iter items nil)) 
>> This method just return opposite result.
>> (square-list (range 1 10))   
>> ;===>(81 64 49 36 25 16 9 4 1)
>>
>> I think all I need is to swap the position of (square (first things)) 
>> andanswer,then 
>> I can get the right order
>> I write fn below:
>> Method 2
>> (defn square-list [items]
>>   (defn iter [things answer]
>> (if (empty? things)
>>   answer
>>   (iter 
>> (rest things)
>> (conj answer (square (first things))  
>>   (iter items nil)) 
>> However, it still return opposite order.
>> Did I misuse cons and conj or I ignore something?
>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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/d/optout.


Clojure cons vs. conj

2014-04-24 Thread Jiacai Liu
hi everyone:
I use Clojure to solve SICP 2.22 

.
The problem is to rewrite a map fn in a iterative way,here it want to get 
the square of each element in a list
Method 1:
(defn square-list [items]
  (defn iter [things answer]
(if (empty? things)
  answer
  (iter 
(rest things)
(cons (square (first things)) answer  
  (iter items nil)) 
This method just return opposite result.
(square-list (range 1 10))   
;===>(81 64 49 36 25 16 9 4 1)

I think all I need is to swap the position of (square (first things)) 
andanswer,then 
I can get the right order
I write fn below:
Method 2
(defn square-list [items]
  (defn iter [things answer]
(if (empty? things)
  answer
  (iter 
(rest things)
(conj answer (square (first things))  
  (iter items nil)) 
However, it still return opposite order.
Did I misuse cons and conj or I ignore something?


-- 
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/d/optout.