This file contains 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
(require 'paredit) | |
(eval-after-load 'paredit | |
'(progn (define-key paredit-mode-map (kbd "{") | |
'paredit-open-curly) | |
(define-key paredit-mode-map (kbd "}") | |
'paredit-close-curly) | |
(define-key paredit-mode-map (kbd "M-}") | |
'paredit-close-curly-and-newline))) |
This file contains 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
(defn- re-clause-to-if [s [re bindings body] else] | |
`(if-let [[~'_ ~@bindings] (re-find ~re ~s)] | |
~body | |
~else)) | |
(defn- re-clauses-to-ifs [s clauses] | |
(when-first [clause clauses] | |
(if (and (not (next clauses)) | |
(= (count clause) 1)) | |
(first clause) |
This file contains 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 myrbot.core | |
(:use irclj.irclj)) | |
;;; cond-re macro | |
(defn- re-clause-to-if [s [re bindings body] else] | |
`(if-let [[~'_ ~@bindings] (re-find ~re ~s)] | |
~body | |
~else)) |
This file contains 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
(pi "The constant pi") 3.14 def | |
(area-of-disk | |
"Calculate the area of a cirlce disk." | |
(radius -- area)) | |
(dup * pi *) | |
defn | |
(area-of-ring | |
"Calculate the area of a ring." |
This file contains 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
(defn fac [n] | |
(loop [n n, acc 1] | |
(if (zero? n) | |
acc | |
(recur (dec n) (* acc n))))) | |
(fac 20) | |
; => 2432902008176640000 | |
(fac 25) | |
; => java.lang.ArithmeticException: integer overflow |
This file contains 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 ditt.namespace.whatever | |
; (:import (javax.swing JOptionPane))) | |
(import 'javax.swing.JOptionPane) | |
(defn ask | |
"Ställer en fråga till användaren. Ger nil om användaren avbryter." | |
[title question] | |
(JOptionPane/showInputDialog nil question title | |
JOptionPane/QUESTION_MESSAGE)) |
This file contains 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-to-list 'load-path "~/.emacs.d/") | |
(require 'rainbow-parens) | |
;; clojure-mode | |
(add-to-list 'load-path "~/Projekt/clojure-mode") | |
(require 'clojure-mode) | |
;; swank-clojure | |
(require 'assoc) |
This file contains 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
(defn- re-clause-to-if [s [re bindings body] else] | |
`(if-let [[~'_ ~@bindings] (re-find ~re ~s)] | |
~body | |
~else)) | |
(defn- re-clauses-to-ifs [s clauses] | |
(when-first [clause clauses] | |
(if (and (not (next clauses)) | |
(= (count clause) 1)) | |
(first clause) |
This file contains 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
;; By Rasmus Svensson. No copyright. | |
(ns se.raek.pipes | |
(:require [clojure.java.io :as io]) | |
(:use (clojure.contrib def json)) | |
(:import (java.io EOFException BufferedReader BufferedWriter StringReader PrintWriter) | |
(javax.swing JOptionPane) | |
(java.util.concurrent BlockingQueue LinkedBlockingQueue SynchronousQueue))) | |
(defprotocol Source |
This file contains 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
user> (def p (make-pipe)) | |
#'user/p | |
user> (put! p :a) | |
nil | |
user> (put! p :b) | |
nil | |
user> (def s1 (source-seq p)) | |
#'user/s1 | |
user> (def w (make-walker s1)) | |
#'user/w |