On Wed, Oct 21, 2009 at 5:50 PM, Lauri Pesonen wrote:
>
> 2009/10/21 John Harrop :
>
> > Like this?
> > (def hexchar? #{\0 \1 \2 \3 \4 \5 \6 \7 \8 \9 \A \a \B \b \C \c \D \d \E
> \e
> > \F \f})
>
> Yep, that's what I had in mind as well, but I got tired of typing ;-)
>
(def hexchar? (set "01234
On Oct 22, 3:22 pm, John Harrop wrote:
> user=> (map call (map constantly [1 2 3]))
> (1 2 3)
>
> "map call" and "map constantly" are actually inverse operations.
:) that makes me smile!
--~--~-~--~~~---~--~~
You received this message because you are subscribed
On Thu, Oct 22, 2009 at 12:19 AM, John Harrop wrote:
> On Wed, Oct 21, 2009 at 11:50 PM, samppi wrote:
>
>> Oh, no. I was just wondering if there was a standard variable devoted
>> to it. A symbol would be aesthetically less clutter than #(%), even if
>> it'd take more typing. But if there isn't
On Wed, Oct 21, 2009 at 11:50 PM, samppi wrote:
> Oh, no. I was just wondering if there was a standard variable devoted
> to it. A symbol would be aesthetically less clutter than #(%), even if
> it'd take more typing. But if there isn't any other than the slow
> apply function, I'm happy with #(%
On Wed, Oct 21, 2009 at 9:58 PM, Dmitry Kakurin wrote:
> On Oct 21, 6:45 pm, John Harrop wrote:
> > the reduction is wrapping the initial seq of empty vectors in ten
> > thousand layers of map ... fn ... invoke ... map ... etc.
> > Reducing a lazy sequence generator like map over a large sequence
Oh, no. I was just wondering if there was a standard variable devoted
to it. A symbol would be aesthetically less clutter than #(%), even if
it'd take more typing. But if there isn't any other than the slow
apply function, I'm happy with #(%) too. :)
On Oct 21, 6:33 pm, John Harrop wrote:
> On W
According to this thread
http://www.velocityreviews.com/forums/t142870-inputstream-and-selector.html
the channel produced from at least the InputStream of system.in is
always blocking . probably the same here. oh well...
--~--~-~--~~~---~--~~
You received this messa
On Oct 21, 6:45 pm, John Harrop wrote:
> the reduction is wrapping the initial seq of empty vectors in ten
> thousand layers of map ... fn ... invoke ... map ... etc.
> Reducing a lazy sequence generator like map over a large sequence does not
> work well in Clojure.
I wonder if this could be i
On Wed, Oct 21, 2009 at 9:28 PM, Dmitry Kakurin wrote:
>
> I have an innocent-looking function that only uses map and reduce, but
> when I run it on a big collection (10K elements) I get a StackOverflow
> exception. Here is the function:
>
> (defn multi-filter [filters coll]
> (reduce
>(fn [r
On Wed, Oct 21, 2009 at 7:49 PM, samppi wrote:
> Is there a standard function that takes one argument and calls it?
> That is, the function equivalent to #(%). Or is that the best idiom
> there is?
#(%) is only four characters. Calling apply with only one argument also does
this, and "apply" is
So, ive been trying this out and it hasn't quite been working out.
First, im getting a inputstream from a Process. Then i'm getting a
channel from it
using Channels/newChannel. This gives me a ReadableByteChannelImpl
which claims to implemen tInterruptibleChannel
http://www.docjar.org/docs/api/jav
I have an innocent-looking function that only uses map and reduce, but
when I run it on a big collection (10K elements) I get a StackOverflow
exception. Here is the function:
(defn multi-filter [filters coll]
(reduce
(fn [res e]
(map (fn [f r] (if (f e) (conj r e) r))
filters
I think you need to be careful not to prematurely optimise. If using
apply becomes a problem, then drop in something more efficient, but
until that point there's no reason not to use it.
- James
On Oct 22, 1:27 am, samppi wrote:
> Ah, of course. But then I'm afraid of a time penalty cost, becau
Ah, of course. But then I'm afraid of a time penalty cost, because
apply can take many arguments; would this be significant? Or should I
stick to #(%)?
Clojure 1.0.0-
user=> (def a (constantly 55))
#'user/a
user=> (time (dotimes [_ 500] (a)))
"Elapsed time: 0.389 msecs"
nil
user=> (time (dotimes
apply
On Oct 22, 12:49 am, samppi wrote:
> Is there a standard function that takes one argument and calls it?
> That is, the function equivalent to #(%). Or is that the best idiom
> there is?
--~--~-~--~~~---~--~~
You received this message because you are subscrib
Is there a standard function that takes one argument and calls it?
That is, the function equivalent to #(%). Or is that the best idiom
there is?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post
On Wed, Oct 21, 2009 at 7:35 PM, Gorsal wrote:
>
> I was just idly wondering: even after searching google, i haven't seen
> the once-only macro+clojure pop up any results. Its easy to
> implement, but I was wondering if there was some reason people weren't
> using this to avoid multiple evaluatio
I was just idly wondering: even after searching google, i haven't seen
the once-only macro+clojure pop up any results. Its easy to
implement, but I was wondering if there was some reason people weren't
using this to avoid multiple evaluation in macros. Is something else
used?
--~--~-~--~-
Yep, thats exactly it. Merci!
--~--~-~--~~~---~--~~
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 pa
Thanks, all, that's enlightening. So if I understand correctly, I
designed hexchar? to accept a string argument, which means it needed a
CharSequence, right? But instead it was getting a Char, which is not
the same thing as a one-character string, and thus was not a
CharSequence.
Yahrgh, I've bee
Hi,
Am 21.10.2009 um 20:49 schrieb Shel:
> (defmulti area (fn [s m] [(:shape s) (:measure m)]))
> (defmethod area[:rectangle :side] [s m] (* (:side m) (:side m)))
> (defmethod area[:rectangle :sides] [s m] (* (:side1 m) (:side2 m)))
> (derive ::square ::rectangle)
> user=> (area {:shape :square}
On Wed, Oct 21, 2009 at 2:49 PM, Shel wrote:
>
> Hi, I'm having a bit of trouble with the supposed use of isa? as a
> part of multimethod dispatch.
> Consider the following example:
>
> (defmulti area (fn [s m] [(:shape s) (:measure m)]))
> (defmethod area[:rectangle :side] [s m] (* (:side m) (:s
Hi, I'm having a bit of trouble with the supposed use of isa? as a
part of multimethod dispatch.
Consider the following example:
(defmulti area (fn [s m] [(:shape s) (:measure m)]))
(defmethod area[:rectangle :side] [s m] (* (:side m) (:side m)))
(defmethod area[:rectangle :sides] [s m] (* (:side
On Oct 21, 11:48 am, Gorsal wrote:
> I'm trying to unintern a function i accidently defined in a namespace
> which collides with another function i'm importing . i can't seem to
> find an unintern, or undef, or anything to do this? How do i achieve
> this?
>
> Thanks~~
I think this is what you w
I'm trying to unintern a function i accidently defined in a namespace
which collides with another function i'm importing . i can't seem to
find an unintern, or undef, or anything to do this? How do i achieve
this?
Thanks~~
--~--~-~--~~~---~--~~
You received this me
Of course! Thanks for that explanation Konrad Hinsen. I indeed was
thinking about functions that return functions, and was attempting to
reason about it with my C-compiler knowledge. It never occurred to me
that closures are well defined statically. That's all that I needed to
know.
Thanks everyo
I haven't tried it yet. I've been very busy. If I have any trouble,
though, I'll post here.
On Wed, Oct 21, 2009 at 7:31 AM, Stuart Campbell <
stuart.william.campb...@gmail.com> wrote:
> Jeffrey, did this work for you? I followed the instructions on the
> screencast and I couldn't get a REPL to
On 21 Oct 2009, at 17:58, CuppoJava wrote:
> The part that I'm having trouble understanding is the fact that
> functions can be defined at runtime. How do you compile a function
> that's not defined until after you run the program?
It is possible to define functions at runtime only by calling ev
Hello,
2009/10/21 CuppoJava
>
> Hi,
> Clojure started my interest in programming languages, and I'm
> wondering exactly how LISP-like languages get compiled ahead of time?
> A link to a tutorial would be much appreciated.
>
> The part that I'm having trouble understanding is the fact that
> func
I'm not aware of a good tutorial online, but Peter Norvig does
excellent treatment in his book "Paradigms of Artificial Intelligence
Programming". Chapter 23 is devoted to writing a simple compiler. The
source for his compiler is online at:
http://norvig.com/paip/compile1.lisp
http://norvig.com/p
I don't know how detailed of an explanation you want. The most basic
explanation is that not everything is compiled to byte code in the
manner that a C compiler usually generates machine code. Instead the
runtime, which would interpret most lisps, is bundled with the code as
a library.
On Oct 2
Chouser---
Hmm, what to do in the meantime. What I was trying to do was write
a package that would take care of indexing fields, adding
backreferences, and creating 'plural' fields. For instance, suppose
you had people and accounts. People have names, incomes and (human)
parents; accounts ha
Hi,
Clojure started my interest in programming languages, and I'm
wondering exactly how LISP-like languages get compiled ahead of time?
A link to a tutorial would be much appreciated.
The part that I'm having trouble understanding is the fact that
functions can be defined at runtime. How do you c
2009/10/21 John Harrop :
> Like this?
> (def hexchar? #{\0 \1 \2 \3 \4 \5 \6 \7 \8 \9 \A \a \B \b \C \c \D \d \E \e
> \F \f})
Yep, that's what I had in mind as well, but I got tired of typing ;-)
--
! Lauri
--~--~-~--~~~---~--~~
You received this message beca
On Wed, Oct 21, 2009 at 10:51 AM, Lauri Pesonen wrote:
> One way to fix this would be to produce a string out of c:
>
> (defn hexchar? [c] (re-find #"[0-9A-Fa-f]" (str c)))
>
> but you should really change hexchar? into something more elegant.
Like this?
(def hexchar? #{\0 \1 \2 \3 \4 \5 \6 \7
On Wed, Oct 21, 2009 at 1:20 AM, Meikel Brandmeyer wrote:
> >>>(repeat (count filters) [])
> > Should I wrap it in (vec ...) or is there a better way?
>
> repeat, map, filter, cycle, take, iterate, etc. are all sequence
> functions. They will turn their argument into sequence (via seq) and
>
Hi Mark,
2009/10/21 Mark Nutter :
>
> (defn blank? [s] (every? #(Character/isWhitespace %) s))
> user=> (defn hexchar? [c] (re-find #"[0-9A-Fa-f]" c))
> user=> (defn hex? [s] (every? #(hexchar? %) s))
> #'user/hex?
> nil
> user=> (hex? "a")
> # cannot be cast to java.lang.CharSequence (NO_S
The problem is that hexchar? expects a CharSequence, but by using
every? you're actually passing a Character into it. The quick fix is
to change hex? to (defn hex? [s] (every? #(hexchar? (str %)) s)).
However, the better solution is probably to change hexchar? to accept
Characters instead -- a la
Jeffrey, did this work for you? I followed the instructions on the
screencast and I couldn't get a REPL to open in Aquamacs. (The only thing I
did differently was put the contents of customizations.el into ~/.emacs.)
Do I have to install SLIME separately... ?
2009/10/21 Jeffrey Straszheim
> Tha
Hi,
Am 21.10.2009 um 01:40 schrieb Dmitry Kakurin:
> Where do I use a sequence? reduce? or this line?
No. reduce itself is eager.
>>>(repeat (count filters) [])
> Should I wrap it in (vec ...) or is there a better way?
repeat, map, filter, cycle, take, iterate, etc. are all sequence
func
Hi all, newcomer to clojure/lisp/fp here. I'm working my way through
the Programming Clojure book (very excellent, well worth the money),
and doing some dabbling in the REPL, and I'm seeing something that
puzzles me. In the book there's an example of a clojure blank?
function that looks like this:
One other small thing, you can find out the exact type returned from a
function by calling class.
user=> (class (concat [1 2] [3 4]))
clojure.lang.LazySeq
There are functions that return lazy sequences all over the place, so
keep an eye out ;-).
On Oct 20, 12:56 am, Dmitri wrote:
> I notice th
+1
This would be awesome for contrib, too.
On Oct 21, 2:03 am, Timothy Pratley wrote:
> On Oct 21, 4:27 pm, Phil Hagelberg wrote:
>
> > I wonder if we got more manpower involved in that process if it would
> > mean less work for Rich and the committer team when they are ready to
> > apply patc
That's a good point. I hadn't thought about how wrapping all functions
might be detrimental because of side-effect issue you mentioned.
I guess I was thinking of something I could turn on and off easily.
But even then, like you mentioned, just wrapping all the functions
probably wouldn't be very
On Tue, Oct 20, 2009 at 8:51 PM, nchubrich wrote:
>
> I'm trying to develop a library for structs (hopefully will be
> generally useful), with an API parallel to the struct API. One of the
> capabilities I would like to have is \typed \structs, i.e., if you
> attempt to assoc something of the wr
I'd be a little concerned about wholesale wrapping of functions, purely from
the perspective that you'll be wrapping mostly side-effect free functions
with functions that do have side-effects. That sounds like something you'd
want to do consciously, where you know it will be safe, and where the
res
46 matches
Mail list logo