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
package nameInverter; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
public class NameInverter { | |
String invertName(String name) { | |
if (name == null || name.length() <= 0) | |
return ""; |
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 osmos.core) | |
(defn absorb [[size additions] mote] | |
(loop [size size | |
additions additions] | |
(cond | |
(< size 2) [size Double/POSITIVE_INFINITY] | |
(< mote size) [(+ size mote) additions] | |
:else (recur (+ size (dec size)) | |
(inc additions))))) |
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
import scala.collection.immutable | |
class Distro[T](probs: Seq[(T, Double)]) { | |
require((probs.map(_._2).sum - 1.0d).abs < Distro.delta) | |
val probMap: Map[T, Double] = mergeProbs(probs) | |
def map[B](f: T => B): Distro[B] = | |
new Distro(for ((event, prob) <- probMap.toSeq) yield (f(event), prob)) | |
def flatMap[B](f: T => Distro[B]): Distro[B] = |
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 pyindent.test.core | |
(:use midje.sweet | |
pyindent.core)) | |
(fact "Tabs increment to the next multiple of 8" | |
(tabulate 0) => 8 | |
(tabulate 8) => 16 | |
(tabulate 7) => 8 | |
(tabulate 9) => 16) |
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 pyindent.core) | |
(def tabsize 8) | |
(defn tabulate [column] | |
(- (+ column tabsize) | |
(rem column tabsize))) | |
(defn indent-level [^String line] | |
(let [[_ spaces] (re-matches #"^(\s*).*" line)] |
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 berlin.core) | |
(defn composed-lights [amount] | |
[(quot amount 5) | |
(rem amount 5)]) | |
(defn seconds-lights [ss] | |
(if (even? ss) 1 0)) | |
(defn lights [[hh mm ss]] |
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 berlin.core) | |
(defn composed-lights [amount] | |
[(quot amount 5) | |
(rem amount 5)]) | |
(defn seconds-lights [ss] | |
(if (even? ss) 1 0)) | |
(defn lights [[hh mm ss]] |
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 counted [f] | |
(let [times (atom 0)] ; thread safe counter | |
(with-meta (fn [& args] | |
(swap! times inc) | |
(apply f args)) | |
{:times times}))) ; associated as metadata | |
(defn times-runned [f] | |
@(:times (meta f))) |
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 trenes | |
(:require [clojure.string :as str])) | |
(defn empty-cache [c] | |
{:capacity c | |
:values {} | |
:time 0 | |
:misses 0 | |
}) |
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
Just copy the archive to /opt/local/var/macports/distfiles/{port_name}/ |