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.math.{BigDecimal => BD, MathContext} | |
import BD.{ZERO, ONE} | |
/** | |
* This program will calculate Pi with John Machin[1]'s formula[2]. | |
* This is just a translation from Mr. Kishida's Java implementation[3] to | |
* Scala one. | |
* | |
* [1] http://en.wikipedia.org/wiki/John_Machin | |
* [2] http://upload.wikimedia.org/math/f/1/5/f15dc3d39c473c4bd718e3a98145da0d.png |
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.math.{BigDecimal => BD, MathContext} | |
import BD.{ZERO, ONE} | |
/** | |
* This program will calculate Pi with John Machin[1]'s formula[2]. | |
* This is just a translation from Mr. Kishida's Java implementation[3] to | |
* Scala one. | |
* | |
* [1] http://en.wikipedia.org/wiki/John_Machin | |
* [2] http://upload.wikimedia.org/math/f/1/5/f15dc3d39c473c4bd718e3a98145da0d.png |
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 pdr; | |
import javax.swing._; | |
import java.awt._ | |
import java.awt.geom._; | |
import java.awt.image._ | |
import java.io._ | |
import scala.collection.mutable.ArrayBuffer | |
import scala.collection.mutable.HashMap |
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
/* | |
Copyright (c) 2008 ymnk, JCraft,Inc. All rights reserved. | |
Redistribution and use in source and binary forms, with or without | |
modification, are permitted provided that the following conditions are met: | |
1. Redistributions of source code must retain the above copyright notice, | |
this list of conditions and the following disclaimer. | |
2. Redistributions in binary form must reproduce the above copyright |
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.tools.nsc.{Interpreter, Settings, Global} | |
import scala.tools.nsc.util.{Position,NoPosition, ShowPickled} | |
import scala.reflect.generic.{PickleFormat, PickleBuffer} | |
import scala.tools.nsc.symtab.classfile.{ClassfileParser} | |
import scala.tools.nsc.io.AbstractFile | |
import java.io.{OutputStream, PrintStream, ByteArrayOutputStream} | |
object DumpGenericsSignature { | |
class MyParser extends ClassfileParser{ | |
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
/* | |
Copyright (c) 2008 ymnk, JCraft,Inc. All rights reserved. | |
Redistribution and use in source and binary forms, with or without | |
modification, are permitted provided that the following conditions are met: | |
1. Redistributions of source code must retain the above copyright notice, | |
this list of conditions and the following disclaimer. | |
2. Redistributions in binary form must reproduce the above copyright |
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.xml.Node | |
import scala.collection.immutable.Set | |
import scala.util.Sorting | |
/** | |
* This program will demonstrate how to use scala.util.Sorting. | |
*/ | |
object SortingDemo { | |
def main(arg:Array[String])={ | |
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.net.{Authenticator, PasswordAuthentication} | |
import java.net.{URL, HttpURLConnection} | |
import scala.xml.{XML, Node} | |
import scala.collection.mutable.Map | |
class FriendOrFollow (screen_name:String) { | |
private val friends_url = "http://twitter.com/statuses/friends/%s.xml" | |
lazy val friends:Map[String, Node] = | |
getMap(friends_url.replace("%s", screen_name)) |
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.xml._ | |
import scala.util.parsing.json.JSON | |
/** | |
* The XML2JSON object will transform a string in json format to | |
* a NodeSeq object. | |
*/ | |
object JSON2XML { | |
def apply(input:String):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
import scala.util.parsing.combinator.lexical.StdLexical | |
import scala.util.parsing.combinator.syntactical.StdTokenParsers | |
/** | |
* This program will parse the arithmetic expression defined as follows, | |
* <exp> ::= <term> | <exp> "+" <term> | <exp> "-" <term> | |
* <term> ::= <factor> | <term> "*" <factor> | <term> "/" <factor> | |
* <factor> ::= <n> | "(" <exp> ")" | |
* , where n is a nonterminal symbol for numbers. | |
* |