val n = 9 | |
val s = Math.sqrt(n).toInt | |
type Board = IndexedSeq[IndexedSeq[Int]] | |
def solve(board: Board, cell: Int = 0): Option[Board] = (cell%n, cell/n) match { | |
case (r, `n`) => Some(board) | |
case (r, c) if board(r)(c) > 0 => solve(board, cell + 1) | |
case (r, c) => | |
def guess(x: Int) = solve(board.updated(r, board(r).updated(c, x)), cell + 1) | |
val used = board.indices.flatMap(i => Seq(board(r)(i), board(i)(c), board(s*(r/s) + i/s)(s*(c/s) + i%s))) |
Basic unit type:
λ> replTy "()"
() :: ()
Basic functions:
... or Why Pipelining Is Not That Easy
Golang Concurrency Patterns for brave and smart.
By @kachayev
- @fergbyrne
- HTM = Hierarchical Temporal Memory
- Slides
- big data is like teenage sex
- noone knows how to do it
- everyone thinks everyone else is doing it
# Simple: | |
# a --> b | |
# --> c --> d | |
# --> d | |
graph1 = { | |
"a": ["b", "c", "d"], | |
"b": [], | |
"c": ["d"], | |
"d": [] | |
} |
I've been working with Aleph rougly for last 5 years, actively contributing to the library for last 2 (or so). I also put some effort into spreading the word about it, including educational tech talks, like "Deep HTTP Dive Throught Aleph & Netty". But the more I talk to people the more confusion I find, mostly about how Aleph works and what can you expect when adding it to your stack. Clojurists Together has recently announced Aleph to get Q1 funding, I think it's a good time to share my priorities and thoughts on development plans that were mentioned in the blog post. Hope the community would find it interesting and helpful.
Aleph describes itself as "asynchronous communication for Clojure" library. And you should probably pay a good portion of your attention to the first word: "asynchronous".
Inspired by "Parsing CSS with Parsec".
Just quick notes and code that you can play with in REPL.
By @kachayev
## Alexey Kachayev, 2014 | |
## Link to slides: | |
## http://goo.gl/n4ylC4 | |
## Basic: | |
## type Parser = String -> Tree | |
## Composition | |
## type Parser = String -> (Tree, String) |