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
@JSExport | |
object ScalaJSExample{ | |
@JSExport | |
def main(args: Array[String]): Unit = { | |
val xs = Seq(1, 2, 3) | |
println(xs) | |
val ys = Seq(4, 5, 6) | |
println(ys) | |
val zs = for{ | |
x <- xs |
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
--- a/spray-util/src/main/scala/spray/util/pimps/PimpedRegex.scala | |
+++ b/spray-util/src/main/scala/spray/util/pimps/PimpedRegex.scala | |
@@ -20,12 +20,9 @@ import java.util.regex.Pattern | |
import scala.util.matching.Regex | |
class PimpedRegex(regex: Regex) { | |
def groupCount = { | |
try { | |
- val field = classOf[Pattern].getDeclaredField("capturingGroupCount") | |
- field.setAccessible(true) |
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 thing = { | |
val sp = span.value | |
lazy val box: HTMLTextAreaElement = textarea( | |
onChange := () => span.innerHTML = box.value | |
).value | |
div(box, sp) | |
} |
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 utest._ | |
object Tests extends TestSuite | |
val tests = TestSuite do | |
'simple do | |
'class-assert((new scalite.simple.Class)() == "Hello World!12") | |
'assignments-assert((new scalite.simple.Assignments)() == 9) | |
'modassignments-assert((new scalite.simple.ModAssignments)() == 9) | |
'ifelsewhile-assert((new scalite.simple.IfElseWhile)() == 40) | |
'ifelsewhilelite-assert((new scalite.simple.IfElseWhileLite)() == 36) |
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 com.example | |
import akka.actor.Actor | |
import spray.routing._ | |
import spray.http._ | |
import MediaTypes._ | |
// we don't implement our route structure directly in the service actor because | |
// we want to be able to test it independently, without having to spin up an actor |
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 com.example | |
import akka.actor.Actor | |
import spray.routing._ | |
import spray.http._ | |
import MediaTypes._ | |
// we don't implement our route structure directly in the service actor because | |
// we want to be able to test it independently, without having to spin up an actor |
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 words(s: String): Set[String] | |
def makeWordMap(sentences: List[String]) = { | |
val forwardMap = sentences.map(s => (s, words(s))).toMap | |
sentences.flatMap(words) | |
.distinct | |
.map(w => sentences.filter(forwardMap(s))) | |
} | |
def makeWordMap2(sentences: List[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
package ammonite.sh2 | |
import acyclic.file | |
import scala.collection.{immutable => imm} | |
object PConfig{ | |
implicit val pc = new PConfig() | |
} | |
case class PConfig(maxDepth: Int = 100, depth: Int = 0) | |
object PPrint extends LowPriPPrint{ |
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
[info] Running ammonite.repl.Repl | |
@ Range(0, 5).ma | |
max map maxBy | |
@ while(true) () | |
Interrupted! | |
@ val x = 1 | |
x: Int = 1 | |
@ val y = 2 | |
y: Int = 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
// Input Scala sources | |
def lightIsVisible(l: Vec, p: Vec) = { | |
val ray = Ray(p, l - p) | |
val length = (l - p).magnitude | |
var visible = true | |
for (i <- 0 until objects.length){ | |
val (o, s) = objects(i) | |
val t = o.intersectionTime(ray) | |
if (t > Epsilon && t < length - Epsilon){ | |
visible = false |
OlderNewer