A sample batch file running a scala script with process to call external commands.
The same can be done for *nix systems.
| package info.daviot.lceb | |
| import scala.util.parsing.combinator._ | |
| sealed trait Expr { def eval: Int } | |
| case class Number(value: Int) extends Expr { | |
| val eval = value | |
| } | |
| case class Prod(left: Expr, right: Expr) extends Expr { | |
| def eval = left.eval * right.eval | |
| } |
A sample batch file running a scala script with process to call external commands.
The same can be done for *nix systems.
| package misc; | |
| import scala.LowPriorityImplicits; | |
| import scala.Predef.; | |
| import scala.collection.IterableLike; | |
| import scala.collection.TraversableOnce; | |
| import scala.collection.immutable.List; | |
| import scala.collection.immutable.List.; | |
| public final class ImportExperiment$ |
| [remote "origin"] | |
| fetch = +refs/heads/*:refs/remotes/origin/* | |
| url = http://[email protected]/git/activiti-xa | |
| [remote "github"] | |
| fetch = +refs/heads/*:refs/remotes/origin/* | |
| url = https://github.com/Activiti/Activiti.git | |
| proxy = http://proxy:3128 |
| import scala.util.Random | |
| import scala.collection.immutable.SortedMap | |
| object ATGC extends App { | |
| def randomString(size: Int) = List.fill(size)(randomChar).mkString | |
| def randomChar = "ATGC"(Random.nextInt(4)) | |
| def analyze(s: String): Map[String, Int] = { | |
| val (_, _, res) = (s + "Z").tail.foldLeft((s.head, 1, SortedMap.empty[String, Int] withDefaultValue 0)) { | |
| case ((last, count, map), current) if current == last => (last, count + 1, map) |
| import scala.io.Source | |
| import scala.util.parsing.json.JSON | |
| object Sort extends App { | |
| //enter your own values, these won't work ! | |
| val listId = "87308c95352724c5f1" | |
| val key = "01e5ed84e035d27b365db068c" | |
| val token = "56027af793b49845fde60505aa429ad82c6ec332a1f98170246" | |
| val data = Source.fromURL(s"https://api.trello.com/1/lists/$listId/cards?key=$key&token=$token").getLines mkString |
| object Events { | |
| object Event { | |
| def build(typee: String) = { | |
| typee match { | |
| case "foo" => new FooEvent | |
| case "bar" => new BarEvent | |
| } | |
| } | |
| } |
| import scala.collection.immutable.SortedMap | |
| import scala.collection.immutable.NumericRange | |
| object Main extends App { | |
| val halfLife: Double = 60 | |
| val data = Seq( | |
| Blip("a", strength = 1), | |
| Blip("b", strength = 1), | |
| Blip("c", strength = 1), |
| // For an unkown reason, this works when copy/paste in ammonite but not with `amm pca.sc` | |
| import $ivy.`org.scalanlp::breeze-natives:0.13.2` | |
| import $ivy.`org.scalanlp::breeze-viz:0.13.2` | |
| import $ivy.`org.scalanlp::breeze:0.13.2` | |
| import breeze.linalg._ | |
| import breeze.linalg.svd._ | |
| import breeze.plot._ | |
| import scala.util.Random._ |
| import scala.concurrent.Future | |
| import scala.concurrent.ExecutionContext.Implicits.global | |
| import scala.concurrent.Await | |
| import scala.concurrent.duration.DurationInt | |
| object ParallelPrimesCompute extends App { | |
| val primes: Stream[Long] = | |
| 2L #:: Stream.range(3, Long.MaxValue, 2).filter( | |
| n => primes.takeWhile(_ <= Math.sqrt(n)).forall(n % _ != 0)) |