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 dfs2; | |
abstract class Graph { | |
type Edge | |
type Node <: NodeIntf | |
abstract class NodeIntf { | |
def connectWith(node: Node): Edge | |
} | |
def nodes: Set[Node] | |
def edges: Set[Edge] |
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 exercises | |
object NinetyNine { | |
//P01 | |
def last[A](xs:List[A]):A = xs match { | |
case x::Nil => x | |
case x::xs => last(xs) | |
case Nil => throw new NoSuchElementException | |
} | |
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 scrapbook | |
object PlayWithUTF { | |
val Π = Math.Pi | |
def √(x:Double)=Math.sqrt(x) | |
val x= √(9*Π) | |
def ∑(r:Range)(f:Int =>Int)=r.reduceLeft(_+ f(_)) |
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 webtest | |
import java.net._ | |
import scala.xml._ | |
object WebTester { | |
def open(url:URL):HttpURLConnection = url.openConnection match { | |
case c:HttpURLConnection => c | |
case _ => error("Only HTTP connections allowed") |
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 workbench; | |
import javax.xml.parsers.ParserConfigurationException; | |
import org.xml.sax.SAXNotRecognizedException; | |
import org.xml.sax.SAXNotSupportedException; | |
import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl; | |
public class MyXMLParserFactory extends SAXParserFactoryImpl { |
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 gameoflife | |
class Board[T](val b:Array[Array[T]]) { | |
val h=b.size | |
val w=b(0).size | |
def conv(idx:Int,max:Int)=if (idx<0) (max-Math.abs(idx %max) ) else (idx % max ) | |
def apply(x:Int,y:Int)=b(conv(x,h))(conv(y,w)) | |
def update(x:Int,y:Int,value:T)= b(conv(x,h))(conv(y,w))=value |
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 tm | |
sealed trait List[+A] { | |
override def toString = { | |
def toScalaList(t: List[A]): scala.List[A] = t match { | |
case Empty => Nil | |
case Cons(h, t) => h :: toScalaList(t) | |
} | |
toScalaList(this).toString | |
} |
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 tm | |
trait PartialType[T[_, _], A] { | |
type Apply[B] = T[A, B] | |
type Flip[B] = T[B, A] | |
} | |
trait Fluffy[F[_]] { | |
def furry[A, B](f: A => B, fa: F[A]): F[B] | |
} |
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
#lang scheme | |
(define atom? (let ((f1 pair?) (f2 not)) (lambda (x) (f2 (f1 x))))) | |
(define lat? | |
(lambda (lat) | |
(cond | |
((null? lat) #t) | |
((atom? (car lat)) (lat? (cdr lat))) | |
(else #f) | |
))) |
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
/** | |
* Created by IntelliJ IDEA. I | |
* User: gabriel | |
* Date: Jun 15, 2010 | |
* Time: 11:55:59 PM | |
* To change this template use File | Settings | File Templates. | |
*/ | |
import java.awt.{Color,Container,Graphics,Canvas,Dimension} |
OlderNewer