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
; file one.cljs | |
(ns one) | |
(declare ^:dynamic *something*) | |
(defn with-something [func] | |
(binding [*something* 42] (func))) | |
(defn print-something [] | |
(.log js/console *something*)) |
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
(import '[java.awt.image BufferedImage]) | |
(defn create-image [w h] | |
(let [image (BufferedImage. w h BufferedImage/TYPE_INT_RGB)] | |
(loop [x (dec w)] | |
(when (>= x 0) | |
(loop [y (dec h)] | |
(when (>= y 0) | |
(.setRGB image (int x) (int y) (int 0)) | |
(recur (dec y)))) |
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
{-# OPTIONS --universe-polymorphism #-} | |
module match where | |
open import Data.List hiding (or) | |
open import Category.Monad | |
open import Category.Functor | |
open import Data.Maybe | |
open import Data.Bool | |
open import Data.Nat | |
open import Relation.Binary.PropositionalEquality | |
open import Relation.Nullary |
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 cljs-test.client) | |
(defn now [] | |
(. (js/Date.) (getTime))) | |
(let [nums (doall (range 0 1000000)) | |
start (now)] | |
(doseq [n nums] | |
) | |
(. js/console (log (- (now) start)))) |
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
package demo | |
class Coder(words: List[String]) { | |
private val mnemonics = Map( | |
'2' -> "ABC", '3' -> "DEF", '4' -> "GHI", '5' -> "JKL", | |
'6' -> "MNO", '7' -> "PQRS", '8' -> "TUV", '9' -> "WXYZ") | |
/** Invert the mnemonics map to give a map from chars 'A' ... 'Z' to '2' ... '9' */ | |
private val charCode: Map[Char, Char] = |
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
(defn- inner-generate [n] | |
(if (= n 10) | |
nil | |
(cons n (lazy-seq (inner-generate (inc n)))))) | |
(defn generate [] | |
(lazy-seq (inner-generate 0))) |
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
(defn validate [params] | |
(letfn [(required [errs k] | |
(if (nil? (k params)) | |
(assoc errs k "is required") errs))] | |
(reduce required {} [:model :pk]))) | |
;; def validate(params_hash) | |
;; errors = {} | |
;; errors[:model] = "is required" if params_hash[:model].nil? | |
;; errors[:pk] = "is required" if params_hash[:pk].nil? |
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
(match x | |
(1 | | |
2 | | |
3) :a0 | |
1 :a1) | |
(match [x y] | |
([1 2] | | |
[2 3] | | |
[3 4]) :a0 |
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
(match [x y] | |
([1 2] | | |
[2 3] | | |
[3 4]) :a0 | |
[10 20] :a1) | |
;; or | |
(let [z [x y]] | |
(match [z] |
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
(use '[clojure.java.io :only [reader]]) | |
(use '[clojure.string :only [split]]) | |
(def read-keys [:id :status :pos-contig :pos-position :pos-strand :neg-contig :neg-position :neg-strand]) | |
(defn split-line [x] | |
(split x #"\t")) | |
(defn create-read [x] | |
(with-meta |