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 test.dialect | |
(:require [clojure.contrib.string :as st])) | |
(defn pig-latinize [word] | |
(let [fs (str (first word))] | |
(str | |
(if (re-seq #"(?i)[aeiou]" fs) | |
word | |
(str (subs word 1) fs)) | |
"ay"))) |
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
class A | |
class A2 extends A | |
class B | |
trait M[X] | |
// | |
// Upper Type Bound | |
// | |
def upperTypeBound[AA <: A](x: AA): A = x |
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
case class ElectricCar(b: Battery) { def batteryLevel = b.filledPercentage } | |
case class GasolineCar(g: GasTank) { def gasLevel = g.filledPercentage } | |
case class Battery(filledPercentage: Int) { def fill: Battery = Battery(100) } | |
case class GasTank(filledPercentage: Int) { def fill: GasTank = GasTank(100) } | |
trait Fills[C] { | |
def fill(car: C): C |
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
module Zipper where | |
import Data.List | |
import Text.JSON | |
import Data.Maybe | |
import Control.Monad | |
data JSZipper = JSZipper { | |
parent :: Maybe JSZipper, | |
lefts :: [JSValue], |
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
smooth() | |
noStroke() | |
fill(226) | |
frameRate(10) | |
size(400,400) | |
case class Color(red:Int,blue:Int,green:Int) | |
case class Ball(x:Int,y:Int,color:Color,radius:Int) | |
def draw { |
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 scalaz.{Failure => _, _} | |
import Scalaz._ | |
import effects._ | |
import iteratees._ | |
import java.io._ | |
object Head { | |
def main(args: Array[String]) { | |
val enum = enumStream[Seq[Byte], IO]((1 to 50).toStream.map(i => ("line " + i + "\n").getBytes.toSeq)) |
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 scalaz.example | |
import scalaz.AltDList._ | |
object ExampleAltDList { | |
def main(args: Array[String]) = run | |
import scalaz._, Scalaz._ | |
import IterV._ |
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
implicit def MapMonoid[K, V](implicit valueSemigroup: Semigroup[V]): Monoid[Map[K, V]] = new Monoid[Map[K, V]] { | |
override val zero = Map.empty[K, V] | |
override def append(m1: Map[K, V], m2: => Map[K, V]) = { | |
val (from, to, semigroup) = { | |
if (m1.size > m2.size) (m2, m1, (v1: V, v2: V) => valueSemigroup.append(v1, v2)) | |
else (m1, m2, (v1: V, v2: V) => valueSemigroup.append(v2, v1)) | |
} | |
from.foldLeft(to) { | |
case (to, (k, v)) => to + (k -> to.get(k).map(semigroup(_, v)).getOrElse(v)) |
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 scalaz.{Failure => _, _} | |
import Scalaz._ | |
import effects._ | |
import iteratees._ | |
import java.io._ | |
object Head { | |
def main(args: Array[String]) { | |
val enum = enumStream[Seq[Byte], IO]((1 to 50).toStream.map(i => ("line " + i + "\n").getBytes.toSeq)) |
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
;; An example of the "accounts" program for Venkat Subramaniam's | |
;; Programming Concurrency Workshop, part 1 | |
;; | |
;; Original Java code by Venkat Subramaniam (@venkat_s) | |
;; available at http://www.agiledeveloper.com/downloads.html | |
;; under "Workshop: Programming Concurrency" | |
;; | |
;; This code example by Stuart Sierra (@stuartsierra) | |
;; | |
;; Überconf 2011, Denver, Colorado |
OlderNewer