Working to sniff Bluetooth Low Energy with the adafruit sniffer
For more information, see this blog post
Going the python route, as described here
before installing pySerial, did ...
sealed trait EdnExpr { | |
def value : Expr | |
def mdata : Map[Expr,Expr] | |
override def equals(other : Any) = other match { | |
case that : EdnExpr => this.value == that.value | |
case _ => false | |
} | |
} | |
type Expr = Any | |
//-- | |
// Clojure's Transducers | |
// (the simpler parts) | |
//-- | |
// References: |
qsort [] = [] | |
qsort (n:xs) = qsort lt ++ [n] ++ qsort gteq where | |
lt = [x | x <- xs, x < n] | |
gteq = [x | x <- xs, x >= n] |
Working to sniff Bluetooth Low Energy with the adafruit sniffer
For more information, see this blog post
Going the python route, as described here
before installing pySerial, did ...
/** 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 |
object TransducerSpecs extends Specification with ScalaCheck { | |
import Process._ | |
import StreamUtils._ | |
"effectful stream transducers" should { | |
def id[I]: Transducer[Nothing, I, I] = | |
transducer.receive1[Nothing, I, I](emit).repeat | |
"perform a simple identity transformation" in prop { xs: List[List[Int]] => | |
val p = emitAll(xs map emitAll).toSource.join |
import spire.algebra._ | |
import spire.implicits._ | |
object Transducer { | |
type RF[R, A] = (R, A) => R | |
def apply[A, B](f: A => B) = | |
new Transducer[B, A] { | |
def apply[R](rf: RF[R, B]): RF[R, A] = (r, a) => rf(r, f(a)) | |
} |
case class Tree[A](root: A, forest: List[Tree[A]]) { | |
def map[B](f: A => B): Tree[B] = | |
coflatMap(t => f(t.copoint)) | |
// categorical dual to canonical "flatMap" | |
def coflatMap[B](f: Tree[A] => B): Tree[B] = { | |
import Tree.unfoldTree | |
unfoldTree(this, (a: Tree[A]) => (f(a), a.forest)) | |
} |
PROGRAMMING WITH EFFECTS | |
Graham Hutton, January 2015 | |
Shall we be pure or impure? | |
The functional programming community divides into two camps: | |
o "Pure" languages, such as Haskell, are based directly | |
upon the mathematical notion of a function as a | |
mapping from arguments to results. |
This is an example for computing running statistics with Lua backed by a hash in Redis. We support counting, average (with and without exponential smoothing), stddev, variance, min, max, sum of observed values. An example for approximating a running median can be found here: https://gist.github.com/thomasdarimont/fff68191d45a001b2d84
We use a hash
for storing various statistic value under the key "stats_value" in redis.
Note: If you need a specific alpha value for smoothing the average, then set the desired alpha -> e.g. alpha 0.7.
If alpha is 0.0 then no smoothing is applied.