Demonstrations of how clojure.core/concat
can produce a
StackOverflow.
This is the most obvious case: A loop that builds up a sequence by concatenation.
;; in reply to http://www.sids.in/blog/2010/05/06/html-parsing-in-clojure-using-htmlcleaner/ | |
(ns html-parser | |
(:require [net.cgrand.enlive-html :as e])) | |
(defn parse-page | |
"Given the HTML source of a web page, parses it and returns the :title | |
and the tag-stripped :content of the page. Does not do any encoding | |
detection, it is expected that this has already been done." | |
[page-src] | |
(-> page-src java.io.StringReader. e/html-resource |
(ns com.example.hello_clojure.HelloActivity | |
(:gen-class :main false | |
:extends android.app.Activity | |
:exposes-methods {onCreate superOnCreate}) | |
(:import [com.example.hello_clojure R$layout])) | |
(defn -onCreate | |
[this bundle] | |
(doto this | |
(.superOnCreate bundle) |
(ns test.leindroid.sample.main | |
(:use [neko.activity :only [defactivity set-content-view!]] | |
[neko.threading :only [on-ui]] | |
[neko.ui :only [make-ui]]) | |
(:import android.widget.EditText | |
android.net.Uri | |
android.content.Intent)) | |
(declare ^EditText edit | |
^android.app.Activity a) |
(defmacro test-> | |
"Takes an expression and a set of test/form pairs. Threads expr (via ->) | |
through each form for which the corresponding test expression (not threaded) is true." | |
[expr | |
& clauses] | |
(assert (even? (count clauses))) | |
(let [g (gensym) | |
pstep (fn [[test step]] `(if ~test (-> ~g ~step) ~g))] | |
`(let [~g ~expr | |
~@(interleave (repeat g) (map pstep (partition 2 clauses)))] |
;; ## Changes from cljs.repl.browser | |
;; | |
;; * Multiple concurrent browser-REPLs can be safely used | |
;; * The browser-REPL's HTTP server is now always-on | |
;; * Each browser-REPL session supports a new top-level "entry" URL that | |
;; can be used to easily start the REPL in a browser or other JS runtime | |
;; (i.e. you don't need to have a separate webapp running to initiate the | |
;; browser-REPL connection) | |
;; * The entry (and REPL) URLs are available in slots on the browser-REPL's | |
;; environment, making it trivial to automate browser-REPL sessions |
(ns my.server | |
(:use org.httpkit.server | |
[clojure.string :only [split trim lower-case]]) | |
(:import [org.httpkit.server AsyncChannel])) | |
(defn origin-match? [origin-re req] | |
(if-let [req-origin (get-in req [:headers "origin"])] | |
(re-matches origin-re req-origin))) |
(defn debounce | |
([c ms] (debounce (chan) c ms)) | |
([c' c ms] | |
(go | |
(loop [start nil loc (<! c)] | |
(if (nil? start) | |
(do | |
(>! c' loc) | |
(recur (js/Date.) nil)) | |
(let [loc (<! c)] |
(ns react-cljs.core | |
(:require React)) | |
(declare render) | |
(defn handle-change [e] | |
(render {:text (.. e -target -value)})) | |
(defn render [{:keys [text]}] | |
(React/renderComponent |
(ns react-cljs.core | |
(:require-macros [reactjs.macros :refer [pure]]) | |
(:require React [reactjs.core :as r])) | |
(enable-console-print!) | |
(declare render-ui) | |
(defn render-counter [id state cb] | |
(pure state |