Melkel,
On Mon, Jun 7, 2010 at 15:55, Meikel Brandmeyer wrote:
> Hi,
>
> On Jun 7, 4:25 pm, Bruce Durling wrote:
>
>> I have no problem with calling seq, I just don't understand why I need to.
>
> Because the initial collections might be empty.
>
> (my-zipmap [] []) => {}
I see, where as the ve
On Jun 7, 1:49 pm, Bruce Durling wrote:
> Steve and Jon,
>
> On Mon, Jun 7, 2010 at 12:43, Steve Purcell wrote:
> > Empty seqs are logically true, so your "if" condition is always true.
>
> I was looking at that today too. I did (> 0 (count my-list)) in my if
> statement to fix it.
Be aware that
Hi,
On Jun 7, 4:25 pm, Bruce Durling wrote:
> I have no problem with calling seq, I just don't understand why I need to.
Because the initial collections might be empty.
(my-zipmap [] []) => {}
Sincerely
Meikel
--
You received this message because you are subscribed to the Google
Groups "Clo
Patrik,
On Mon, Jun 7, 2010 at 13:00, patrik karlin wrote:
> calling rest dosent give you nil it gives you an empty seq
> so the if statment never fails
>
> try
>
> (defn my-zipmap [keys vals]
> (loop [my-map {}
> [kf & kr] (seq keys)
> [vf & vr] (seq vals)]
> (if (and kf vf)
>
Stu,
On Mon, Jun 7, 2010 at 13:08, Stuart Halloway wrote:
> That doc page used pre-1.0 Clojure code, which, as you saw, doesn't work.
> Thanks for the catch, I have fixed the docs on the site.
Thanks. I think my mistake was mixing up rest (which always returns a
sequence even if empty) and next
Hi Bruce,
That doc page used pre-1.0 Clojure code, which, as you saw, doesn't work.
Thanks for the catch, I have fixed the docs on the site.
Stu
> Steve and Jon,
>
> On Mon, Jun 7, 2010 at 12:43, Steve Purcell wrote:
>> Empty seqs are logically true, so your "if" condition is always true.
>>
So its the calling of first that gives you nil
here is some example code
user=> (rest '(2))
()
user=> (rest '())
()
user=> (first '())
nil
2010/6/7 patrik karlin :
> calling rest dosent give you nil it gives you an empty seq
> so the if statment never fails
>
> try
>
> (defn my-zipmap [keys val
calling rest dosent give you nil it gives you an empty seq
so the if statment never fails
try
(defn my-zipmap [keys vals]
(loop [my-map {}
[kf & kr] (seq keys)
[vf & vr] (seq vals)]
(if (and kf vf)
(recur (assoc my-map kf vf) kr vr)
my-map)))
2010/6/6 Jon Seltzer
Steve,
On Mon, Jun 7, 2010 at 12:48, Steve Purcell wrote:
> On 7 Jun 2010, at 12:43, Steve Purcell wrote:
>
>> Empty seqs are logically true, so your "if" condition is always true.
>
>
> Apologies; I'm talking rubbish:
>
> user=> (if '() (println "truthy"))
> truthy
> nil
> user=> (if (seq '()) (
Steve and Jon,
On Mon, Jun 7, 2010 at 12:43, Steve Purcell wrote:
> Empty seqs are logically true, so your "if" condition is always true.
>
I was looking at that today too. I did (> 0 (count my-list)) in my if
statement to fix it.
Is the Recursive Looping example on
http://clojure.org/function
On 7 Jun 2010, at 12:43, Steve Purcell wrote:
> Empty seqs are logically true, so your "if" condition is always true.
Apologies; I'm talking rubbish:
user=> (if '() (println "truthy"))
truthy
nil
user=> (if (seq '()) (println "truthy"))
nil
--
You received this message because you are subscr
On 6 Jun 2010, at 15:30, Jon Seltzer wrote:
> I'm still learning Clojure and doing so by reading everything on
> clojure.org. I ran across this example in the Functional Programming
> section:
>
> (defn my-zipmap [keys vals]
> (loop [my-map {}
> my-keys (seq keys)
> my-vals (seq
12 matches
Mail list logo