This is my recommended path for learning Haskell.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copyright (c) 2011 Josh Schreuder | |
# http://www.postteenageliving.com | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.annotation.tailrec | |
import math.abs | |
//Fixed point algorithm | |
object fpalgorithm { | |
val tolerance = 0.0001 | |
def fixedPoint(f: Double => Double)(firstGuess: Double) = { | |
def isCloseEnough(x: Double, y: Double) = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Rational(n: Int, d: Int) { | |
require(d != 0, "Denominator must be nonzero") | |
def this(n: Int) = this(n, 1) | |
private def gcd(a: Int, b: Int): Int = | |
if (b == 0) a else gcd(b, a % b) | |
private val g = gcd(n, d) | |
val numer = n / g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.NoSuchElementException | |
trait List[T] { | |
def isEmpty: Boolean | |
def head: T | |
def tail: List[T] | |
def length: Int | |
def atIndex(i: Int): T | |
def add(i: T): List[T] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object mergesort { | |
def msort[T](xs: List[T])(implicit ord: Ordering[T]): List[T] = { | |
val n = xs.length / 2 | |
if (n == 0) xs | |
else { | |
def merge(xs: List[T], ys: List[T]): List[T] = (xs, ys) match { | |
case (Nil, ys) => ys | |
case (xs, Nil) => xs | |
case (x :: xs1, y :: ys1) => | |
if (ord.lt(x, y)) x :: merge(xs1, ys) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Vundle | |
filetype off | |
set rtp+=~/.vim/bundle/vundle/ | |
call vundle#rc() | |
Bundle 'gmarik/vundle' | |
Bundle 'altercation/vim-colors-solarized' | |
Bundle 'Valloric/YouCompleteMe' | |
Bundle 'gerw/vim-latex-suite' | |
Bundle 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'} | |
Bundle 'scrooloose/nerdtree' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def continueWith[S](cont: Future[T] => S): Future[S] = { | |
val p: Promise[S] = Promise() | |
f.onComplete { | |
case Failure(f) => p.complete(Failure(f)) | |
case Success(v) => p.completeWith(Future(cont(f))) | |
} | |
return p.future |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%Datamatrix D: | |
D = [ -6.5 -6.5 -6.5 -6.5 -2.5 -2.5 -.75 -.75 3.25 3.25 4.5 4.5 6.5 6.5 6.5 6.5; ... | |
-2 -2 .5 .5 .5 .5 2 2 2 2 .5 .5 .5 .5 -2 -2; ... | |
-2.5 2.5 2.5 -2.5 -2.5 2.5 -2.5 2.5 -2.5 2.5 -2.5 2.5 -2.5 2.5 2.5 -2.5; ... | |
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1;... | |
]; | |
%Adjency matrix | |
A =[0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1;... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Binary.Put | |
import GHC.Word | |
data HeartBeat = HeartBeat { | |
typet :: Word8, | |
autopilot :: Word8, | |
basemode :: Word8, | |
custommode :: Word32, | |
systemstatus :: Word8, | |
version :: Word8 |
OlderNewer