$ ./amm
Loading...
Welcome to the Ammonite Repl 0.4.7
(Scala 2.11.7 Java 1.8.0_45)
@ load.ivy("com.typesafe" % "config" % "1.3.0")
@ val configString = """
|app {
| root = "baseDir"
#!/bin/bash | |
# | |
# ========================================================================= | |
# Copyright 2014 Rado Buransky, Dominion Marine Media | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 |
package data.listmap | |
/** | |
* Created by yoelusa on 30/10/14. | |
*/ | |
trait ListMap[+A, +B] { | |
def allKeys: List[A] = { | |
def go(m: ListMap[A, B], ac: List[A]): List[A] = m match { |
package data.pinetree | |
trait Pine[+A] { | |
def inOrderTrav[B](f: A => (B => B))(ac: B): B = this match { | |
case End(a) => f(a)(ac) | |
case Fork(a,l,r) => | |
r.inOrderTrav (f) (f(a) (l.inOrderTrav (f) (ac) )) | |
} |
package com.instabt | |
/** | |
* Created by yoelusa on 30/10/14. | |
*/ | |
import org.apache.commons.codec.binary.Base64 | |
import play.api.data.Form | |
import play.api.data.Forms._ | |
import play.api.libs.ws._ |
// immutable cycle | |
class Node[T]( val value: T, _next: => Node[T] ){ | |
lazy val next = _next | |
} | |
val cycle: Node[Int] = new Node( 1, new Node( 2, cycle ) ) | |
// prints List(1, 2, 1, 2, 1, 2, 1, 2, 1, 2) | |
println(cycle.iterator.take(10).map(_.value).toList) | |
implicit class NodeIterator[T](node: Node[T]){ |
package extra.queuemanager | |
import akka.actor._ | |
import scala.collection.mutable | |
import scala.collection.immutable | |
import scala.util.Failure | |
/** | |
* Created by yoelusa on 31/03/15. | |
*/ |
object StateApply { | |
import scalaz._ | |
implicit def applyState[F[_], A](implicit F: Applicative[F], S: Semigroup[A]): Applicative[({ type l[a] = StateT[F, A, a]})#l] = new Applicative[({ type l[a] = StateT[F, A, a]})#l] { | |
def point[B](b: => B): StateT[F, A, B] = StateT[F, A, B]((a:A) => F.point((a,b))) | |
def ap[B, C](fa: => StateT[F, A, B])(f: => StateT[F, A, B => C]): StateT[F, A, C] = { | |
StateT[F, A, C]((s: A) => { | |
val sa = fa.run(s) | |
val sb = f.run(s) |
Every application ever written can be viewed as some sort of transformation on data. Data can come from different sources, such as a network or a file or user input or the Large Hadron Collider. It can come from many sources all at once to be merged and aggregated in interesting ways, and it can be produced into many different output sinks, such as a network or files or graphical user interfaces. You might produce your output all at once, as a big data dump at the end of the world (right before your program shuts down), or you might produce it more incrementally. Every application fits into this model.
The scalaz-stream project is an attempt to make it easy to construct, test and scale programs that fit within this model (which is to say, everything). It does this by providing an abstraction around a "stream" of data, which is really just this notion of some number of data being sequentially pulled out of some unspecified data source. On top of this abstraction, sca
#!/bin/bash | |
declare -r TRUE=0 | |
declare -r FALSE=1 | |
# takes a string and returns true if it seems to represent "yes" | |
function isYes() { | |
local x=$1 | |
[ $x = "y" ] && echo $TRUE; return | |
[ $x = "Y" ] && echo $TRUE; return |