On Wed, Oct 20, 2010 at 3:21 PM, Rich Hickey wrote:
>
>
> On Oct 20, 1:34 pm, cej38 wrote:
>> This question leads into something that I read in Joy of Clojure (page
>> 161 in the latest MEAP edition):
>> "If you manage to hold onto the head of a sequence somewhere within a
>> function, then that
On Wed, Oct 20, 2010 at 09:52, Alan wrote:
> I agree with Tom (and with Stuart). I tend to like using ->> when it's
> convenient, since all you're really doing is performing a list of
> transformations on a single object. However, the let is better
> documentation if that's ever going to matter.
great! good to know
On Oct 20, 3:21 pm, Rich Hickey wrote:
> On Oct 20, 1:34 pm, cej38 wrote:
>
>
>
>
>
> > This question leads into something that I read in Joy of Clojure (page
> > 161 in the latest MEAP edition):
> > "If you manage to hold onto the head of a sequence somewhere within a
> > fu
On Oct 20, 1:34 pm, cej38 wrote:
> This question leads into something that I read in Joy of Clojure (page
> 161 in the latest MEAP edition):
> "If you manage to hold onto the head of a sequence somewhere within a
> function, then that sequence will be prevented from being garbage
> collected. Th
Not only did my question get answered, but I learned several new
things in the process.
Thanks!
Dave
On Wed, Oct 20, 2010 at 1:52 PM, Alan wrote:
> When you work with a lazy sequence, Clojure (java really)
> automatically garbage-collects elements you're done with. It can only
> be certain you'
When you work with a lazy sequence, Clojure (java really)
automatically garbage-collects elements you're done with. It can only
be certain you're done with them if you no longer have any reference
to them, direct or indirect. If you've bound the head of the sequence
to a local, then you can still a
This question leads into something that I read in Joy of Clojure (page
161 in the latest MEAP edition):
"If you manage to hold onto the head of a sequence somewhere within a
function, then that sequence will be prevented from being garbage
collected. The simplest way to retain the head of sequence
By the way, http://tinyurl.com/2a235cn is an example of your style of
let being used in the Clojure source: the definition of defn itself.
It's a little overdone and weird-looking, but the alternative of
deeply nested forms would be much worse.
I didn't notice your question about technical tradeof
Hi,
readability might be a concern but it's not the only criteria.
a) Do you need to trace intermediate results ? Then you need a
binding so you do not redo the work twice (presumably, I exclude memoized
functions here). Of course if the code has some side effects, the choice
is obvious,
I agree with Tom (and with Stuart). I tend to like using ->> when it's
convenient, since all you're really doing is performing a list of
transformations on a single object. However, the let is better
documentation if that's ever going to matter. Not because it makes it
easier to understand what ope
Dave,
Yes, this is perfectly idiomatic and many people in Clojure (and also
Haskell, for example) use let to help document how they're building up
their computation.
Stuart's suggestion is also good and it's largely a matter of personal
preference which to use when.
Of course, as you use clojure
On 20 October 2010 14:19, Dave Ray wrote:
> Hey,
>
> I'm parsing a file with a chain of filter and map operations. To make
> it a little more readable (to me), I put the steps in a let like this:
>
> (defn parse-dictionary
> [reader]
> (let [lines(read-lines reader)
>trimmed (map #
Hey,
I'm parsing a file with a chain of filter and map operations. To make
it a little more readable (to me), I put the steps in a let like this:
(defn parse-dictionary
[reader]
(let [lines(read-lines reader)
trimmed (map #(.trim %1) lines)
filtered (filter is-dictionary-
13 matches
Mail list logo