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 Network.HTTP | |
import Data.ByteString.Lazy.Char8 as B | |
import Codec.Text.IConv | |
main :: IO() | |
main = do | |
htmlSrc <- openURL "http://flowermaster.web.fc2.com/lrnanido_sara.html" | |
let src = convert "CP932" "UTF-8" $ B.pack htmlSrc | |
B.putStrLn src | |
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 Data.Attoparsec.ByteString.Char8 as AP | |
import Data.ByteString.Char8 as B | |
import Control.Applicative | |
data MusicData = MusicData { | |
dID :: Integer, | |
dLevel :: String, | |
dMusicTitle :: String, | |
dBmsID :: Integer, |
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 Control.Monad(forM_) | |
import Text.Printf | |
main :: IO() | |
main = do | |
txt <- getContents | |
let ls = lines txt | |
num = head ls | |
ps = mklist $ tail ls |
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
object MyIteratee{ | |
sealed trait Input[+E] { | |
} | |
object Input { | |
case class El[+E](e: E) extends Input[E] | |
case object EOF extends Input[Nothing] | |
} | |
trait Iteratee[E, A] { |
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 localhost | |
import scala.tools.nsc | |
import nsc.Global | |
import nsc.plugins.Plugin | |
import nsc.plugins.PluginComponent | |
import nsc.transform.Transform | |
class LazyTracePlugin(val global: Global) extends Plugin { | |
import global._ |
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 localhost | |
import scala.tools.nsc | |
import nsc.Global | |
import nsc.plugins.Plugin | |
import nsc.plugins.PluginComponent | |
import nsc.transform.Transform | |
import scala.tools.nsc.ast.TreeGen | |
import scala.tools.nsc.symtab.Flags |
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
// Scalaの限定継続で四天王問題解いてみた その2 | |
// http://q.hatena.ne.jp/1284217294 | |
// scalac -P:continuations:enable Amb2.scala | |
import scala.util.continuations._ | |
object Amb{ | |
def amb[T](lst:T*):T @ cpsParam[Unit,Unit] = shift{k:(T=>Unit) => lst.foreach(k)} | |
def require(p:Boolean):Unit @ cpsParam[Unit,Unit] = shift{k:(Unit=>Unit) => if(p)k()} |
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
// Scalaの限定継続で四天王問題解いてみた | |
// scalac -P:continuations:enable Amb.scala | |
import scala.util.continuations._ | |
object Amb{ | |
def amb(lst:Int*):Int @ cpsParam[Unit,Unit] = shift{k:(Int=>Unit) => lst.foreach(k)} | |
def require(p:Boolean):Unit @ cpsParam[Unit,Unit] = shift{k:(Unit=>Unit) => if(p)k()} |
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
#!/bin/sh | |
exec scala -deprecation "$0" | |
!# | |
// ScalaのfjbgでHello,World | |
import ch.epfl.lamp.fjbg._ | |
val context = new FJBGContext() | |
import JAccessFlags._ | |
val jclass = context.JClass(ACC_PUBLIC, |
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
// 最大回避ヒープ | |
object BinaryTree{ | |
import scala.math._ | |
case class Fork[T](val cnt:Int, val v:T, val lhs:Tree[T], val rhs:Tree[T]){ | |
override def toString = "(" + v.toString + "," + (lhs.toString) + "," + rhs.toString + ")" | |
def size = cnt | |
} | |
def merge[T<%Ordered[T]](lhs:Tree[T],rhs:Tree[T]):Tree[T] = (lhs,rhs) match { |
NewerOlder