Skip to content

Instantly share code, notes, and snippets.

View fogus's full-sized avatar
💭
attempting to learn how to better learn

Fogus fogus

💭
attempting to learn how to better learn
View GitHub Profile
@fogus
fogus / cells.clj
Created February 18, 2010 13:59 — forked from richhickey/cells.clj
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(set! *warn-on-reflection* true)
<!DOCTYPE html>
<html>
<head>
<title>BAD DATA</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="en-us" http-equiv="Content-Language" />
</head>
<body>
<header><h1>BAD DATA</h1></header>
For each Ruby module/class, we have Ruby methods on the left and the equivalent
Clojure functions and/or relevant notes are on the right.
For clojure functions, symbols indicate existing method definitions, in the
clojure namespace if none is explicitly given. clojure.contrib.*/* functions can
be obtained from http://github.com/kevinoneill/clojure-contrib/tree/master,
ruby-to-clojure.*/* functions can be obtained from the source files in this
gist.
If no method symbol is given, we use the following notation:
(ns com.wangdera.slideshow
(:use [clojure.contrib.test-is])
(:import (java.io File)
(javax.imageio ImageIO)
(javax.swing JFrame JPanel Timer)
(java.awt Dimension Frame Color)
(java.awt.event ActionListener WindowAdapter)))
(def imagelist (atom []))
(def current-image (atom nil))
import scala.xml.{Node, Elem, Group}
/**
* A path to a Node in a Node tree.
*/
sealed trait NodePath {
def depth: Int
}
object NodePath {
(defn tests []
[{:name 'suiteA
:total 3
:passed (promise)
:failed (promise)
:success (promise)
:tests [{:name 'testA :success (promise)}
{:name 'testB :success (promise)}
{:name 'testC :success (promise)}]}
{:name 'suiteB
(ns joc
(:use [clojure.test]))
(defn rpn-orig
([tokens] (rpn-orig tokens []))
([[top & tail] stack]
(lazy-seq
(if top
(if (fn? top)
(let [l (peek stack)
(ns user
(:use clojure.set))
;; core
(defstruct monad :unit :bind :run :zero :plus)
(defmacro defmonad [name & fdecl]
(let [[doc defs]
(if (string? (first fdecl))
; STM history stress-test
(defn stress [hmin hmax]
(let [r (ref 0 :min-history hmin :max-history hmax)
slow-tries (atom 0)]
(future
(dosync
(swap! slow-tries inc)
(Thread/sleep 200)
@r)
@fogus
fogus / core.clj
Created August 16, 2010 18:13 — forked from hiredman/core.clj
(defmacro fork [x & bodies]
(let [n (gensym)]
`(let [~n ~x]
(pvalues
~@(map (fn [[a & b]]
(cons a (cons n b)))
bodies)))))
(defn join [results fn]
(fn results))