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
/* *** Arithmetic *** */ | |
import Math._ | |
import S99Int._ | |
class S99Int(val start: Int) { | |
def isPrime: Boolean = { | |
(true /: List.range(2, start / 2)) { (decision, n) => | |
decision && start % n != 0 | |
} |
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
/* Examples of using Stream to create lazily evaluated collections */ | |
def integersFrom(n: Int): Stream[Int] = | |
Stream.cons(n, integersFrom(n + 1)) | |
val naturals = integersFrom(1) | |
// From: http://www.scala-blogs.org/2007/12/project-euler-fun-in-scala.html | |
val fib: Stream[Int] = | |
Stream.cons(0, Stream.cons(1, fib.zip(fib.tail).map(p => p._1 + p._2))) |
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> val f: (Any*) => Unit = { (s, n) => println(s * n) } | |
<console>:4: error: wrong number of parameters; expected = 1 | |
val f: (Any*) => Unit = { (s, n) => println(s * n) } |
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
var times = 500000, | |
benchmarks = {}, | |
objects, | |
sys = { | |
puts: function() { console.log.apply(console, arguments); } | |
}; | |
function bm(label, fn) { | |
benchmarks[label] = fn; | |
}; |
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
/** | |
* CSS addon for Kongregate Asynchronous JavaScript Loader | |
* | |
* Adds support to KJS for loading CSS files. | |
* | |
* You can find KJS at: | |
* https://gist.github.com/388e70bccd3fdb8a6617 | |
* | |
* Usage: | |
* |
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
/** | |
* From the W3C working draft | |
* http://www.w3.org/TR/IndexedDB | |
*/ | |
// synchronously set properties on a database and retrieve a record | |
var db = indexedDB.open('books', 'Book store', false); | |
if (db.version !== '1.0') { | |
var olddb = indexedDB.open('books', 'Book store'); |
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
def makeClos() { | |
def x = 0; | |
def close = { x += 1; println(x) } | |
close | |
} | |
def closA = makeClos() | |
def closB = makeClos() | |
closA() // prints 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
/* | |
* Set#groupBy() is not defined in Scala 2.7. | |
*/ | |
class GroupableSet[A](val set: Set[A]) { | |
def groupBy[K](grouping: A => K): Map[K, Set[A]] = { | |
val init: Map[K, Set[A]] = Map() | |
set.foldLeft(init) { (map, e) => | |
val key = grouping(e) | |
val group = map.getOrElse(key, Set()) | |
map + (key -> (group + e)) |
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
/** | |
* Minimal implementation of Modules/AsynchronousDefinition as described | |
* in http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition | |
* | |
* For a more complete implementation use RequireJS | |
* <http://requirejs.org/>. | |
*/ | |
var define = (function() { | |
var definitions = {}, |
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
GET /__services/v2/rest/browserEvents/1310753774420?e=activityStream.poll | |
Accept: application/json, text/javascript, */*; q=0.01 | |
Cookie: jive_wysiwygtext_height=845; jive.server.info="serverName=brewspace.jiveland.com:serverPort=443:contextPath=:localName=localhost.localdomain:localPort=9001:localAddr=127.0.0.1"; JSESSIONID=1310674633500msE1CFA7B08138FBC7B9618EC2273CC269.node02; SPRING_SECURITY_REMEMBER_ME_COOKIE=amVzc2UuaGFsbGV0dDoxMzExODg0MjMzNTAwOmJiODI3YzRkZGU3ZjRmMTA2NjZkYzJmMjBiYmY3YWFj; jive.user.loggedIn=true; demoStyle=mainCSS; __utma=194160894.284716925.1284424263.1310689961.1310753078.814; __utmb=194160894.5.10.1310753078; __utmc=194160894; __utmz=194160894.1310753078.814.65.utmcsr=jira.jivesoftware.com|utmccn=(referral)|utmcmd=referral|utmcct=/browse/JIVE-4471 | |
Host: brewspace.jiveland.com | |
Referer: https://brewspace.jiveland.com/content | |
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.56 Safari/535.1 | |
X-J-Token: 39fd41326e56a1e0a075 | |
X-Requested-With: X |