I normally use
(defn digits [n]
(map #(Integer/parseInt (str %)) (seq (str n
You can adapt it to read in different bases easily.
sincerely,
--Robert McIntyre
On Thu, Feb 17, 2011 at 9:45 PM, Matthew Boston
wrote:
> How about using the Java api Character/getNumbericValue, like so:
>
> (
Great, that would be nice!
On Feb 18, 12:44 am, James Reeves wrote:
> On 17 February 2011 13:54, Zhenchao Li wrote:
>
> > By the way, when deploying the project it seems compojure somehow uses
> > java.rmi.server.UID if you use compojure.handler, and on app engine
> > java.rmi.server.UID is not
How about using the Java api Character/getNumbericValue, like so:
(defn explode-to-digits [number]
(map #(Character/getNumericValue %) (str number)))
user => (explode-to-digits 12345)
(1 2 3 4 5)
On Feb 17, 4:45 pm, Mike Meyer wrote:
> On Thu, 17 Feb 2011 15:27:47 -0600
>
> Michael Gardner w
Is there something besides type-hinting that I'm missing?
--
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
You can also create new types that act mostly like Clojure's existing
types using deftype and implementing things like IPersistentStack.
I posted code for (among other things) a bounded deque (using a
ringbuffer internally) here fairly recently.
The one limitation with these things is that they d
On Thu, 17 Feb 2011 15:27:47 -0600
Michael Gardner wrote:
> On Feb 17, 2011, at 1:36 PM, Mike Meyer wrote:
>
> > My turn...
> >
> > (defn to-digits
> > "Create a seq of digits from a number."
> > [i]
> > ^{:user/comment "For Euler Problems (Specifically 16)"}
> > (map {\0 0 \1 1 \2 2 \3 3 \
> If your domain model can be represented by a simple vector / map /
> set, then you have a very rich set of tools (in Clojure) to operate on
> your domain model. If your domain model is represented by fixed types,
> you have to write all sorts of wrapper functions to be able to apply
> those oper
On Feb 15, 4:12 pm, James Reeves wrote:
> On 15 February 2011 22:53, MS <5lvqbw...@sneakemail.com> wrote:
>
> >> So an electrical circuit is a data structure containing vertices and
> >> edges and describing how they are connected. Then you'll have some
> >> functions that operate on that data s
On Feb 15, 3:10 pm, Sean Corfield wrote:
> On Tue, Feb 15, 2011 at 2:53 PM, MS <5lvqbw...@sneakemail.com> wrote:
> > Because I'm not sure how else to use (for example) a graph library and
> > still have it look like a circuit, rather than a graph.
>
> Almost any such graph library is going to be
On Feb 17, 2011, at 1:36 PM, Mike Meyer wrote:
> My turn...
>
> (defn to-digits
> "Create a seq of digits from a number."
> [i]
> ^{:user/comment "For Euler Problems (Specifically 16)"}
> (map {\0 0 \1 1 \2 2 \3 3 \4 4 \5 5 \6 6 \7 7 \8 8 \9 9}
> (str i)))
>
> No assumption about repr
The code from my previous post is not correct, cons for example
affects metadata:
(def q (bounded-queue 3))
(meta q) -> { :bounded-size 3}
(meta (cons 1 qm)) -> nil
On Feb 17, 3:19 pm, pba wrote:
> Combining the two approaches:
> (defn bounded-queue [size]
> (with-meta (clojure.lang.Persisten
Combining the two approaches:
(defn bounded-queue [size]
(with-meta (clojure.lang.PersistentQueue/EMPTY) {:bounded-size
size}))
then look for (get (meta q) :bounded-size) in the protocol. Nice ...
Thanks!
On Feb 17, 11:04 am, Alexandre Patry
wrote:
> On 11-02-17 10:33 AM, pba wrote:> Not qui
On Thu, 17 Feb 2011 10:26:05 -0800 (PST)
JMatt wrote:
> On Feb 16, 10:29 pm, Andreas Kostler
> wrote:
> > Is there an easy and idiomatic way of getting the digits of a number in
> > clojure?
> Here is my attempt at this from a few months ago:
My turn...
(defn to-digits
"Create a seq of digit
On Feb 16, 10:29 pm, Andreas Kostler
wrote:
> Is there an easy and idiomatic way of getting the digits of a number in
> clojure?
Here is my attempt at this from a few months ago:
(defn to-digit
"Create a seq of digits from a number."
^{:user/comment "For Euler Problems (Specifically 16)"}
On 17 February 2011 13:54, Zhenchao Li wrote:
> By the way, when deploying the project it seems compojure somehow uses
> java.rmi.server.UID if you use compojure.handler, and on app engine
> java.rmi.server.UID is not usable. I'm using ring.middleware to
> construct a proper usable handler for app
This code looks it working:
(defn prime-2? [num]
(loop [i 2]
(if (<= (* i i) num)
(if (zero? (mod num i))
false
(recur (inc i)))
true)))
Any potential logic error?
On Feb 17, 2:01 am, Marek Stępniowski wrote:
> On Thu, Feb 17, 2011 at 12:34 AM, HB wrote:
> > I
On 11-02-17 10:33 AM, pba wrote:
Not quite, the queue size needs to be passed in at instantiation time
for example you may want to have a 10 or 100 element queue depending
on the element type. What I'm looking for is to somehow decorate the
queue (or some other object) with behavior constraints (
Not quite, the queue size needs to be passed in at instantiation time
for example you may want to have a 10 or 100 element queue depending
on the element type. What I'm looking for is to somehow decorate the
queue (or some other object) with behavior constraints (a la C++
traits) when the object is
> Is there a better way to specialize an built-in Clojure collection
> except wrapping - like for example to create a fixed size queue that
> drops new elements while full ?
You can use protocols as in the example at https://gist.github.com/831830
Is this what you were looking for?
--
You recei
Hi,
On 17 Feb., 06:52, Matthew Boston wrote:
> Again, this will have the same "path" of internal memory addresses.
> Therefore (identical? "test" "test") is the same path of memory
> addresses and is identical?.
This is the = way. identical? means you really have the same array.
Not only the sa
It turns out I used this code to start my local dev server using
appengine.server/start-server:
(start-server index :directory "./war" :join? false :port 8080)
forgot to replace index with the new "app". It works fine now, post
arguments are correctly captured.
By the way, when deploying the proje
I think I recall something in a CS class about how String is (or
possibly is) implemented. Consider the following:
1) Each character of the alphabet, number, symbol etc. is assigned a
memory location. 0x00, 0x01, 0x02, etc. etc.
2) A String has an internal representation as a char[].
So, String
When is the next one?
On Feb 16, 9:24 am, rob levy wrote:
> By the way, as those who attend the first meeting know, it was actually
> quite huge in terms of the number of people who attended. There are less
> than 40 people who list themselves on the meetup page as members, but closer
> to 50 pe
Ah!
Turns out when I started the server using appengine.server/start-
server I accidently passed in the original index handler! No wonder it
did not work. It works just fine now. Thanks for your reply!
On Feb 17, 4:07 pm, Zmitro Lapcjonak wrote:
> On Feb 17, 5:13 am, Zhenchao Li wrote:
>
> >
Is there a better way to specialize an built-in Clojure collection
except wrapping - like for example to create a fixed size queue that
drops new elements while full ?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email t
Hi Fred,
I've just finished prototyping clj-breve (http://spiderland.org/)
everything works but the integration isn't as elegant as I would like,
hence why I haven't released it yet. The current paradigm for using
clj-breve is to develop models in Clojure then export to breve. More
details when I
Armando, James, & Mike.
Thank you very much for the help, I'll certainly put your ideas to
good use.
Appreciate it!
--
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 ne
On Tue, Feb 08, 2011 at 09:01:38AM -0500, Stuart Halloway wrote:
> Please let us know when you get a misleading error message from a
> macroexpansion, so we can make it better. Or contribute a patch along the
> lines
> of [2].
Here's another error message that really threw me off for a while.
I
On 17 February 2011 03:13, Zhenchao Li wrote:
> This is how I define my app:
>
> (defroutes index
> (GET "/" [] (main-page))
> (GET "/form" [] (render-page "Vote" (render-form)))
> (POST "/vote" {params :params} (post-vote params))
> (route/not-found "Page not found"))
>
> (def app (site i
On Thu, Feb 17, 2011 at 1:39 AM, Shantanu Kumar
wrote:
> On Feb 17, 11:09 am, Ken Wesson wrote:
>> On Thu, Feb 17, 2011 at 12:29 AM, Andreas Kostler
>>
>> wrote:
>> > Is there an easy and idiomatic way of getting the digits of a number in
>> > clojure?
>>
>> > (defn explode-to-digits [number]
>
On Feb 17, 5:13 am, Zhenchao Li wrote:
> (POST "/vote" {params :params} (post-vote params))
> The site here is used to capture :params, which is new in compojure
> 0.6.0. However I'm getting a empty map in post-vote. I wonder what's
> wrong with the above code? Any suggestions? Hints?
Have y
31 matches
Mail list logo