Thanks. That's much better.
On Monday, December 17, 2012 8:53:22 PM UTC+10, Dick Davies wrote:
>
>
> If you're using leiningen (2 at least, maybe 1?) then a
>
> (user/clojuredocs apply)
>
> is a much better "how do I drive this thing?" than a straight (doc ...)
> call.
>
--
You received thi
On 16 December 2012 10:59, Peter West wrote:
> This effect is, on the face of it, unpredictable: you just have to know that
> that is what apply does. Users of clojure learn that pretty quickly. I've
> just learned it. Doc doesn't help.
>
>>> user=> (doc apply)
If you're using leiningen (2 at l
> However, the fact that you can write funcall so easily as #(%1 %2)
> illustrates that funcall adds no real expressiveness to the language,
> whereas apply is really fundamental to being able to pass lists to
> multi-arg functions. It's hard to imagine how to write apply at all if it
> were
On Sun, Dec 16, 2012 at 10:04 AM, Marko Topolnik
wrote:
>
> Well, why don't you start with my example? Try rewriting this without OP's
> *apply*, implemented here as #(%1 %2).
>
> (defn apply-curried [f & args] (reduce #(%1 %2) f args))
>
>
>
To avoid confusion, I'm going to refer to the OP's con
> As for your suggestion of a (funcall f [i]) that behaves just like (f
> [i]), I can't imagine any possible purpose for that in Clojure. Why would
> you not just write (f [i])?
>
Well, why don't you start with my example? Try rewriting this without OP's *
apply*, implemented here as #(%1 %
On Sun, Dec 16, 2012 at 2:59 AM, Peter West wrote:
So it sounds like you just thought apply was something other than the
list->arguments adapter that it is. One of the best resources for learning
about clojure's functions is clojuredocs.org. Most of the functions are
accompanied by a number of
> If you are looking, for some reason I can't imagine at the moment, for a
> function that acts just like a funcall, so that
> (funcall f [i]) is exactly equivalent to (f [i]), I guess you are out of
> luck.
>
I can give you a reason: applying a curried function. On first sight that
may seem
>
> Users of clojure learn that pretty quickly. I've just learned it. Doc
> doesn't help.
> user=> (doc apply)
>>
>> -
>>
>> clojure.core/apply
>>
>> ([f args] [f x args] [f x y args] [f x y z args] [f a b c d & args])
>>
>> Applies fn f to the argument list formed by
Thanks again. I do get it. I'm not saying that apply has effects other than
the result it returns. No, it's not a side-effect; it doesn't change
something in the environment in passing. What it changes is the expected
result, if you expect that, as Rich Hickey is supposed to have written,
(appl
On Sat, Dec 15, 2012 at 3:58 PM, Peter West wrote:
> But it can't, can it? In this context (apply f [i]) with respect to (f i)*
> apply *has *side-effects*!
>
This doesn't really make any sense. There are no side effects here. I
think maybe you just don't understand what apply does. Let me t
Hi Mark and Baishampayan,
I can see what difference it makes, but I can't get a handle on the
rationale. For instance, I found this discussion:
http://stackoverflow.com/questions/1257028/why-should-i-use-apply-in-clojure
It starts with a quote from a Rich Hickey blog post, as follows.
> A big d
Nonsense. Why would that be any faster? (join coll) is defined as (apply
str coll).
On Saturday, December 15, 2012 12:21:45 PM UTC-8, Marek Šrank wrote:
>
> ...which should be also a lot faster :)
>
> On Saturday, December 15, 2012 5:44:01 PM UTC+1, Armando Blancas wrote:
>>
>> (comp (partial app
...which should be also a lot faster :)
On Saturday, December 15, 2012 5:44:01 PM UTC+1, Armando Blancas wrote:
>
> (comp (partial apply str) (partial filter #{\a}))
>>
>
> Or, (comp join (partial filter #{\a}))
>
>
--
You received this message because you are subscribed to the Google
Groups "
>
> (comp (partial apply str) (partial filter #{\a}))
>
Or, (comp join (partial filter #{\a}))
--
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 moder
An example will make it clear for you...
(str ) => (str '("foo" "bar" "baz"))
(apply str ) => (str "foo" "bar" "baz)
Hope this helps.
-BG
On Sat, Dec 15, 2012 at 3:48 PM, Peter West wrote:
> Thanks Baishampayan.
>
> I'm still puzzled about this though, because (doc str) says that with one
> a
> I'm still puzzled about this though, because (doc str) says that with one
> argument x, str returns x.toString(). What it returns is
> "clojure.lang.LazySeq@fe1"
>
> So it seems to be returning a lazy sequence. Why is the function not
> simply applied? Other functions are "applied" simple by
On Saturday, 15 December 2012 17:42:05 UTC+10, puzzler wrote:
>
> (I took the liberty of replacing #(= \a %) with #{\a})
>
> On Fri, Dec 14, 2012 at 11:37 PM, Mark Engelberg
>
> > wrote:
>
>> (comp (partial apply str) (partial filter #{\a}))
>>
>
>
Puzzler,
Your change replaces the single argume
Thanks Baishampayan.
I'm still puzzled about this though, because (doc str) says that with one
argument x, str returns x.toString(). What it returns is
"clojure.lang.LazySeq@fe1"
So it seems to be returning a lazy sequence. Why is the function not simply
applied? Other functions are "applied" s
On Saturday, 15 December 2012 18:09:13 UTC+10, Peter West wrote:
>
>
>
> On Saturday, 15 December 2012 17:42:05 UTC+10, puzzler wrote:
>>
>> (I took the liberty of replacing #(= \a %) with #{\a})
>>
>> On Fri, Dec 14, 2012 at 11:37 PM, Mark Engelberg wrote:
>>
>>> (comp (partial apply str) (parti
The apply is needed here because filter is going to return a sequence
of strings and you really want to `apply' str on it.
-BG
On Sat, Dec 15, 2012 at 1:39 PM, Peter West wrote:
> A couple of questions, if I may.
>
> In (partial apply str) why the apply?
>
> Given the apply, why the partial?
On Saturday, 15 December 2012 17:42:05 UTC+10, puzzler wrote:
>
> (I took the liberty of replacing #(= \a %) with #{\a})
>
> On Fri, Dec 14, 2012 at 11:37 PM, Mark Engelberg
>
> > wrote:
>
>> (comp (partial apply str) (partial filter #{\a}))
>>
>
>
You're most welcome. Thank you for this.
A co
(I took the liberty of replacing #(= \a %) with #{\a})
On Fri, Dec 14, 2012 at 11:37 PM, Mark Engelberg
wrote:
> (comp (partial apply str) (partial filter #{\a}))
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to
(comp (partial apply str) (partial filter #{\a}))
--
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.
T
I want to compose and apply a function as follows:
A> (= ( "abBcdAa">) "aa")
I can filter the argument using filter #(= \a %) .
If I (def s (filter #(= \a %) "abBcdAa")) I get
(\a \a\).
If I (str s) I get
"clojure.lang.LazySeq@fe1"
If I (apply str s) i get
"aa"
But what I am trying to do is A
24 matches
Mail list logo