diff options
author | Chouser <chouser@n01se.net> | 2008-09-17 00:03:44 +0000 |
---|---|---|
committer | Chouser <chouser@n01se.net> | 2008-09-17 00:03:44 +0000 |
commit | c68f9aefb7d4b4f2240e196556f83f76e9fd4ef5 (patch) | |
tree | 31721cb18ea8ba1525e181629316db80bbac6c08 /clojurescript/t02.cljs | |
parent | 80c4d45654e505dbfb148441da75184b02e0f62d (diff) |
ClojureScript: even more local var emits are now avoided.
Diffstat (limited to 'clojurescript/t02.cljs')
-rw-r--r-- | clojurescript/t02.cljs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/clojurescript/t02.cljs b/clojurescript/t02.cljs new file mode 100644 index 00000000..e25d0543 --- /dev/null +++ b/clojurescript/t02.cljs @@ -0,0 +1,22 @@ +; This may look like Clojure, but it's actually ClojureScript. Macros +; may be used here, but should be defined elsewhere, in regular +; Clojure code. +(ns n01se) + +(defn my-take + "Returns a lazy seq of the first n items in coll, or all items if + there are fewer than n." + [n coll] + (when (and (pos? n) (seq coll)) + (lazy-cons (first coll) (my-take (dec n) (rest coll))))) + +(defn script-src [] + (for [elem (.getElementsByTagName document "script")] + (do + (prn :next) + (if-let src (.src elem) + src + "--none--")))) + +(doseq src (my-take 2 (script-src)) + (prn src)) |