Re: hash-map initialization issue

2013-04-02 Thread MichaƂ Marczyk
On 28 March 2013 22:51, Ryan wrote: > Thanks for your explanation Jonathan. I am still a bit confused however what > is the proper solution here. Should i use an anonymous function instead to > do what I want or can it be done with the #() syntax? Just wanted to add that the #() syntax is just sh

Re: hash-map initialization issue

2013-04-02 Thread Ryan
Thanks Gary, it didn't cross my mind that i can use the # reader with the threading macro :) On Tuesday, April 2, 2013 4:15:58 PM UTC+3, Gary Verhaegen wrote: > > And there's the threading macro : #(-> {:foo %}) > > On 1 April 2013 07:12, Ryan > wrote: > > Thanks for your input guys > > > > R

Re: hash-map initialization issue

2013-04-02 Thread Ryan T.
Thanks Gary, it didn't cross my mind that i can use the # reader with the threading macro :) On Tue, Apr 2, 2013 at 4:15 PM, Gary Verhaegen wrote: > And there's the threading macro : #(-> {:foo %}) > > On 1 April 2013 07:12, Ryan wrote: > > Thanks for your input guys > > > > Ryan > > > > > > On

Re: hash-map initialization issue

2013-04-02 Thread Gary Verhaegen
And there's the threading macro : #(-> {:foo %}) On 1 April 2013 07:12, Ryan wrote: > Thanks for your input guys > > Ryan > > > On Sunday, March 31, 2013 11:11:08 AM UTC+3, Alex Baranosky wrote: >> >> There's also 'for' >> >> (defn my-function [foo-id a-keyword a-list] >> (for [m a-list] >>

Re: hash-map initialization issue

2013-03-31 Thread Ryan
Thanks for your input guys Ryan On Sunday, March 31, 2013 11:11:08 AM UTC+3, Alex Baranosky wrote: > > There's also 'for' > > (defn my-function [foo-id a-keyword a-list] > (for [m a-list] > {:foo_id foo-id (keyword a-keyword) (:BAR_KEY m)})) > > > On Sun, Mar 31, 2013 at 12:57 AM, JvJ >w

Re: hash-map initialization issue

2013-03-31 Thread Alex Baranosky
There's also 'for' (defn my-function [foo-id a-keyword a-list] (for [m a-list] {:foo_id foo-id (keyword a-keyword) (:BAR_KEY m)})) On Sun, Mar 31, 2013 at 12:57 AM, JvJ wrote: > ...even cheezier, use do > #(do {:foo %}) > > > On Saturday, 30 March 2013 23:58:31 UTC-4, JvJ wrote: >> >> He

Re: hash-map initialization issue

2013-03-31 Thread JvJ
...even cheezier, use do #(do {:foo %}) On Saturday, 30 March 2013 23:58:31 UTC-4, JvJ wrote: > > Here's a cheezy hack, use identity. > > #(identity {:foo %}) > > On Thursday, 28 March 2013 17:51:10 UTC-4, Ryan wrote: >> >> Thanks for your explanation Jonathan. I am still a bit confused however >

Re: hash-map initialization issue

2013-03-30 Thread JvJ
Here's a cheezy hack, use identity. #(identity {:foo %}) On Thursday, 28 March 2013 17:51:10 UTC-4, Ryan wrote: > > Thanks for your explanation Jonathan. I am still a bit confused however > what is the proper solution here. Should i use an anonymous function > instead to do what I want or can i

Re: hash-map initialization issue

2013-03-28 Thread Jonathan Fischer Friberg
No problem, glad to be of help. :) Jonathan On Thu, Mar 28, 2013 at 11:19 PM, Ryan wrote: > Thanks for all your help Jonathan :) I went with the standard fn syntax, > its a two-liner anyway so not a big of deal :) > The important part here was that I learned that #() executes the content > as

Re: hash-map initialization issue

2013-03-28 Thread Ryan
Thanks for all your help Jonathan :) I went with the standard fn syntax, its a two-liner anyway so not a big of deal :) The important part here was that I learned that #() executes the content as a function, very helpful! Ryan On Friday, March 29, 2013 12:08:04 AM UTC+2, Jonathan Fischer Friber

Re: hash-map initialization issue

2013-03-28 Thread Jonathan Fischer Friberg
It can still be done with the #(), with for example the hash-map function. It's basically the same as the {} but as a function, like this: (hash-map :a 3 :b 4) => {:a 3, :b 4} So you should be able to write the function as: #(hash-map :foo_id foo-id (keyword a-keyword) (:BAR_KEY %)) I think you s

Re: hash-map initialization issue

2013-03-28 Thread Ryan
Thanks for your explanation Jonathan. I am still a bit confused however what is the proper solution here. Should i use an anonymous function instead to do what I want or can it be done with the #() syntax? Hyphens is my preferred way as well, but, those keys represent sql columns which they use

Re: hash-map initialization issue

2013-03-28 Thread Jonathan Fischer Friberg
It's because the #() syntax always calls the content as a function. So #(...) is the same as (fn [] (...)). In your case, #({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)}) is the same as: (fn [%] ({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)})) Note the extra () around {}. In other words, y