(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
#lang racket | |
;; 0CFA in the AAM style on some hairy Church numeral churning | |
;; Moral: per machine-state store polyvariance is not viable, | |
;; but with widening it's not so bad. | |
;; (X -> Set X) -> (Set X) -> (Set X) | |
(define ((appl f) s) | |
(for/fold ([i (set)]) |
# Author: Roman Sinayev | |
# License: BSD Style. | |
# Viterbi algorithm implementation and example written in Julia Language | |
# | |
# The idea is to decode the most probable order of a hidden markov model | |
# based on indirect observations. | |
# In the example below, we attempt to determine where a person is based on | |
# their cell phone service strength. We also have fake probabilities associated | |
# with each state(location) and with transitions between locations and with |
module HMM | |
using Distributions | |
import Distributions.rand | |
import Distributions.fit | |
immutable HiddenMarkovModel{TP, K} | |
theta::Vector{TP} | |
A::Matrix{Float64} |
import Control.Monad | |
import Data.Char | |
import qualified Data.List.Key as K | |
import System.Random | |
data Treap k a = Nil | Node Int k a (Treap k a) (Treap k a) | |
priority :: Treap k a -> Int | |
priority Nil = -1 | |
priority (Node p _ _ _ _) = p |
import Base: isempty, start, next, done, length, getindex, minimum, maximum, search, show | |
export Treap, TreapNode | |
type TreapNode{K} | |
priority::Float64 | |
size::Int | |
key::K | |
left::TreapNode{K} | |
right::TreapNode{K} |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
#lang racket | |
;; | |
;; These are some examples of different ways to compute factorials | |
;; using various paradigms and features provided by Racket. There | |
;; are more options available in packages which are not imported | |
;; by default, but that rabbit hole goes very deep indeed. | |
;; | |
;; Comments and suggestions welcome! | |
;; leo@lwh.jp |
#lang racket | |
(define eval [lambda (p ) (eval/s p '())]) | |
(define eval/s [lambda (p s) (eval/k p s (lambda (x) x))]) | |
(define eval/k | |
[lambda (p s k) | |
(cond {(eq? p '()) (k s)} | |
{(number? (car p)) (eval/k (cdr p) s [lambda (s) (k (cons (car p) s))])} | |
{(eq? (car p) 'dup) (eval/k (cdr p) s [lambda (s) (k (cons (car s) (cons (car s) (cdr s))))])} |
--- | |
title: On the Duality of Streams | |
subtitle: How Can Linear Types Help to Solve the Lazy IO Problem? | |
author: | |
- name: Jean-Philippe Bernardy | |
- name: Josef Svenningsson | |
... | |
<!-- |
;;- -*-scheme-*- | |
;;; rabbit compiler | |
;;- This is the source code to the RABBIT Scheme compiler, by Guy Steele, | |
;;- taken from the Indiana Scheme repository and annotated by me, Darius | |
;;- Bacon. I converted it from all-uppercase to all-lowercase and | |
;;- reindented it with Emacs for better readability. I've added the | |
;;- comments starting with either ;- or ;*. Other comments are by Steele. | |
;;- The ;- comments were things I'd figured out, while ;* denoted things | |
;;- for me to look into. (Sometimes I didn't bother to type in the answer |