generating a list of random numbers
Hi all, I have the nagging feeling that I'm missing a simple solution. Say I want a list of a 100 rand-int 10 numbers. Currently, I create that by doing (map (fn [_] (rand-int 10)) (range 100)). Is there an easier way? -- 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
Re: fast development through clojure repl
I never used emacs but in some videos I sah people doing cool stuff in it. So I started learning. I'm still a noob but I really like it already better then any IDE I have used. It makes working with the repl easy. On Jul 28, 1:49 am, Josh Stratton wrote: > > If you're rather looking for overall workflows/program structure/best > > practices etc - good question. :) > > I was actually, but the integration with emacs is important, too. > I'll have to get SLIME working. > > Thanks. -- 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
Re: generating a list of random numbers
Hi, You could do: (repeatedly 100 #(rand-int 10)) HTH, -- Laurent 2010/7/28 bOR_ > Hi all, > > I have the nagging feeling that I'm missing a simple solution. Say I > want a list of a 100 rand-int 10 numbers. Currently, I create that by > doing (map (fn [_] (rand-int 10)) (range 100)). Is there an easier > way? > > -- > 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 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
Re: generating a list of random numbers
On 28 July 2010 09:24, bOR_ wrote: > Hi all, > > I have the nagging feeling that I'm missing a simple solution. Say I > want a list of a 100 rand-int 10 numbers. Currently, I create that by > doing (map (fn [_] (rand-int 10)) (range 100)). Is there an easier > way? I think Laurent's answer is better, but this also works: (for [i (range 100)] (rand-int 10)) -- Michael Wood -- 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
Re: fast development through clojure repl
You mention one use case of the repl, but I think that's just one part of a typical workflow. Say you decide to write a function, you start half way and then you realize that you need to group pairs of items in a vector and then turn these pairs into a vector of maps. Oh, but what order are the arguments for map, and how does partition work again? Hit the repl and (doc partition), do some small experiments to figure out how to do what you want to do, and then once you get it working paste the code into your function. Then once the function is written it's nice to test it out on the repl; pass in a variety of args, make sure it works, and move on. For more complicated functions that are harder to test by eye or that require more complex inputs, it might be faster to write a unit test function, and then call that from the repl. I normally write the unit test directly below the function definition during development, and then periodically I'll pull all the tests into a separate file just to keep things tidy. Not much of a repl tutorial, but if you try out these steps you'll get the feel for it pretty quick. -Jeff On Jul 27, 7:11 pm, Josh Stratton wrote: > I think one of the major advantages touted by languages like clojure > are faster development times by adding to the program as you go via > the REPL. > > I, however, have still been doing a more traditional > write/save/execute debugging workflow without the REPL, which doesn't > seem to get the real benefits of the REPL. From what I understand, > when you take full advantage of the REPL, you can quickly tweak things > in the code like if a function breaks, you can rewrite it and start > again. Say for example a GUI is opened and a button press calls some > clojure function. If there's a bug in that, I can redefine that > function in the REPL and just click again on the button to continue > without losing the state of the program when I recompile. Is this > correct? > > Are there any tutorials specific to developing and debugging large > clojure apps through the REPL? -- 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
Re: generating a list of random numbers
Ah. A sneaky difference between repeat and repeatedly there then :). Good to remember! On Jul 28, 9:35 am, Laurent PETIT wrote: > Hi, > > You could do: > > (repeatedly 100 #(rand-int 10)) > > HTH, > > -- > Laurent > > 2010/7/28 bOR_ > > > > > Hi all, > > > I have the nagging feeling that I'm missing a simple solution. Say I > > want a list of a 100 rand-int 10 numbers. Currently, I create that by > > doing (map (fn [_] (rand-int 10)) (range 100)). Is there an easier > > way? > > > -- > > 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 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
Re: newbie question casting java classes/interfaces
What error or other message do you get? Also, which MetaModelImpl is this? I assume it's not the JPA one. - Chas On Jul 27, 2010, at 2:38 PM, Sandeep Puri wrote: The snippet below works fine GraphDatabaseService neo = new EmbeddedGraphDatabase(dbpath); MetaModel model = new MetaModelImpl((NeoService) neo); Where MetaModelImpl expects a NeoService trying to do the same thing in clojure (let [^NeoService neo (EmbeddedGraphDatabase. dbpath) model (MetaModelImpl. neo)] ...) does not.. am I allowed to typecast any class what am I doing wrong? Am a newbie to clojure and am trying to us the neo4j libraries includin gthe MetaModel components of neo4j -- 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 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
Re: Dynamic defrecord
The confusion over type and instance was a sloppy example. Sorry. But in your solution I'm confused by one thing. You create and instance of Foo in the let and then assoc the new value of List1 to it. This has two problems. One is that the loaded data is not permanent. The other is that there is no way to add List2 to the MyFoo record. (I've decided to not use MyFoo at all. Instead I have a (def List1 (ref nil)) defined and then do a ref-set to it when the data is loaded.This seems much simpler and works. I then can do a def for List2, List3, etc.) It seem to me there should be some way to load a record at run time without breaking the immutability laws.Once the dynamic data is loaded, the record becomes immutable and will never be changed again.It's unrealistic to imagine that we always know at compile time what the values of a record will be. I'm not a compiler person so I have no idea how to do such a thing and no idea if it is possible. On Jul 27, 5:23 pm, Stuart Halloway wrote: > Hi Bill, > > There are several issues here: > > (1) A confusion of record and instance. You are asking for the :list1 field > from foo, the record type, not from an instance of the type. > > (:list1 foo) s/b (:list1 MyFoo) > > (2) You are ignoring the return value of assoc. Remember, Clojure data > structures are immutable. To actually assign something you need to hold on to > the return value of the expression (or use a reference type if you really > want an identity). > > (3) The capitalization choices facilitate confusion. You are using "foo" for > a record/class name, where both Java and Clojure style would dictate "Foo". > Then you use "MyFoo" for a top-level def, where Clojure style would encourage > "my-foo". > > The following code demonstrates these ideas. > > ;; stubbed so example can be run > (defn load-data-from-file > [x] :stub) > > (defrecord Foo [list1 list2]) > > (defn get-data [path] > (let [list1Data (load-data-from-file path) > f (Foo. nil nil) > f (assoc f :list1 list1Data)] > (:list1 f))) > > (get-data "fakepath") > > Regards, > Stu > > Stuart Halloway > Clojure/corehttp://clojure.com> All the examples of defrecord I see seem > simple enough and when I > > experiment in the REPL I get things to work as they should. However, > > when I move to 'real' code I can't get it to work at all. > > > The problem at hand is simple enough - I want to create a record that > > hold records. For example I have (defrecord foo [list1, list2]) > > where list1 and list2 are defined records themselves. The issue is > > that the data in list1 and list2 is dynamic - it is loaded from a file > > at run time. So I do the following: > > > (def MyFoo (foo. nil nil)) > > > (defn get-data [path] > > (let [list1Data (load-data-from-file path)] ; fill in the record > > for list 1 > > (assoc MyFoo :list1 list1Data) ; assign the data > > record to the foo record > > (:list1 foo) > > )) > > > As I say, if I do this non-dynamically in the REPL I get the proper > > result. > > > In my program (using let) (:list1 foo) always remains nil. What am > > I doing wrong? And how can I get the fields of foo to take on the > > dynamic data. > > > Bill > > > -- > > 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 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
Re: Clojure finally on SPOJ!
Maybe SPOJ treat clojure as script language. In fact, though clojure is quite fast, loading the clojure.jar library takes a bit of time. And SPOJ count the class loading time into the running time. If the Judge Machine is similar to ideone.com, maybe the clojure.jar loading time is about 0.6~0.7s. Only the class loading time will TLE the problem if there is more than 2 cases. I hope It's not true... On Jul 27, 5:39 pm, Matthias Schneider wrote: > And on nearly all problems Clojure isn't an accepted language (yet?). > Does the person who submitted the problem has to update this? > > -matthias > > On Jul 25, 12:34 pm, Cachou wrote: > > > > > Even the "TEST" Problem will TLE!!! > > > My code is here: > > > (ns spoj-test) > > > (defn read-int > > [] > > (let [s (read-line)] > > (Integer/parseInt s))) > > > (defn main > > [] (let [n (read-int)] > > (when (not (== 42 n)) > > (println n) > > (recur > > > (main) > > > the sample input is OK. > > > On Jul 25, 3:51 pm, sphere research wrote: > > > > Hi, > > > > now, you can solve problems/submit problems in Clojure on SPOJ, > > > > good luck, > > > > regards, > > > SPOJ Team > > > > ps. > > > > We are very happy to announce that users' accounts have finally > > > appeared on Ideone :) > > > If you liked Ideone as it has been so far, you will like the new one > > > even more. The most important new features available for Ideone users > > > are: > > > > * management panel where users can view and group their pastes, > > > * personalized access to Ideone API > > > * and public folders which allow to publish and share a group of > > > pastes at one go. -- 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
Re: generating a list of random numbers
Hi, bOR_ Yes, there is easier variant: (repeatedly 100 #(rand-int 10)) On Wed, Jul 28, 2010 at 10:24 AM, bOR_ wrote: > Hi all, > > I have the nagging feeling that I'm missing a simple solution. Say I > want a list of a 100 rand-int 10 numbers. Currently, I create that by > doing (map (fn [_] (rand-int 10)) (range 100)). Is there an easier > way? > > -- > 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 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
Re: destructuring using :as in fn arg vector
Ahhh! It's so obvious now that I'm almost embarrassed. Thank you Randy Cam On Jul 27, 4:17 pm, Randy Hudson wrote: > The form you're looking for is (defn foo [ & [a b :as c]] ...) > > On Jul 27, 2:57 pm, Cameron wrote: > > > > > Hey all, just wondering if this is normal or not. There seems to be > > something weird going on with :as in a functions arg vector. > > > This little example works as I'd expect... > > user=> (defn foo [[a b :as c]] c) > > #'user/foo > > user=> (foo [1 2]) > > [1 2] > > > But this one does not > > user=> (defn foo [a b :as c] c) > > java.lang.Exception: Unsupported binding form: :as (NO_SOURCE_FILE:11) > > user=> > > > I would expect to call the second example like (foo 1 2) and have it > > return [1 2]. > > > So if this happens to be expected behavior, is there an idiomatic way > > to do destructure args but also refer to them all as one list? -- 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
Re: Newbie style question - implementing binary search
Thanks. That does look clearer. Dave On Jul 27, 4:15 pm, Joost wrote: > > I think the main thing that's confusing here is that you're messing > with offsets and split collections at once. At least is was confusing > to me. :) > > I think for binary search (which implies random lookup is ~ O(n) > anyway) it's clearer if you stick to offsets. > > A few remarks regarding style: > > You don't need letfn; personally I think it's clearer to use either > two separate functions or - in this case - specialize on the > arguments. > > If you define assert_equal as a function, you won't get any good > feedback if the assert fails. Use a macro instead. > > Here's what I made: > > (defn chop > ([val coll] > (chop val coll 0 (count coll))) > ([val coll left right] ; range to test is left ... right - 1, which > makes the code a bit cleaner > (if (< left right) ; are we still in a valid range? > (let [halve (int (/ (- right left) 2)) > index (+ left halve) > found-value (coll index)] > (cond > (= val found-value) index > (> val found-value) (recur val coll (inc index) right) > (< val found-value) (recur val coll left index))) > -1))) ; not found > > (defmacro assert_equal > [v1 v2] > `(assert (= ~v1 ~v2))) > > Note that all of this is pretty low-level but I think it looks kinda > nice and readable. -- 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
A bug in clojure.core/bean?
Hey folks, It was suggested to me in IRC to check here before filing a bug report. I've noticed that the mappish object returned by clojure.core/ bean will throw an NPE if you try to access a missing key. Since normal maps don't do this, and I can't think of any reason you would want that behavior, it seems to me a bug. Any thoughts? Gary -- 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
Re: Dynamic defrecord
Hi, 2010/7/28 WoodHacker > The confusion over type and instance was a sloppy example. Sorry. > > But in your solution I'm confused by one thing. You create and > instance of Foo in the let and then assoc the new value of List1 to > it. > This has two problems. One is that the loaded data is not > permanent. The other is that there is no way to add List2 to the > MyFoo record. > > (I've decided to not use MyFoo at all. Instead I have a (def List1 > (ref nil)) defined and then do a ref-set to it when the data is > loaded.This seems > much simpler and works. I then can do a def for List2, List3, etc.) > > It seem to me there should be some way to load a record at run time > without breaking the immutability laws.Once the dynamic data is > loaded, the record becomes immutable and will never be changed > again.It's unrealistic to imagine that we always know at compile > time what the values of a record will be. > Here a record is no different than any other persistent datastructure: you must "build" you data inside-out: first the leaves, then the parents, etc. So in your case, you should first "build" list1 and list2, and then you can build an instance of MyFoo : (MyFoo. list1 list2). There's something coming around the corner, for post 1.2, which used to be named "cells" on IRC, and is now named "Pods" by Rich, which will enable to isolate an "island of mutation" for the purpose of efficiently creating an immutable value in several steps, from one or many threads (aka "processes"). Maybe this could address some of the issues you're seeing, maybe not. HTH, -- Laurent -- 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
Re: Dynamic defrecord
Hi Bill, Are your looking for something as simple as this: (defrecord Foo [x]) (defn load-a-record-at-runtime "Loads a record value from a file" [f] (Foo. (slurp f))) Or is there some subtlety here? Stu > The confusion over type and instance was a sloppy example. Sorry. > > But in your solution I'm confused by one thing. You create and > instance of Foo in the let and then assoc the new value of List1 to > it. > This has two problems. One is that the loaded data is not > permanent. The other is that there is no way to add List2 to the > MyFoo record. > > (I've decided to not use MyFoo at all. Instead I have a (def List1 > (ref nil)) defined and then do a ref-set to it when the data is > loaded.This seems > much simpler and works. I then can do a def for List2, List3, etc.) > > It seem to me there should be some way to load a record at run time > without breaking the immutability laws.Once the dynamic data is > loaded, the record becomes immutable and will never be changed > again.It's unrealistic to imagine that we always know at compile > time what the values of a record will be. > I'm not a compiler person so I have no idea how to do such a thing and > no idea if it is possible. > > On Jul 27, 5:23 pm, Stuart Halloway wrote: >> Hi Bill, >> >> There are several issues here: >> >> (1) A confusion of record and instance. You are asking for the :list1 field >> from foo, the record type, not from an instance of the type. >> >> (:list1 foo) s/b (:list1 MyFoo) >> >> (2) You are ignoring the return value of assoc. Remember, Clojure data >> structures are immutable. To actually assign something you need to hold on >> to the return value of the expression (or use a reference type if you really >> want an identity). >> >> (3) The capitalization choices facilitate confusion. You are using "foo" for >> a record/class name, where both Java and Clojure style would dictate "Foo". >> Then you use "MyFoo" for a top-level def, where Clojure style would >> encourage "my-foo". >> >> The following code demonstrates these ideas. >> >> ;; stubbed so example can be run >> (defn load-data-from-file >> [x] :stub) >> >> (defrecord Foo [list1 list2]) >> >> (defn get-data [path] >> (let [list1Data (load-data-from-file path) >> f (Foo. nil nil) >> f (assoc f :list1 list1Data)] >> (:list1 f))) >> >> (get-data "fakepath") >> >> Regards, >> Stu >> >> Stuart Halloway >> Clojure/corehttp://clojure.com> All the examples of defrecord I see seem >> simple enough and when I >>> experiment in the REPL I get things to work as they should. However, >>> when I move to 'real' code I can't get it to work at all. >> >>> The problem at hand is simple enough - I want to create a record that >>> hold records. For example I have (defrecord foo [list1, list2]) >>> where list1 and list2 are defined records themselves. The issue is >>> that the data in list1 and list2 is dynamic - it is loaded from a file >>> at run time.So I do the following: >> >>> (def MyFoo (foo. nil nil)) >> >>> (defn get-data [path] >>> (let [list1Data (load-data-from-file path)] ; fill in the record >>> for list 1 >>> (assoc MyFoo :list1 list1Data) ; assign the data >>> record to the foo record >>> (:list1 foo) >>> )) >> >>> As I say, if I do this non-dynamically in the REPL I get the proper >>> result. >> >>> In my program (using let) (:list1 foo) always remains nil.What am >>> I doing wrong? And how can I get the fields of foo to take on the >>> dynamic data. >> >>> Bill >> >>> -- >>> 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 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 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
Re: generating a list of random numbers
> (repeatedly 100 #(rand-int 10)) Hm... on 1.1.: user=> (repeatedly 100 #(rand-int 10)) java.lang.IllegalArgumentException: Wrong number of args passed to: core$repeatedly (NO_SOURCE_FILE:0) user=> but, could be solved with: user=> (take 100 (repeatedly #(rand-int 10))) -- 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
Re: Dynamic defrecord
> It seem to me there should be some way to load a record at run time > without breaking the immutability laws. Once the dynamic data is > loaded, the record becomes immutable and will never be changed > again. Actually, that's how records work and is exactly the behavior of the initial (foo. nil nil), after which the record is loaded and immutable. If the loaded data must be bound to MyFoo: (def MyFoo (foo. (load-data-from-file f1) (load-data-from-file f2))) or you might consider making Myfoo a ref instead of each subrecords, seems simpler that way. -- 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
slime-fancy
If I use lein swank and have (slime-setup '(slime-repl)) in my .emacs, the repl doesn't work (try (+ 1 2)). Changing this to (slime-setup '(slime-repl)) fixes the problem. Anyone know why this should be? SBCL, CCL64, KAWA and QiII work fine with (slime-setup '(slime-repl)). -- 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
Re: slime-fancy
Re Dave at "Wed, 28 Jul 2010 10:25:13 -0700 (PDT)" wrote: D> If I use lein swank and have (slime-setup '(slime-repl)) in my .emacs, D> the repl doesn't work (try (+ 1 2)). Changing this to (slime-setup D> '(slime-repl)) fixes the problem. Anyone know why this should be? D> SBCL, CCL64, KAWA and QiII work fine with (slime-setup '(slime-repl)). As I remember, slime-fancy includes slime-autodoc, that doesn't work with Clojure in vanila SLIME. Set (setq slime-use-autodoc-mode nil) to disable it -- With best wishes, Alex Ott, MBA http://alexott.blogspot.com/http://alexott.net/ http://alexott-ru.blogspot.com/ Skype: alex.ott -- 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
todays project.
Hi all, Todays' project involved modelling what happens if an infected flea enters a burrow of gerbils. The biology is as follows: fleas feed daily on gerbils, and drop off after every meal, only to climb on one of the gerbils again. There is a small chance that a feeding flee infects a gerbil with the plague. Once a gerbil is infected, it takes 3 days for it to become infectious, after which any flea feeding on it will also become infected. I needed to answer a few questions, two of which were: 1. Once there are a few fleas infected in the burrow, does any influx of infected fleas from the outside world still matter? 2. How long does it take before a burrow is fully infected. Lacking a good intuition on how I could approximate the within-burrow process in a larger meta- population model, I decided to model what happens in the burrow. The code is here, for whoever wants an example of a bit of modelling with clojure. It is pretty neat (to me), as I modeled the timeline of a burrow infection as a lazy seq, which could just be read out. I am exploring what I can do model-wise with lazy seqs. They often don't fit for modelling, but this time they did nicely. Warning: the code is pretty ugly in the part where I shuffle the healthy (susceptible) fleas and infected fleas (sfleas and ifleas) over the gerbils in the burrow (I was out of concentration when I wrote that part). http://dl.dropbox.com/u/150929/burrows.clj It also features a nice example of an incanter graph. http://dl.dropbox.com/u/150929/dist.png -- 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
Re: slime-fancy
Thanks Alex, that worked. -- 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
Re: bit-and type hint
thanks! that worked. the cast to int makes sense is since the jvm will convert the byte value to an int for the & computation On Jul 27, 2:47 pm, Joost wrote: > Peter Ryan wrote: > > I am trying to avoid a reflective callback with this function: > > > (defn unsign-byte-from-buffer [#^java.nio.ByteBuffer buffer] > > (bit-and 0xFF (.get buffer))) > > > (println "should be 254" (unsign-byte-from-buffer (java.nio.ByteBuffer/ > > wrap (byte-array [(byte 0xFE)] > > > when run with (set! *warn-on-reflection* true) I receive the following > > error: > > > Reflection warning...type-hint.clj:7 - call to and can't be resolved. > > There is no bit-and for bytes; you need ints. At least that's what it > looks like to me. > > (defn unsign-byte-from-buffer [#^java.nio.ByteBuffer buffer] > (bit-and 0xff (int (.get buffer > > seems to solve the issue for me. -- 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
Re: Feedback on Clojure web development post
Excellent job! It's great that you're willing to devote the time to help others learn more quickly & easily! On Jul 27, 9:42 am, Savanni D'Gerinel wrote: > I thought this was pretty awesomely informative, including the > deployment to Amazon Cloud. I already playing through and doing > development with Compojure and Hiccup, and I found a lot of new things > in here for me to investigate and potentially put to good use. > > -- > Savanni > > > > On Sat, 2010-07-24 at 00:30 -0700, Mark McGranaghan wrote: > > Hi All, > > > I recently posted to my blog on the process of developing and > > deploying a simple Clojure web application: > > >http://mmcgrana.github.com/2010/07/develop-deploy-clojure-web-applica... > > > The purpose of this post is twofold. The first is to provide some > > documentation in the form of a complete, deployable Clojure web app > > and associated commentary and instructions. To that end I hope you > > find the post useful and that you feel free to ask any questions you > > may have. > > > The second purpose is to elicit feedback from the community on how > > they would or have approached the problem of developing and deploying > > Clojure web applications. > > > I'm particularly interested in the specifics of how people tie > > together and round out entire apps with e.g. logging and exception > > handling, how they develop apps locally, and how they deploy them to > > production. I think the most useful basis for discussing things like > > this is complete working examples of applications and associated > > instructions for how to deploy them. I doubt there are very many such > > open-source apps floating around, but if anyone has one to share I > > would love to see it. > > > Even if you don't have a complete app to share, I would love to hear > > your comments and see your code snippets on the specific aspects of > > the development and deployment process that I covered (or perhaps > > omitted) in the post. > > > - Mark -- 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
Idea for personal Clojure project
I want to write a clojure program that searches for similarities of words in the english language and places them in a graph, where the distance between nodes indicates their similarity. I don't mean syntactical similarity. Related contextual meaning is closer to the mark. For instance: "fish" and "reel" don't have much similarity, but in the context of fishing they do, so the distance in such a graph wouldn't be very large. I'm sure research has been done in this area (I suspect with no small portion belonging to google), so can anybody point me in the right direction? Thanks. -- 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
Re: Idea for personal Clojure project
Wordnet is the main existing thing that comes to mind as related to your idea. -- 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
Re: A bug in clojure.core/bean?
Looks like a bug to me. Fixed it locally with the change below, after the Java implementations where atVal(x) delegates to atVal(x,null). --- src/clj/clojure/core_proxy.clj |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/clj/clojure/core_proxy.clj b/src/clj/clojure/ core_proxy.clj index dc3514d..1a1b1a7 100644 --- a/src/clj/clojure/core_proxy.clj +++ b/src/clj/clojure/core_proxy.clj @@ -391,7 +391,7 @@ [] (containsKey [k] (contains? pmap k)) (entryAt [k] (when (contains? pmap k) (new clojure.lang.MapEntry k (v k - (valAt ([k] (v k)) + (valAt ([k] (. this valAt k nil)) ([k default] (if (contains? pmap k) (v k) default))) (cons [m] (conj (snapshot) m)) (count [] (count pmap)) -- On Jul 28, 5:04 am, gfrlog wrote: > Hey folks, > > It was suggested to me in IRC to check here before filing a bug > report. I've noticed that the mappish object returned by clojure.core/ > bean will throw an NPE if you try to access a missing key. Since > normal maps don't do this, and I can't think of any reason you would > want that behavior, it seems to me a bug. Any thoughts? > > Gary -- 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
Re: Idea for personal Clojure project
This is a hard problem. If you go by degrees and shades of synonymity, it can (and has been) done manually - see Visual Thesaurus (http:// www.visualthesaurus.com/). But for grouping based on the same semantic topics - that's pretty difficult. You could do it based on co-location in a corpus, but there'd be a lot of noise and results wouldn't be perfect. Maybe by using a syntactic parser to pull out nouns and verbs you could improve the results a bit. You could probably get something. Your best bet is definitely a statistical, corpus-linguistics based approach.. Actual semantic parsing isn't anywhere close, yet. The consensus of those I've talked to seems to be that we won't have "full" semantic language processing until we have strong AI - in fact, the two are very probably equivalent. Natural language is just too full of ambiguity and context. For example, there's probably a great many *people* in the world who'd have a hard time linking the words "fish" and "reel", if they haven't fished before. And a lot of people would probably associate "reel" with "dance" more strongly than "fish". The task potentially would strain even the verbal prowess of a non- linguist human, and computers are much more limited. On Jul 28, 4:58 pm, Daniel wrote: > I want to write a clojure program that searches for similarities of > words in the english language and places them in a graph, where the > distance between nodes indicates their similarity. I don't mean > syntactical similarity. Related contextual meaning is closer to the > mark. > > For instance: "fish" and "reel" don't have much similarity, but in the > context of fishing they do, so the distance in such a graph wouldn't > be very large. > > I'm sure research has been done in this area (I suspect with no small > portion belonging to google), so can anybody point me in the right > direction? > > Thanks. -- 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
Re: Idea for personal Clojure project
On 7/28/10 5:34 PM, Mark Engelberg wrote: > Wordnet is the main existing thing that comes to mind as related to your > idea. > You might also want to look into Freebase. Here's a Clojure client you can use to query their data. http://github.com/rnewman/clj-mql signature.asc Description: OpenPGP digital signature
Re: newbie question casting java classes/interfaces
It's not the JPA one. It's the meta-model work-in-progress for the neo4j project. It so happens I was using neo4j-1.1-snapshot with an older meta-model implementation. I pulled the meta-model-0.9 snapshot which seems to work.fine. But the above question is still valid in a generic sense.. On Jul 28, 4:27 am, Chas Emerick wrote: > What error or other message do you get? Also, which MetaModelImpl is > this? I assume it's not the JPA one. > > - Chas > > On Jul 27, 2010, at 2:38 PM, Sandeep Puri wrote: > > > > > The snippet below works fine > > GraphDatabaseService neo = new EmbeddedGraphDatabase(dbpath); > > MetaModel model = new MetaModelImpl((NeoService) neo); > > > Where MetaModelImpl expects a NeoService > > > trying to do the same thing in clojure > > > (let [^NeoService neo (EmbeddedGraphDatabase. dbpath) > > model (MetaModelImpl. neo)] > > ...) > > > does not.. > > am I allowed to typecast any class > > what am I doing wrong? > > > Am a newbie to clojure and am trying to us the neo4j libraries > > includin gthe MetaModel components of neo4j > > > -- > > 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 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
Re: newbie question casting java classes/interfaces
Sorry didn't answer your question.. The error I got was "Cannot cast GraphDBService to NeoService" On Jul 28, 8:54 pm, Sandeep Puri wrote: > It's not the JPA one. It's the meta-model work-in-progress for the > neo4j project. > > It so happens I was using neo4j-1.1-snapshot with an older meta-model > implementation. > I pulled the meta-model-0.9 snapshot which seems to work.fine. > > But the above question is still valid in a generic sense.. > > On Jul 28, 4:27 am, Chas Emerick wrote: > > > > > What error or other message do you get? Also, which MetaModelImpl is > > this? I assume it's not the JPA one. > > > - Chas > > > On Jul 27, 2010, at 2:38 PM, Sandeep Puri wrote: > > > > The snippet below works fine > > > GraphDatabaseService neo = new EmbeddedGraphDatabase(dbpath); > > > MetaModel model = new MetaModelImpl((NeoService) neo); > > > > Where MetaModelImpl expects a NeoService > > > > trying to do the same thing in clojure > > > > (let [^NeoService neo (EmbeddedGraphDatabase. dbpath) > > > model (MetaModelImpl. neo)] > > > ...) > > > > does not.. > > > am I allowed to typecast any class > > > what am I doing wrong? > > > > Am a newbie to clojure and am trying to us the neo4j libraries > > > includin gthe MetaModel components of neo4j > > > > -- > > > 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 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
Re: Idea for personal Clojure project
A very good place to start searching about edit distances between words and some related stuff can be found on Peter Norvigs site at: http://norvig.com/spell-correct.html Also, try to find some wikipedia articles about the bm25 ranking algorithm, I used clojure for an assignment at school that required we write a little ranking mechanism with this algorithm and it's a pretty straightforward approach; not to hard to wrap your head around the whole thing. Can't quite remember if it did semantic stuff or just word simple frequency though. The hard part might be getting a training set. I'd offer you the file I had but I think I deleted it after the semester was over.. -Cameron On Jul 28, 2010, at 4:58 PM, Daniel wrote: > I want to write a clojure program that searches for similarities of > words in the english language and places them in a graph, where the > distance between nodes indicates their similarity. I don't mean > syntactical similarity. Related contextual meaning is closer to the > mark. > > For instance: "fish" and "reel" don't have much similarity, but in the > context of fishing they do, so the distance in such a graph wouldn't > be very large. > > I'm sure research has been done in this area (I suspect with no small > portion belonging to google), so can anybody point me in the right > direction? > > Thanks. > > -- > 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 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
Re: Log SQL in clojure.contrib.sql
I found: http://code.google.com/p/log4jdbc/ On Jul 27, 11:31 pm, ngocdaothanh wrote: > Hi, > > I would like to ask if there is a way to log SQL generated by > clojure.contrib.sql to console for inspection. > > Thanks. -- 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
Re: newbie question casting java classes/interfaces
Yes, this is a perfectly valid error, it simply means what it says. That it's impossible to cast an instance of EmbeddedGraphDatabase to the NeoService interface. The reason for this is of course that EmbeddedGraphDatabase does not implement the NeoService interface. As you said, you were mixing incompatible versions of the Neo4j packages, the NeoService interface was renamed to GraphDatabaseService before the release of Neo4j version 1.0. Cheers, Tobias On Thu, Jul 29, 2010 at 5:57 AM, Sandeep Puri wrote: > Sorry didn't answer your question.. > The error I got was "Cannot cast GraphDBService to NeoService" > > On Jul 28, 8:54 pm, Sandeep Puri wrote: > > It's not the JPA one. It's the meta-model work-in-progress for the > > neo4j project. > > > > It so happens I was using neo4j-1.1-snapshot with an older meta-model > > implementation. > > I pulled the meta-model-0.9 snapshot which seems to work.fine. > > > > But the above question is still valid in a generic sense.. > > > > On Jul 28, 4:27 am, Chas Emerick wrote: > > > > > > > > > What error or other message do you get? Also, which MetaModelImpl is > > > this? I assume it's not the JPA one. > > > > > - Chas > > > > > On Jul 27, 2010, at 2:38 PM, Sandeep Puri wrote: > > > > > > The snippet below works fine > > > > GraphDatabaseService neo = new EmbeddedGraphDatabase(dbpath); > > > > MetaModel model = new MetaModelImpl((NeoService) neo); > > > > > > Where MetaModelImpl expects a NeoService > > > > > > trying to do the same thing in clojure > > > > > > (let [^NeoService neo (EmbeddedGraphDatabase. dbpath) > > > > model (MetaModelImpl. neo)] > > > > ...) > > > > > > does not.. > > > > am I allowed to typecast any class > > > > what am I doing wrong? > > > > > > Am a newbie to clojure and am trying to us the neo4j libraries > > > > includin gthe MetaModel components of neo4j > > > > > > -- > > > > 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 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 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