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
| case class ReaderWriterStateT[R, W, S, F[_], A]( | |
| run: (R, S) => F[(W, A, S)] | |
| ) { | |
| def map[B](f: A => B)(implicit F: Functor[F]) | |
| : ReaderWriterStateT[R, W, S, F, B] = | |
| ReaderWriterStateT { | |
| case (r, s) => F.map(run(r, s)) { | |
| case (w, a, s) => (w, f(a), s) | |
| } | |
| } |
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 scala.util.DynamicVariable | |
| /** | |
| * A concise JSON DSL in Scala. | |
| * When you want to use, only | |
| * import Jsson._ is needed. | |
| * Note that this program change the semantics of standard -> operator. | |
| * I recommend that you use enclosing block with Jsson as followings: | |
| * { | |
| * import Jsson._ | |
| * val obj = %{ |
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 BinTreeIterator { | |
| sealed trait Tree | |
| case class Node(v: Int, l: Tree, r: Tree) extends Tree | |
| case object Leaf extends Tree | |
| def toIterator(node: Tree): Iterator[Int] = { | |
| def toStream(n: Tree): Stream[Int] = n match { | |
| case Node(v, l, r) => v #:: toStream(l) #::: toStream(r) | |
| case Leaf => Stream.empty | |
| } |
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
| # Print all project items | |
| Recurse-Project -Action {param($item) "`"$($item.ProjectItem.Name)`" is a $($item.Type)" } | |
| # Function to format all documents based on https://gist.github.com/984353 | |
| function Format-Document { | |
| param( | |
| [parameter(ValueFromPipelineByPropertyName = $true)] | |
| [string[]]$ProjectName | |
| ) | |
| Process { |
NewerOlder