Skip to content

Instantly share code, notes, and snippets.

.gradle
/local.properties
/.idea/workspace.xml
.DS_Store

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

## Functional Track talks from NDC London 2014
### Wednesday 2014-12-3
* [F-Words - Functional Programming Terms With More Than Four Letters - Calvin Bottoms](http://www.ndcvideos.com/#/app/video/2191)
* [Reactive Game Development For The Discerning Hipster - Bodil Stokke](http://www.ndcvideos.com/#/app/video/2221)
* [Erlang Patterns Matching Business Needs -- Torben Hoffman](http://www.ndcvideos.com/#/app/video/2211)
* [Equivalence Classes, xUnit.net, FsCheck, Property-Based Testing -- Mark Seemann](http://www.ndcvideos.com/#/app/video/2291)
* [Functional programming design patterns -- Scott Wlaschin](http://www.ndcvideos.com/#/app/video/2311)
* [Write Your Own Compiler in 24 Hours -- Phillip Trelford](http://www.ndcvideos.com/#/app/video/2281)

Introduction to scalaz-stream

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

@goral09
goral09 / clojureVersion.clj
Created July 22, 2015 19:04
clojure version
(defn hiddenMsg [size seq]
(frequencies (map #(apply str %) (partition size 1 seq)))
)
(hiddenMsg 2 "ATAATGATATTAGAGACAAT")
;{"AA" 2, "TT" 1, "AC" 1, "AG" 2, "TA" 3, "AT" 5, "TG" 1, "GA" 3, "CA" 1}
def hiddenMsg(kmer: Int, msg: String) = {
msg.sliding(kmer).foldLeft[Map[String, Int]](Map.empty) { case (acc, curr) =>
if (acc.isDefinedAt(curr)) acc.updated(curr, acc(curr) + 1)
else acc.updated(curr, 1)
}
}
class Animal(name: String, size: Int)
object Animal {
def apply(name: String, size: Int) = new Animal(name, size)
def unapply(a: Animal): Option[(String, Int)] = Option((a.name, a.size))
}
def myHumorToday: Animal = Animal("Dog", scala.util.Random.nextInt(50))
def depsOnMyHumor(a: Animal) = a match {
case myHumorToday => "you got lucky boy!"
def mdropFirstE[T0](xs: MList { type T = T0 })
: MList { type T = T0 } =
xs.uncons match {
case None => MNil()
case Some(ml) => ml.tail
}
def pdropFirst[T](xs: PList[T]): PList[T] = xs match {
case PNil() => PNil()
case PCons(_, t) => t
sealed abstract class StSource[A] {
type S
def init: S
def emit(s: S): (A, S)
}
object StSource {
type Aux[S0, A] = StSource[A] { type S = S0 }
def apply[A, S0](i: S0)(f: S0 => (A, S0)): Aux[S0, A] =
new StSource[A] {