On Oct 29, 11:39 pm, Joop Kiefte iko...@gmail.com wrote:
(first (flatten ...)) ?
And where reduction of code is?
--
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
On Oct 29, 4:03 am, lprefonta...@softaddicts.ca wrote:
user= (doc ffirst)
-
clojure.core/ffirst
([x])
Same as (first (first x))
nil
user=
That could help a bit :
Nice! I didn't know about this function, and for this concrete case it
is ideal!
--
You
On Oct 29, 4:03 am, Andrew Gwozdziewycz apg...@gmail.com wrote:
I'd hoist the empty out of the cond using an if:
(if (empty? ps)
ret
(let [fps (first (first ps))]
(cond
...)))
Yeah, I thought about it, but it is still a bit verbose, especially
with a 3
On Oct 29, 5:40 am, David Sletten da...@bosatsu.net wrote:
You could just bind another local variable in the loop form:
(loop [ps pairs
ret {}
ffps (ffirst ps)]
(cond (empty? ps) ret
(some-test ffps) (recur (rest ps) (add-to-result ret ffps) (ffirst
(rest ps)))
Hi,
On 29 Okt., 12:11, andrei andrei.zhabin...@gmail.com wrote:
You could just bind another local variable in the loop form:
(loop [ps pairs
ret {}
ffps (ffirst ps)]
(cond (empty? ps) ret
(some-test ffps) (recur (rest ps) (add-to-result ret ffps) (ffirst
On Fri, Oct 29, 2010 at 7:14 AM, Meikel Brandmeyer m...@kotka.de wrote:
There's nothing stoping you to put a let in a loop.
(loop [ps (seq pairs)
ret {}]
(let [ffps (ffirst ps)]
(cond
(not ps) ret
(some-test ffps) (recur (next ps) (add-to-result ret ffps))
Errr... clarification Scheme would blow up when doing (first (first
object that could be '())).
On Fri, Oct 29, 2010 at 7:44 AM, Andrew Gwozdziewycz apg...@gmail.com wrote:
On Fri, Oct 29, 2010 at 7:14 AM, Meikel Brandmeyer m...@kotka.de wrote:
There's nothing stoping you to put a let in a
On Oct 29, 2:14 pm, Meikel Brandmeyer m...@kotka.de wrote:
There's nothing stoping you to put a let in a loop.
Yes, but imagine a bit more complicated case, for example, instead of
'(first (first ps))' write (.foo (first ps)), and it will crash. I'm
looking for elegant, but general case
(first (flatten ...)) ?
2010/10/29 andrei andrei.zhabin...@gmail.com:
On Oct 29, 2:14 pm, Meikel Brandmeyer m...@kotka.de wrote:
There's nothing stoping you to put a let in a loop.
Yes, but imagine a bit more complicated case, for example, instead of
'(first (first ps))' write (.foo (first
Hi,
I have a code similar to this:
(def pairs (list [1 :a] [2 :b] [3 :c]))
...
(loop [ps pairs, ret {}]
(cond (empty? ps) ret
(some-test (first (first ps))) (recur (rest ps) (add-to-
result ret (first (first ps
:true (recur (rest ps) (do-smth-else ret (first
user= (doc ffirst)
-
clojure.core/ffirst
([x])
Same as (first (first x))
nil
user=
That could help a bit :
Luc P.
andrei andrei.zhabin...@gmail.com wrote ..
Hi,
I have a code similar to this:
(def pairs (list [1 :a] [2 :b] [3 :c]))
...
(loop [ps pairs,
I'd hoist the empty out of the cond using an if:
(if (empty? ps)
ret
(let [fps (first (first ps))]
(cond
...)))
On Thu, Oct 28, 2010 at 8:49 PM, andrei andrei.zhabin...@gmail.com wrote:
Hi,
I have a code similar to this:
(def pairs (list [1 :a] [2 :b] [3 :c]))
Andrei,
You could just bind another local variable in the loop form:
(loop [ps pairs
ret {}
ffps (ffirst ps)]
(cond (empty? ps) ret
(some-test ffps) (recur (rest ps) (add-to-result ret ffps) (ffirst
(rest ps)))
:true (recur (rest ps) (do-sth-else ret ffps) (ffirst
13 matches
Mail list logo