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
var traits = {}; | |
function trait(name, methods) { | |
traits[name] = methods; | |
} | |
function struct() { | |
var args = arguments; | |
// インターフェイスを作成 |
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
trait Eq1 { | |
fn eq1(&self, o: &Self) -> bool; | |
} | |
trait Eq2 { | |
fn eq2(&self, o: &Self) -> bool; | |
} | |
struct I {i:int} impls Eq1, Eq2 { | |
fn eq1(&self, o: &I) -> bool { (*o).i == (*self).i } | |
fn eq2(&self, o: &I) -> bool { (*o).i == (*self).i } | |
} |
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
// orignal code http://openpear.org/package/IO_MIDI/downloads | |
package midi | |
case class Midi(header:Header,tracks:List[Track]) | |
trait Chunk | |
case class Header(format:Int,numberOfTracks:Int,divisionFlag:Int,division:Int) extends Chunk | |
case class Track(List[Event]) extends Chunk | |
trait Event | |
class IO_MIDI { |
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
def classify(xts:List[('a,Type.T)], ini:'b, addf:('b,'a)=>'b, addi:('b,'a,Type.T)=>'b):'b = { | |
xts.foldLeft(ini) { | |
case (acc, (x, t)) => t match { | |
case Type.Unit() => acc | |
case Type.Float() => addf(acc, x) | |
case _ => addi(acc, x, t) | |
} | |
} | |
} |
NewerOlder