- The best tutorials are in the introductory books. See below.
- Getting Started with Clojure - A detailed tutorial on getting a modern (as of Jan 2013) Clojure workflow going.
- Emacs Live is a nice development environment based on Emacs.
- Understanding The Clojure Development Ecosystem
- Clojure Docs Site is a community-driven doc site with good tutorials, and reference material going somewhat deeper than individual API docs.
- Functional Programming for the Rest of Us is a classic introduction to functional thinking
- [A comprehensive article on namespaces and different ways of requiring them](http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns lisp-ch1) | |
| (def self-evaluating? | |
| (some-fn number? string? char? | |
| true? false? vector?)) | |
| (defn -atom? [s] | |
| (or (self-evaluating? s) | |
| (symbol? s))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns ormclj.pg | |
| (:require [clojure.java.jdbc :as sql])) | |
| (defn pg-db | |
| [hostname port db-name user passwd] | |
| {:classname "org.postgresql.Driver" | |
| :subprotocol "postgresql" | |
| :subname (str "//" hostname ":" port "/" db-name) | |
| :user user | |
| :password passwd}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; This defines the event stream, in this case just a series of numbers, | |
| ;; a new one produced each second | |
| (defn timer [] | |
| (lazy-seq | |
| (do | |
| (Thread/sleep 1000) | |
| (cons (System/nanoTime) (timer))))) | |
| ;; We can see some events (this takes a couple seconds to complete): | |
| (take 3 (timer)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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)))] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
| //background processing goes here | |
| dispatch_async(dispatch_get_main_queue(), ^{ | |
| //update UI here | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # add ssh key on remote server | |
| cat ~/.ssh/id_rsa.pub | ssh [email protected] 'cat >> .ssh/authorized_keys' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Regex | |
| import Foundation | |
| operator infix =~ {} | |
| @infix func =~ (str: String, pattern: String) -> Bool { | |
| var error: NSError? | |
| let regex = NSRegularExpression.regularExpressionWithPattern(pattern, options: nil, error: &error) | |
| if (error) { return false } |
OlderNewer