(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.
{- Implementation of BST (binary search tree) | |
Script is absolutly free/libre, but with no guarantee. | |
Author: Ondrej Profant -} | |
import qualified Data.List | |
{- DEF data structure -} | |
data (Ord a, Eq a) => Tree a = Nil | Node (Tree a) a (Tree a) | |
deriving Show |
module Minimax (aimove) where | |
import Tree | |
-- Find value for max key from assoc list | |
maxkey :: (Ord k) => [(k, v)] -> v | |
maxkey = snd . foldl1 (\(k1,v1) (k2,v2) -> if k1 > k2 then (k1,v1) else (k2,v2)) | |
max' :: (Ord a) => [a] -> a | |
max' = foldl1 max |
module BinaryTree | |
where | |
-- Haskell Binary Tree Examples | |
-- A binary tree can either be empty or a node with a left and right branch | |
data Tree a = EmptyTree | Node a (Tree a) (Tree a) | |
deriving ( Show, Read, Eq ) |
import Data.Functor | |
import Data.Functor.Constant | |
import Data.Functor.Identity | |
import Data.Monoid | |
import Data.Traversable (Traversable(..)) | |
import Control.Comonad | |
import Control.Applicative (ZipList(..)) | |
class Cotraversable t where |
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. |
#!/bin/sh | |
# | |
# Setup a work space called `work` with two windows | |
# first window has 3 panes. | |
# The first pane set at 65%, split horizontally, set to api root and running vim | |
# pane 2 is split at 25% and running redis-server | |
# pane 3 is set to api root and bash prompt. | |
# note: `api` aliased to `cd ~/path/to/work` | |
# | |
session="work" |
(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.
{ config, pkgs, ... }: | |
let | |
hostname = "luz3"; | |
in { | |
imports = | |
[ # Include the results of the hardware scan. | |
./hardware-configuration.nix | |
# I use VirtualBox to connect to Windows and Linux guests |
{ config, pkgs, ... }: | |
{ | |
imports = | |
[ # Include the results of the hardware scan. | |
./hardware-configuration.nix | |
]; | |
boot = { | |
initrd.luks.devices = [ |
-- A tiny chat server to check I understand STM and threads. | |
-- To connect, run this program, then connect a few clients | |
-- using 'nc localhost 5252' in different terminals. Type a line + enter to send a message. | |
import Network | |
import System.IO | |
import Control.Concurrent | |
import GHC.Conc | |
import Control.Monad(forever) |