Using macro to generate boilerplate keywords

2014-01-17 Thread Kashyap CK
Hi, I am exploring javax.sound.midi using clojure and while creating keywords for notes I wonder if I could use macros to generate the keywords - (defn note-2-num [n] (let [ m { :C1 0 :C#1 1 :D1 2 :D#1 3 :E1 4 :F1 5

Re: Using macro to generate boilerplate keywords

2014-01-17 Thread Timothy Baldridge
perhaps something like: (zipmap (range) (for [octave (range 8) key [C C# D D# ...]] (keyword (str key octave Timothy On Fri, Jan 17, 2014 at 9:21 AM, Kashyap CK ckkash...@gmail.com wrote: Hi, I am exploring javax.sound.midi using

Re: Using macro to generate boilerplate keywords

2014-01-17 Thread Alex Walker
Is a macro necessary? https://gist.github.com/alexpw/8476780 On Friday, January 17, 2014 10:21:52 AM UTC-6, Kashyap CK wrote: Hi, I am exploring javax.sound.midi using clojure and while creating keywords for notes I wonder if I could use macros to generate the keywords - (defn note-2-num

Re: Using macro to generate boilerplate keywords

2014-01-17 Thread Kashyap CK
Thanks Alex ... I believe, pre-computing the map upfront would be more efficient. But yeah, looks like macros are not required as Timothy has shown. Regards, Kashyap On Friday, January 17, 2014 10:20:31 PM UTC+5:30, Alex Walker wrote: Is a macro necessary?

Re: Using macro to generate boilerplate keywords

2014-01-17 Thread Kashyap CK
Thank you so much Timothy .. this is just what I was looking for ... On Friday, January 17, 2014 10:03:12 PM UTC+5:30, tbc++ wrote: perhaps something like: (zipmap (range) (for [octave (range 8) key [C C# D D# ...]] (keyword (str key