Re: apply a function to a list and another parameter

2010-10-23 Thread Mike Meyer
On Fri, 22 Oct 2010 03:48:44 -0700 (PDT) Marc von Bihl wrote: > Hello, I am new to fucntional programming and have 2 questions: > > How can I apply a function to each element from a list and a second > parameter? > > (def lstr '("Hello1" "Hello2" "Hello3")) > > (defn addtoString [s1 s2] > (s

Re: Detecting a byte array -- byte[]

2010-10-23 Thread Dave Ray
This should do it: user=> (defn byte-array? [obj] (= Byte/TYPE (.getComponentType (class obj #'user/byte-array? user=> (byte-array? (byte-array [(byte 56) (byte 98)])) true user=> (byte-array? "") false user=> (byte-array? 99) false Hope that helps, Dave On Sat, Oct 23, 2010 at 11:53 PM, Sh

Re: Type Metadata

2010-10-23 Thread Shantanu Kumar
On Oct 24, 2:44 am, Chris Dow wrote: > Is there any way to attach Clojure defined 'metadata' to to types?  I > am trying to write a ORM for records and would like some way to attach > 'metadata' to types for the sake of mapping configuration.  Clojure's > built-in metadata apppears to be intende

Detecting a byte array -- byte[]

2010-10-23 Thread Shantanu Kumar
Hi Can anybody tell me how can I detect that a given object is a byte array? Or maybe show me how to write a (defn byte-array? [obj] ..) function? I want to be able to detect arrays of other types too - e.g. char[], Integer[] etc. I experimented a bit at the REPL: user=> (type (byte-array [(byte

Re: Trying to Load An Alias from Another Namespace into The Current Namespace

2010-10-23 Thread Stefan Rohlfing
I started Emacs again and now your solution is working! I have no idea why it did not work on the first restart but I am happy that I now can import aliases from another namespace. Thanks again for your help! Stefan On Oct 24, 10:00 am, Stefan Rohlfing wrote: > Hi Mikel, > > I tried your soluti

Re: Trying to Load An Alias from Another Namespace into The Current Namespace

2010-10-23 Thread Stefan Rohlfing
Hi Mikel, I tried your solution but am still not able to import the aliases from another namespace: This is what I did: - src/active-record/tns.clj (ns active-record.tns) (require '[active-record.user :as user]) (require '[acti

Re: apply a function to a list and another parameter

2010-10-23 Thread gaz jones
you could do something like: (map str ["hello1" "hello2" "hello3"] (repeat "world")) there is also a time macro: (time (println "oh hi")) On Fri, Oct 22, 2010 at 5:48 AM, Marc von Bihl wrote: > Hello, I am new to fucntional programming and have 2 questions: > > How can I apply a function to e

Type Metadata

2010-10-23 Thread Chris Dow
Is there any way to attach Clojure defined 'metadata' to to types? I am trying to write a ORM for records and would like some way to attach 'metadata' to types for the sake of mapping configuration. Clojure's built-in metadata apppears to be intended only for instances of types. I could use Java

Re: Setting Clojure “constants” at runtime (cros sposted to Stackoverflow)

2010-10-23 Thread Scott McKearney
This is literally the way we "think"...but if we all verbalized it this way... we would all have a stack overflow at runtime. On Fri, Oct 22, 2010 at 11:56 AM, Ralph wrote: > I have a Clojure program that I build as a JAR file using Maven. > Embedded in the JAR Manifest is a build-version numb

apply a function to a list and another parameter

2010-10-23 Thread Marc von Bihl
Hello, I am new to fucntional programming and have 2 questions: How can I apply a function to each element from a list and a second parameter? (def lstr '("Hello1" "Hello2" "Hello3")) (defn addtoString [s1 s2] (str s1 s2)) (apply (addtoString lstr "World")) - I need it for the follo

Clojure chat room at StackOverflow

2010-10-23 Thread edoloughlin
There's a pretty nice new chat feature at StackOverflow with the ability to link responses to original messages and chat room archiving. The Clojure room is at http://chat.stackoverflow.com/rooms/68/clojure -- You received this message because you are subscribed to the Google Groups "Clojure" gro

Re: Conj arrivals and Thursday night...

2010-10-23 Thread Nick Brown
As opposed to other times in which DC metro traffic is any better? That's actually what I'm braving Saturday evening as I'm leaving the conference early to get to my high school reunion. On Oct 18, 6:02 pm, Christopher Petrilli wrote: > I'll be driving down from DC, and probably arriving betwee

Re: Conj arrivals and Thursday night...

2010-10-23 Thread Sean Allen
What hackathon? On Thu, Oct 21, 2010 at 12:00 AM, Alex Miller wrote: > The Revelytix crew will be in around dinner time on Thursday. I'm > happy to spring for food during the hackathon courtesy of Strange Loop > or take a group out to dinner - whatever happens to be convenient. > > Alex Miller

Re: Wildcards on multimethod matching

2010-10-23 Thread Meikel Brandmeyer
Hi, if you only dispatch on types you can do it like this: (derive Object ::any) ; Also derive all of your ::keyword types from ::any. (defmulti foo #(vec (map type %&))) (defmethod foo [::any Integer] ...) But this won't work if you dispatch on actual values as you did in your example. For th

Wildcards on multimethod matching

2010-10-23 Thread Paul Richards
Hi, I have a multimethod which is dispatched on two arguments: (defmulti bar (fn [x y] [x y])) (defmethod bar [1 2] ..) (defmethod bar [3 4] ..) Is there a way I can define methods on this which use "wildcards"? E.g.: ; To match any call with 42 as the 1st argument (defmethod bar [42 _] ..) ;

problem connecting through slime

2010-10-23 Thread Glen Rubin
Hey!!! Maybe this is not the best place to ask this question, but seeing as how many of you use emacs to code I will give it a shot. I am using emacs, slime, swank combo. When I try to slime-connect, I initially get the following error: error in process filter: Symbol's value as variable is voi

Re: Reference Menu sans Transients

2010-10-23 Thread Christian Vest Hansen
+1 and a vote to also add these: http://clojure.org/protocols http://clojure.org/datatypes On Sat, Oct 23, 2010 at 12:08, ka wrote: > +1, besides adding transients, protocols 1.2 features, can we also > have a "Future" section after the Reference section? > > -- > You received this message becaus

Re: Strange behavior of PersistentTreeMap

2010-10-23 Thread andrei
Huh! I checked several times to pass to recur replaced string, but didn't noticed that I'm passing wrong string to .replace itself. Thank you! On Oct 23, 10:12 pm, Chris Perkins wrote: > On Oct 23, 2:10 pm, andrei wrote: > > > I modified procedure a bit to see interim results, and it's output >

Re: Strange behavior of PersistentTreeMap

2010-10-23 Thread Chris Perkins
On Oct 23, 2:10 pm, andrei wrote: > I modified procedure a bit to see interim results, and it's output > confused me even more. > > (defn replace-map >   "Replaces substrings in s from (keys m) by (vals m). " >   [s m] >   (loop [cur-str s, ks (keys m)] >     (if (empty? ks) >       cur-str >    

Re: Strange behavior of PersistentTreeMap

2010-10-23 Thread andrei
I modified procedure a bit to see interim results, and it's output confused me even more. (defn replace-map "Replaces substrings in s from (keys m) by (vals m). " [s m] (loop [cur-str s, ks (keys m)] (if (empty? ks) cur-str (let [replaced (.replace s (first ks) (m (first ks))

taking a first look at martin fowlers new book

2010-10-23 Thread faenvie
hi clojure-community, yesterday i got my copy of martin fowlers "Domain Specific Languages". I am quite sure, that this book, like others from the author, is an important one to own for the "pragmatic bookshelf". but reading the preface i found information that disappointed me a little bit: "..

Re: Setting Clojure “constants” at runtime (cros sposted to Stackoverflow)

2010-10-23 Thread B Smith-Mannschott
- Why not make the jar available at compile time as well? (e.g. maven scope="provided") - You could also use a delay: (def *version* (delay (get-version))) and then write @*version* when you want the version information at runtime. - Equivalently, you could memoize get-version and just call tha

Re: Setting Clojure “constants” at runtime (cros sposted to Stackoverflow)

2010-10-23 Thread Ralph
Won't work. The "def" gets executed at compile time, before the JAR file exists. On Oct 22, 3:55 pm, ataggart wrote: > (defn get-version [] >   (-> (str "jar:" (-> my.ns.name (.getProtectionDomain) >                                  (.getCodeSource) >                                  (.getLocatio

Re: Trying to Load An Alias from Another Namespace into The Current Namespace

2010-10-23 Thread Stefan Rohlfing
Thanks for the great explanation. This really makes using the clj- record library much more comfortable! Stefan PS. Sorry for replying late. I could not get my VPN to work which meant Google Groups was blocked for me. On Oct 21, 7:47 pm, Meikel Brandmeyer wrote: > Hi, > > you can't transfer a

Re: Reference Menu sans Transients

2010-10-23 Thread ka
+1, besides adding transients, protocols 1.2 features, can we also have a "Future" section after the Reference section? -- 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