Simple doseq problem

12 views
Skip to first unread message

Piotr 'Qertoip' Włodarek

unread,
Dec 22, 2008, 11:10:05 AM12/22/08
to Clojure
user=> (doseq [word ("one" "two" "three")] (println word))

Throws java.lang.Exception: Unable to resolve symbol: word in this
context.

Could you please give any working example of doseq? I've seen one or
two examples on the web but they doesn't seem to work.


Regards,
Piotrek

Stuart Sierra

unread,
Dec 22, 2008, 11:34:18 AM12/22/08
to Clojure
On Dec 22, 11:10 am, Piotr 'Qertoip' Włodarek <qert...@gmail.com>
wrote:
> user=> (doseq [word ("one" "two" "three")] (println word))

The problem here is that the list ("one" "two" "three") tries to
evaluate "one" as a function. Try this:

user=> (doseq [word (list "one" "two" "three")] (println word))
one
two
three
nil

-Stuart Sierra

Johan Berntsson

unread,
Dec 23, 2008, 8:10:49 AM12/23/08
to Clojure
Or simply quote the list
user=> (doseq [word '("one" "two" "three")] (println word))

On Dec 22, 8:34 am, Stuart Sierra <the.stuart.sie...@gmail.com> wrote:
> On Dec 22, 11:10 am, Piotr 'Qertoip' Włodarek <qert...116@gmail.com>

Rich Hickey

unread,
Dec 23, 2008, 8:28:04 AM12/23/08
to clo...@googlegroups.com
2008/12/23 Johan Berntsson <johan....@gmail.com>:

Or better yet, just use a vector, please. It's more idiomatic Clojure

(doseq [word ["one" "two" "three"]]
(println word))

Quoted lists are an ugly part of Lisps that can be avoided in Clojure.
I don't see a lot of use for them other than in macros and other
code-producing code.

Rich

Reply all
Reply to author
Forward
0 new messages