Very simple function:
(defn map-filter [f coll]
(map f (filter f (coll)))
Is there an API function for this that I am missing? For example, it
is useful for pulling out all values in a list of maps of a certain
key that is optional:
Clojure=> (map-filter :k [{:a :b :c :d :k :found} {:a :b :c :
1
> (+ (fib (- n 1)) (fib (- n 2)
>
> If you need every last bit of performance, you can replace the atom-
> map combination with a mutable Java HashMap.
>
> -Jason
>
> On Mar 18, 11:17 pm, B Smith-Mannschott wrote:
>
> > On Fri, Mar 19, 2010 at 06:56, G
Ah, is there any concern with pummeling that var?
On Mar 19, 2:22 am, Meikel Brandmeyer wrote:
> Hi,
>
> On Mar 19, 7:05 am, Greg Fodor wrote:
>
> > Ah, I think I have the solution:
>
> > (defn foo []
> > (let [bar-memoized (memoize bar)]
>
Ah, I think I have the solution:
(defn foo []
(let [bar-memoized (memoize bar)]
; Do stuff with bar-memoized
))
Seems to work -- to verify, this will GC the memoized cache for bar
after each call to foo, right?
On Mar 19, 1:56 am, Greg Fodor wrote:
> Hi there -- I am looking fo
Hi there -- I am looking for a solution to a particular memoization
pattern. I have a function foo that is the entry point of a caller
that makes many thousands of calls to a function bar. In calling foo,
bar will be called with many different args but there are many
repeated calls to bar with the
Sean Devlin wrote:
> Hey Greg, welcome to Clojure :)
>
> You might want to take a look at c.c.seq-utils and the clojure cheat
> sheet. Both of these already exist. See take-while & partition-by
>
> The cheat sheet can be found here:http://clojure.org/cheatsheet
>
> On Mar
at-fenceposts % coll) (range (expt 2 (- (count
coll) 1)
On Mar 15, 1:24 pm, Greg Fodor wrote:
> Hi there, I am just learning Clojure and am processing some BER
> encoded integer values. Basically, the most significant bit of the
> integer in the stream indicates the split point be
Hi there, I am just learning Clojure and am processing some BER
encoded integer values. Basically, the most significant bit of the
integer in the stream indicates the split point between integers, and
so I was looking into partition-by to see if that would help. Turns
out, what I really need are tw
Yes, this makes things much more clear -- thanks for all the insights.
On Jan 9, 10:03 pm, Chouser wrote:
> On Fri, Jan 9, 2009 at 9:27 PM, Greg Fodor wrote:
>
> > Ok, this makes sense to me now. So, correct me if I'm wrong, but is it
> > safe to say that when you see
My (admittedly newbie) attempt:
(with-open [rdr (reader "executors.clj")]
(map (partial format "%d: %s") (iterate inc 1) (line-seq rdr)))
On Jan 9, 7:22 pm, wubbie wrote:
> Hi,
>
> How can you add line numbers for each line printed from the file.
> Without line number, I have this:
>
> (with-
e viewed as one. That is the
> distinction between your examples.
>
> On Jan 9, 8:47 pm, Greg Fodor wrote:
>
> > Right, what I was more pointing out is the fact that the printed
> > version of a sequence in the REPL is syntactically identical to that
> > of a list.
Right, but the confusion stems from the fact that all sequences are
not lists. I might just be really confused, but there seems to be some
asymmetry:
=> (seq [1 2 3])
(1 2 3)
=> (seq '(1 2 3))
(1 2 3)
=> '(1 2 3)
(1 2 3)
=> [1 2 3]
[1 2 3]
It seems that the output in the first two is driven b
Right, what I was more pointing out is the fact that the printed
version of a sequence in the REPL is syntactically identical to that
of a list. Which, clearly for most intents and purposes is a great
representation in output for using the REPL while doing development.
However, for a newcomer part
Hey all, I am just picking up Clojure here for the first time, sorry
about the relative newbie question. One thing I noticed is that the
REPL prints out a sequence as a list, basically eval'ing rest until it
sees nil. This threw me off a bit when first learning the language in
the last day because
Funny, it's this concept that has drawn me into looking into clojure
more in the
last few days. I worked on a highly structured editor at intentional
software
for some time but at the time had little exposure to LISP.
I feel a modern JVM based LISP such as Clojure with full access to
Java drawing
15 matches
Mail list logo