Re: getting started: generated address-book directory does not match tutorial

2016-01-30 Thread gianluca torta
are you using leiningen 2.x? in such a case, it should download and install the desired template on the fly when you give command: $ lein new hoplon address-book hth, Gianluca On Saturday, January 30, 2016 at 3:54:32 AM UTC+1, hiskennyness wrote: > > [Also posted in the Hoplon github issues

error in receipe 1 of "Clojure Data Structures and Algorithms Cookbook"?

2016-01-29 Thread gianluca torta
Hi all, I have just started reading this book, and went through the 1st Recipe: https://www.packtpub.com/application-development/clojure-data-structures-and-algorithms-cookbook Unfortunately, the recipe apparently does not work. On page 2, the author informally describes the recipe as taking:

Re: macro question

2016-01-27 Thread gianluca torta
Hi Dan, And, if I understand correctly, what was really happening with the macro > bar was that in ('+ 2 'u), '+ was looking itself up in 2, not finding > itself, and so returning the default value 'u. This was the expansion of > the macro, and so at run time, it was bound to 10. > > exactly,

Re: Can anyone help with a jug problem in clojure

2016-01-26 Thread gianluca torta
Hi Steve, this lookslike a typical problem that requires "artificial intelligence" (AI) search: http://www.tutorialspoint.com/artificial_intelligence/artificial_intelligence_popular_search_algorithms.htm once you have a general strategy based on the above algos in mind, a quite orthogonal

Re: Question concerning eval

2016-01-14 Thread gianluca torta
Hi Adrian, with your suggestion it certainly works also with avec' however, I still don't see why the original code from Burt works with avec and does not work with avec' cheers, Gianluca On Thursday, January 14, 2016 at 5:06:02 PM UTC+1, adrian...@mail.yu.edu wrote: > > You need to quote

Re: Question concerning eval

2016-01-14 Thread gianluca torta
Hi Burt, I have done some investigation, further reducing your issue to the following: (def g (make-adder 2)) (eval `(let [~'f ~g] (~'f 5))) ; --> error IllegalArgumentException No matching ctor found for class user$make_adder$fn__7609 etc. (defn h [x] (+ x 2)) (eval `(let [~'f ~h] (~'f 5)))

Re: Question concerning eval

2016-01-14 Thread gianluca torta
small update: I found that the problem happens because make-adder returns a closure; with a simple function it works: (defn make-2-adder [] (fn [x] (+ 2 x))) (def g2 (make-2-adder)) (eval `(let [~'f ~g2] (~'f 5))) ; --> 7 On Thursday, January 14, 2016 at 12:52:47 PM UTC+1, gianluca torta wr

Re: mexpand on macrolet

2015-12-07 Thread gianluca torta
Hi Hunter, however, in this way you are expanding the application of the macro "symbol-macrolet" (which is itself a macro), not just the symbol macro "b": (pprint (mexpand-1 '(symbol-macrolet [b (+ 1 2)] b ["something" "else"]))) ;; (do (+ 1 2) ["something" "else"]) ;; nil cheers, Gianluca On

Re: Extend ns macro?

2015-12-02 Thread gianluca torta
for some reason, it looks like the implementation of the ns macro assumes that the macro itself is being defined in namespace clojure.core try defining myns in the namespace clojure.core, and it should work cheers, Gianluca On Tuesday, December 1, 2015 at 9:49:08 PM UTC+1, Gregg Reynolds

Re: Poor parallelization performance across 18 cores (but not 4)

2015-11-18 Thread gianluca torta
by the way, have you tried both Oracle and Open JDK with the same results? Gianluca On Tuesday, November 17, 2015 at 8:28:49 PM UTC+1, Andy Fingerhut wrote: > > David, you say "Based on jvisualvm monitoring, doesn't seem to be > GC-related". > > What is jvisualvm showing you related to GC and/or

Re: Writing Friendlier Clojure

2015-10-13 Thread gianluca torta
Hi, "Whenever you notice this pattern, you can probably turn to one of the > threading macros instead." > > that would fly in the face of being more declarative; when we start to > put in explicit ordering, instead of leaving it as just relationships, > that can be bad. of course it can also

Re: Help with macro.

2015-10-04 Thread gianluca torta
> > Yes, your solution works, but only on clojure. ClojureScript doesn't have > `resolve`. It there any portable solution? > > I'm not sure if and how you can do it in ClojureScript... have you tried: https://groups.google.com/forum/#!forum/clojurescript cheers, Gianluca -- You received

Re: Help with macro.

2015-10-03 Thread gianluca torta
Hi, the behavior you describe is not specific to macros, but is due to the use of aliases after: (require '[foo.bar :as b]) this will give you false: (= 'foo.bar/x (first '(b/x))) while this will give you true: (= 'foo.bar/x (first '(foo.bar/x))) one way to solve it, is comparing the

Re: macro help

2015-10-02 Thread gianluca torta
Hi Colin, as far as I can tell, your solution looks fine... here are a couple of comments on your step-by-step analysis cheers, Gianluca 1(defmacro form [state & elements] > 2 (let [m-state (gensym)] > 3`(let [~m-state ~state] > 4 [:div.form.horizontal > 5~@(map (fn [[f m &

Re: Is this expected behavior with meta data?

2015-06-25 Thread gianluca torta
to get the meta-data of a var (I'm guessing symbol n refers to a var...) you should call it on the var iself, not its value or symbol: user= (def ^{:some-meta 123} n 0) #'user/n user= (meta n) nil user= (meta 'n) nil user= (meta #'n) {:some-meta 123, :ns #Namespace user, :name n, :file

Re: I'm trying to decode some source code to understand how it works

2015-06-23 Thread gianluca torta
Hi Gregg, When you look at the function given as the first argument to 'recurse', (fn [f g] #(f (apply g %))), how do you think about when '%' is replaced by [1 2 3 4]? Does this happen only when 'recurse' has consumed all the items in the collection it's been given (as the second

Re: Help with data structure transformation

2015-06-07 Thread gianluca torta
see also this page: http://clojure.org/sequences where for is listed among the seq library functions HTH Gianluca -- 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

Re: macro question

2014-06-18 Thread gianluca torta
you can also use macroexpand-1 to see how your macro expands for example, having defined your macro as suggested by Gary and James above, you can write something like: (macroexpand-1 '(if-zero (- 4 2 2) (+ 1 1) (+ 2 2))) and see that it correctly to: (if (clojure.core/= (- 4 2 2) 0) (+ 1 1) (+

Re: The Cons in iterate's return value

2014-04-16 Thread gianluca torta
this issue on core.typed http://dev.clojure.org/jira/browse/CTYP-96 in particular the comment: This is starting to make me rethink what a clojure.core docstring means exactly by a lazy sequence cheers, Gianluca On Wednesday, April 16, 2014 6:45:01 PM UTC+2, Mars0i wrote: The docstring for

Re: Lazy sequence - how they work internally

2014-04-06 Thread gianluca torta
Hi sorin, your function computes a sequence of just one element (the sum of the collection members), so I would say it is not a typical use of (lazy) seqs to see that the code is indeed lazy, you can try: (def x (test-fc (range 210432423543654675765876879))) and see that it returns

Re: Example in Joy of Clojure, 2nd edition (MEAP)

2014-02-16 Thread gianluca torta
as a side note, since we are within the backquote, simply using r (instead of ~'r) would not work since it would incorrectly expand to the fully qualified symbol, e.g. user/r Gianluca On Saturday, February 15, 2014 5:49:57 PM UTC+1, Jan Herich wrote: Hello Eric, You can rewrite this

Re: Looking for advice to fine tune a simple function

2014-02-16 Thread gianluca torta
to me it seems that you are anyway relying on the assumption that the sequence is ordered, so I think it would be convenient to drop the ands Gianluca On Sunday, February 16, 2014 11:31:46 PM UTC+1, Laurent Droin wrote: Hi, Disclaimer - I am completely new to Clojure. I just implemented my

Re: instaparse: composing smaller rules into a bigger one

2013-11-18 Thread gianluca torta
I am not familiar with instaparse, but the parser may be reasoning as follows: - Exposure matches a PK TOKEN that is preferred over WORD TOKEN, so it is parsed as PK TOKEN - to matches a WORD TOKEN that is not preferred, but there's no other choice, so it is parsed as a WORD TOKEN - ... I

Re: Pedestal introduction question

2013-07-04 Thread gianluca torta
Hi, I am pretty new to clojure and trying to learn a lot from this great list anyway, looking at the code you point to, it seems that the name templates has two roles: - one deriving from: (:require ... [io.pedestal.app.render.push.templates :as templates] ...) - one

Re: Pedestal introduction question

2013-07-04 Thread gianluca torta
right, sorry! I found the double role of template in this sample file on the pedestal repo: https://github.com/pedestal/samples/blob/master/chat/chat-client/app/src/chat_client/web/rendering.cljs maybe the doc you originally refer to is inspired by this, but something got lost in the doc