I hereby claim:
- I am leonardoborges on github.
- I am leonardoborges (https://keybase.io/leonardoborges) on keybase.
- I have a public key whose fingerprint is CD7B F319 99AE 74FF 4D3B 86CD B71B 49D1 0F1B F2EE
To claim this, I am signing this object:
(setq hs-show-all-p t) | |
(defun hs-mode-toggle-show-all () | |
(interactive) | |
(if hs-show-all-p | |
(hs-hide-all) | |
(hs-show-all)) | |
(setq hs-show-all-p (not hs-show-all-p))) | |
(global-set-key (kbd "C-.") 'hs-toggle-hiding) | |
(global-set-key (kbd "C-c C-.") 'hs-mode-toggle-show-all) |
(async | |
(let [a (await (async-task-a)) | |
b (await (async-task-b)) | |
c (await (async-task-c (* a b)))] | |
(+ a b c))) | |
;; whish is equivalent to: | |
(async | |
(let [a (await (async-task-a)) |
case class Error(reason: String) | |
val eithers: List[\/[Error, String]] = List(\/-("Ok"), -\/(Error("notOk"))) | |
eithers.sequence | |
// error: could not find implicit value for parameter ev: scalaz.Leibniz.===[scalaz.\/[Error,String],G[B]] | |
eithers.sequence[({type λ[α] = \/[Error, α]})#λ, String] | |
// scalaz.\/[Error,List[String]] = -\/(Error(notOk)) | |
eithers.sequenceU |
-- From: http://tonymorris.github.io/blog/20-intermediate-haskell-exercises/ | |
-- which seems to be offline now | |
class Fluffy f where | |
furry :: (a -> b) -> f a -> f b | |
-- Exercise 1 | |
-- Relative Difficulty: 1 | |
instance Fluffy [] where | |
furry = error "todo" |
I hereby claim:
To claim this, I am signing this object:
;; Slides at: http://www.slideshare.net/borgesleonardo/monads-in-clojure | |
;; The list Monad | |
(def list-m { | |
:return (fn [v] (list v)) | |
:bind (fn [mv f] | |
(mapcat f mv)) | |
}) | |
(defn combinations [] |
;; This is short but in case of a failure, it's harder to pinpoint which bit is wrong. | |
(is (= (balance tree) | |
[:red | |
[:black | |
[:black nil "a" nil] | |
"x" | |
[:black nil "b" nil]] | |
"y" | |
[:black |
(require '[clojure.core.async :as async :refer :all]) | |
(defn fake-search [kind] | |
(fn [query] | |
(Thread/sleep (int (* (java.lang.Math/random) 1000))) | |
(str kind " result for " query))) | |
(def web (fake-search "Web")) | |
(def image (fake-search "Image")) | |
(def video (fake-search "Video")) |
threes = ["", "", "fizz"].cycle.lazy | |
fives = ["", "", "", "", "buzz"].cycle.lazy | |
(1..Float::INFINITY).lazy.zip(threes, fives).map{|n,f,b| | |
if f.empty? && b.empty? | |
return n | |
elsif f.empty? | |
return b | |
else | |
return [f,b].join |
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot) { | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
robot.rotateCannon(90); |