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
object SemiGroupApp { | |
trait SemiGroup[T] { | |
def append(a: T, b: T): T | |
} | |
/*object IntSemiGroup extends SemiGroup[Int] { | |
def append(a: Int, b: Int) = a + 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
package utils | |
import org.joda.time.DateTime | |
import org.joda.time.format.{DateTimeFormatterBuilder, DateTimeFormat, DateTimeFormatter} | |
import scala.concurrent.stm._ | |
/** | |
* Created by liaoshifu on 2015/4/11 | |
*/ |
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
sealed trait KVStoreA[A] | |
case class Put[A](key: String, value: A) extends KVStoreA[Unit] | |
case class Get[A](key: String) extends KVStoreA[A] | |
case class Delete(key: String) extends KVStoreA[Unit] | |
import cats.free.Free | |
type KVStore[A] = Free[KVStoreA, A] | |
import cats.free.Free.liftF |
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 updateLiveStats( | |
time: Time, | |
liveId: String, | |
event: Option[Iterable[LiveEvent]], | |
state: State[LiveStatistics] | |
): Option[LiveStatistics] = { | |
event.flatMap { es => | |
val (creates, notCreates) = es.partition(_.isCreate) |
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
import shapeless.{:+:, ::, CNil, Coproduct, Generic, HList, HNil, Inl, Inr, Lazy} | |
/** | |
* http://www.cakesolutions.net/teamblogs/solving-problems-in-a-generic-way-using-shapeless | |
*/ | |
trait Depth[T] { | |
def depth(t: T): Int | |
} | |
object Depth { |
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
use std::borrow::BorrowMut; | |
use std::ptr::replace; | |
pub fn do_sth() { | |
test_merge_sort(); | |
} | |
fn merge_sort(to_sort: &mut Vec<i32>, all: &mut Vec<i32>) { | |
let len = to_sort.len(); |
OlderNewer