https://lipn.univ-paris13.fr/bigdata/index.php/How_to_use_Spark_on_Grid5000
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 RandomAccessList { | |
type RandomAccessList[A] = List[(CompleteBinaryTree[A], Int)] | |
def fromList[A](xs: List[A]): RandomAccessList[A] = { | |
def sublists[A](xs: List[A]): List[(List[A], Int)] = { | |
def inner(xs: List[A], size: Int, acc: List[(List[A], Int)]): List[(List[A], Int)] = size match { | |
case 0 => acc | |
case s => { | |
val s_ = Math.pow(2, Math.floor(Math.log(s + 1) / Math.log(2))).toInt - 1 | |
inner(xs.take(s - s_), s - s_, (xs.drop(s - s_), s_)::acc) |
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
sealed trait CompleteBinaryTree[A] { | |
def lookup(size: Int, index: Int): A = (this, index) match { | |
case (Leaf(x), 0) => x | |
case (Leaf(_), _) => throw new Exception("Index is not in list.") | |
case (Node(x, _, _), 0) => x | |
case (Node(x, l, _), i) if i <= size / 2 => l.lookup(size / 2, i - 1) | |
case (Node(x, _, r), i) if i > size / 2 => r.lookup(size / 2, i - 1 - size / 2) | |
} | |
def update(size: Int, index: Int, y: A): CompleteBinaryTree[A] = (this, index) match { | |
case (Leaf(_), 0) => Leaf(y) |
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 util._ | |
import dom.ext._ | |
import scala.scalajs.concurrent.JSExecutionContext.Implicits.runNow | |
object ScalaJSExample extends js.JSApp{ | |
def main(): Unit = { | |
val url = | |
"http://jsonplaceholder.typicode.com/posts/1" | |
val f=Ajax.get(url) | |
f.onComplete{ |
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 Main extends App { | |
AvoidLosingGenericType.run() | |
AvoidMatchingOnGenericTypeParams.run() | |
TypeableExample.run() | |
TypeTagExample.run() | |
} | |
class Funky[A, B](val foo: A, val bar: B) { | |
override def toString: String = s"Funky($foo, $bar)" | |
} |
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
/** This is in reference to @tploecat's blog http://tpolecat.github.io/2015/04/29/f-bounds.html | |
* where he compares F-bounded polymorphism and type classes for implementing "MyType". | |
* | |
* Curiously, the in my mind obvious solution is missing: Use abstract types. | |
* | |
* A lot of this material, including an argument against F-bounded for the use-case | |
* is discussed in: | |
* | |
* Kim B. Bruce, Martin Odersky, Philip Wadler: | |
* A Statically Safe Alternative to Virtual Types. ECOOP 1998: 523-549 |
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 your.pkg.here | |
import java.security.MessageDigest | |
import java.nio.file.{Files, Paths} | |
object Generator { | |
implicit class Helper(val sc: StringContext) extends AnyVal { | |
def md5(): String = generate("MD5", sc.parts(0)) | |
def sha(): String = generate("SHA", sc.parts(0)) | |
def sha256(): String = generate("SHA-256", sc.parts(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
# Scaladoc Developer Guide | |
## Introduction | |
Scaladoc is the tool that enables developers to automatically generate documentation for their Scala (and Java) projects. It is Scala's equivalent of the widely-used Javadoc tool. This means that Javadoc (and even doxygen) users will be familiar with Scaladoc from day 1: for them, it is most beneficial to check out the Scaladoc/Javadoc comparison tables and if necessary, skim through this document to understand specific features. | |
The rest of this tutorial is aimed at developers new to Scaladoc and other similar tools. It assumes a basic understanding of the Scala language, which is necessary to follow the examples given throughout the tutorial. For the user perspective on the Scaladoc-generated documentation, such as finding a class, understanding the page layout, navigating through diagrams, please refer to the Scaladoc User Guide. | |
The tutorial will start by a short motivation and then will explain the main concept in Scaladoc: the doc comment. | |
### Why document? |