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 java.io._ | |
import java.awt._ | |
import java.awt.geom._ | |
import java.awt.event._ | |
import java.awt.image.BufferedImage | |
import javax.swing.{ImageIcon, JWindow, JLabel, JFrame} | |
import javax.imageio.ImageIO | |
import java.net.{URL,HttpURLConnection,URLEncoder} | |
import scala.io.Source | |
import scala.xml.{XML,NodeSeq } |
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> class やる気[T]( theSeq:Seq[T]) extends Seq[T]{ | |
| def apply(i:Int) = theSeq(i) | |
| def length = theSeq.length | |
| def iterator = theSeq.iterator | |
| } | |
defined class やる気 | |
scala> new やる気( List.empty[Nothing] ) | |
res1: やる気[Nothing] = line1() |
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
// immutable.TreeSetで + で要素を追加されるとSort順がヘンなTreeSetが返る。これバグなの? | |
scala> val l = List( "bbb","aa" ,"eee","cc") | |
l: List[java.lang.String] = List(bbb, aa, eee, cc) | |
scala> val ts = TreeSet( l : _* ) | |
ts: scala.collection.immutable.TreeSet[java.lang.String] = TreeSet(aa, bbb, cc, eee) | |
scala> val newts = ts + "ab" | |
newts: scala.collection.immutable.TreeSet[java.lang.String] = TreeSet(eee, ab, bbb, cc, aa) |
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
// Optionをfor式で受けるとうれしい場合をちょっと思い付いたので | |
scala> val (o1,o2,o3) = ( Some("foo"),None,Some("bar") ) | |
o1: Some[java.lang.String] = Some(foo) | |
o2: object None = None | |
o3: Some[java.lang.String] = Some(bar) | |
// 3つのOptionがすべて値を持つ場合のみtuple3を作り出したいときは | |
// for式のgeneratorにOptionを与えると記述が簡単になる | |
scala> for( v1 <- o1; v2 <- o2; v3 <- o3) yield { ( v1,v2,v3 ) } | |
res5: Option[(java.lang.String, Nothing, java.lang.String)] = None |
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
// 1階マルコフ連鎖で奇声を発するジェネレータ。どうせ意味のある文章を生成するつもりもないので | |
// 1階マルコフ連鎖で充分よっ。 | |
// | |
// こんなのが出ます。おまえなにやってんの?ぎょぱーーーっ!! | |
// ほにゃあ! | |
// ぃっーー!!! | |
// よぅ…くんくんくんどるぷぇー | |
// ほにゃっぱ | |
// ぃぱ | |
// よぅぅ…くんくんっ |
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
// implict conversionやPartialFunctionを駆使した奇妙なFizzBuzz | |
// PartialFunction[A,B]を "A --> B"のように書けるようにしておく | |
type -->[A,B] = PartialFunction[A,B] | |
// FizzBuzz用のPartailFunctionを生成するユーティリティ | |
def toPF[A]( r:String )( f: A => Boolean): A --> String = | |
{ case v if f(v) => r } | |
// FizzBuzzできるSeq |
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
#!/usr/bin/ruby | |
# rubyの練習で書いたTwitte APIをほげるヤツ | |
require 'net/http' | |
require 'json' | |
require 'optparse' | |
class TwitterApi | |
# コンストラクタ | |
def initialize( user, passwd ) |
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 scala.math._ | |
class OldJpNumber private ( val jpNumber:String , val number:Long ){ | |
override def toString = jpNumber | |
} | |
object OldJpNumber { | |
private val j = Seq( "","壹","貮","參","肆","伍","陸","漆","捌","玖" ) | |
private val t = Seq( "","拾","陌","阡") |
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 java.util.Date | |
import java.text.SimpleDateFormat | |
import java.net.URL | |
import scala.xml._ | |
import scala.xml.parsing.XhtmlParser | |
import scala.io.Source | |
case class User( userId:Int, nickname:String, twitterId:Option[String], join:Boolean = true ) | |
class Event( eventId:String, eventXml:Node ) { | |
lazy val usersXml = XML.load( new URL( "http://api.atnd.org/events/users/?event_id=%s" format eventId )) |
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
diff -r aaecac256d39 src/share/classes/com/sun/tools/javac/parser/Token.java | |
--- a/src/share/classes/com/sun/tools/javac/parser/Token.java Mon Aug 09 16:03:07 2010 -0700 | |
+++ b/src/share/classes/com/sun/tools/javac/parser/Token.java Fri Aug 13 18:07:17 2010 +0900 | |
@@ -76,7 +76,7 @@ | |
PACKAGE("package"), | |
PRIVATE("private"), | |
PROTECTED("protected"), | |
- PUBLIC("public"), | |
+ PUBLIC("pubulic"), | |
RETURN("return"), |