Skip to content

Instantly share code, notes, and snippets.

;; Simple example for generating Pascal's triangle
;; using chouser's finger-tree
(use 'clojure.data.finger-tree
'clojure.pprint)
(def pascal
(iterate #(into (double-list)
(map +
(conjr % 0)
(ns uitest
(:require [goog.ui.ComboBox :as ComboBox]
[goog.ui.ComboBoxItem :as ComboBoxItem]
[goog.dom :as dom]))
(defn ^:export add-combo-box []
(let [combo-box (goog.ui/ComboBox.) ;; <-- ?
items ["A" "B" "C"]
elem (dom/getElement "combobox")]
; src/bar.clj
(ns bar)
(defmacro bar-macro [x]
`(inc ~x))
(ns csvtest.core
(:require [clojure.java.io :as io]
[clojure.data.csv]
[clojure-csv.core]))
(def characters
(vec
(concat "0123456789"
"abcdefghijklmnopqrstuvxyz"
"ABCDEFGHIJKLMNOPQRSTUVXYZ"
No message.
[Thrown class java.lang.NullPointerException]
Restarts:
0: [QUIT] Quit to the SLIME top level
Backtrace:
0: clojure.lang.Compiler.lookupVar(Compiler.java:6780)
1: clojure.lang.Compiler.isInline(Compiler.java:6277)
2: clojure.lang.Compiler.analyzeSeq(Compiler.java:6402)
$ script/cljs-repl
ClojureScript:cljs.user> (in-ns 'one-sample-model)
ClojureScript:one-sample-model> state
"Error evaluating:" state :as ".state;\n"
#<SyntaxError: Unexpected token .>
SyntaxError: Unexpected token .
at http://localhost:8080/javascripts/out/clojure/browser/repl.js:21:158
at evaluate_javascript (http://localhost:8080/javascripts/out/clojure/browser/repl.js:33:3)
at Object.callback (http://localhost:8080/javascripts/out/clojure/browser/repl.js:115:126)
at [object Object].deliver (http://localhost:8080/javascripts/out/goog/messaging/abstractchannel.js:141:13)
@jonase
jonase / newapp.diff
Created February 5, 2012 21:47
Remove ClojureScript One sample app and add a very simple application stub
From 22694b6e3d0ae4fe9c649deead0127073bf3c7c9 Mon Sep 17 00:00:00 2001
From: Jonas Enlund <[email protected]>
Date: Sun, 5 Feb 2012 18:09:07 +0200
Subject: [PATCH] Skeleton app
---
project.clj | 2 +-
public/design.html | 4 -
src/app/clj/newapp/config.clj | 27 +++++
src/app/clj/newapp/dev_server.clj | 67 ++++++++++++
@jonase
jonase / gist:2205346
Created March 26, 2012 14:10
A more advanced rule system?
(ns termite.core
(:refer-clojure :exclude [==])
(:use [clojure.core.logic]))
(def inc-rule
(let [x (lvar)]
[#(all (== % `(~'+ ~x 1))
;; It's easy to add pattern predicates
(pred x number?))
#(== % `(inc ~x))]))
@jonase
jonase / gist:2236019
Created March 29, 2012 11:18
Why doesn't the expression terminate?
(defn segmento [left middle right all]
(fresh [xs]
(appendo left middle xs)
(appendo xs right all)))
user> (run* [q]
(segmento [1 2] [3 4] [5 6] [1 2 3 4 5 6]))
(_.0)
(def uri "datomic:mem://testdb")
(d/create-database uri)
(def conn (d/connect uri))
;; The schema
(def s [{:db/id #db/id[:db.part/db]
:db/ident :testdb/test
:db/valueType :db.type/boolean
:db/cardinality :db.cardinality/one