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
/* | |
* This is an attempt to keep references to client actors on a remote actor to push events out to them as appropriate. | |
* Note that, as per the comment in the client actor, the console output shows up on the server console not the client(s) | |
* console(s). | |
* | |
*/ | |
package com.kyrlach.scratch | |
import akka.actor.{Actor,ActorRef} | |
import akka.actor.Actor._ |
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
//A new approach... doesn't work yet. | |
import akka.stm._ | |
import java.util.concurrent.CyclicBarrier | |
import scala.actors.Actor | |
import scala.actors.Actor._ | |
class Player(val id:Int, val matches:Ref[Int], val rating:Ref[Int]) { |
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
//This is as close as I've come thus far, but it cheats. :( | |
object Combinator { | |
def main(args:Array[String]):Unit = { | |
lazy val y:((Int => Int) => (Int => Int)) => (Int => Int) = g => g(y(g))(_) | |
val error:(Int => Int) = n => throw new java.lang.Exception("OOPS") | |
val fp:((Int => Int) => (Int => Int)) = f => n => if (n == 0) 1 else n * f(n - 1) | |
println(y(fp)(10)) |
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 org.cincyfp.actor | |
import scala.actors.Actor | |
import scala.actors.Actor._ | |
object GenFile { | |
def main(args:Array[String]):Unit = { | |
val r = new java.util.Random | |
val f = new java.io.File("test.data") | |
val fos = new java.io.FileOutputStream(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
//Usage | |
Option<String> someString = Option<String>.Some("Hi"); | |
Option<String> noString = Option<String>.None(); | |
Console.WriteLine(someString.Select(x => x.Length).GetOrElse(-1)); | |
Console.WriteLine(noString.Select(x => x.Length).GetOrElse(-1)); | |
//Definition | |
abstract class Option<T> |
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
//Here's some F# code... | |
type Expression = | |
| Number of int | |
| Add of Expression * Expression | |
| Multiply of Expression * Expression | |
| Variable of string | |
let rec Evaluate (env:Map<string,int>) exp = | |
match exp with |
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
abstract class Tree[+A] | |
case class Node[A](l: Tree[A], e: A, r: Tree[A]) extends Tree[A] | |
case object Tip extends Tree[Nothing] | |
abstract class MONOID[T] { | |
val append: T => T => T | |
val identity: T | |
} | |
object IntMonoid extends MONOID[Int] { |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace AST | |
{ | |
class Program | |
{ | |
static void Main(string[] args) |
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 language.experimental.macros | |
import scala.reflect.makro.Context | |
object MacroTest { | |
def lookup_builder(t: List[(Int, Int)], d: Int): Int => Int = macro lookup_builder_impl | |
def lookup_builder_impl(c: Context)(t: c.Expr[List[(Int, Int)]], d: c.Expr[Int]): c.Expr[Int => Int] = { | |
import c.mirror._ | |
import c.universe._ |
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 com.kyrlach.symbol | |
object Identifier { | |
val idents = new java.util.HashMap[Symbol, Identifier] | |
def set[T](s: Symbol, v: T) = { | |
println("Setting " + s + " to " + v) | |
idents.put(s, new Identifier{ type I = T; val init = v }) | |
} | |
def get[T](s: Symbol): T = { | |
println("Getting " + s) |
OlderNewer