Skip to content

Instantly share code, notes, and snippets.

--myApply :: (Num a0) => (a0 -> a0 -> a0) -> [a0] -> a0
--myApply func list
-- = func (head list) value
--where value =
data Fraction = Fraction { numerator :: Int
,denominator :: Int } deriving (Eq)
addFractions :: Fraction -> Fraction -> Fraction
--myApply :: (Num a0) => (a0 -> a0 -> a0) -> [a0] -> a0
--myApply func list
-- = func (head list) value
--where value =
data Fraction = Fraction { numerator :: Int
,denominator :: Int } deriving (Show, Eq)
addFractions :: Fraction -> Fraction -> Fraction
--myApply :: (Num a0) => (a0 -> a0 -> a0) -> [a0] -> a0
--myApply func list
-- = func (head list) value
--where value =
data Fraction = Fraction { numerator :: Int
,denominator :: Int } deriving (Show, Eq)
addFractions :: Fraction -> Fraction -> Fraction
import std.stdio, std.string;
uint factorial(uint number) {
uint product = number;
foreach (multiplicand; 2..number) {
product *= multiplicand;
}
return product;
}
void swap(T)(ref T a, ref T b)
import std.stdio, std.string;
uint factorial(uint number) {
uint product = number;
foreach (multiplicand; 2..number) {
product *= multiplicand;
}
return product;
}
void swap(T)(ref T a, ref T b)
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
"Bundle 'gmarik/vundle'
" colorsupport placed at the top because it takes the first of rtp and uses it to cache, apparently another plugin somewhere in here is messing with it
Bundle 'colorsupport.vim'
module BinaryTree where
import Data.Maybe(fromJust)
data Tree a = Leaf a | Node a (Tree a) (Tree a) deriving (Show, Eq)
isNode (Node _ _ _) = True
isNode _ = False
isLeaf (Leaf _) = True
isLeaf _ = False
module BinaryTree where
import Data.Maybe(fromJust)
data Tree a = Leaf a | Node a (Tree a) (Tree a) deriving (Show, Eq)
isNode (Node _ _ _) = True
isNode _ = False
isLeaf (Leaf _) = True
isLeaf _ = False
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
"Bundle 'gmarik/vundle'
" colorsupport placed at the top because it takes the first of rtp and uses it to cache, apparently another plugin somewhere in here is messing with it
Bundle 'colorsupport.vim'
Bundle 'godlygeek/tabular'
module Sudoku( SudokuCell, SudokuGroup ) where
data SudokuCell = SudokuCell { cellRow :: Int, cellColumn :: Int, cellValue :: Int } deriving (Show)
instance Eq SudokuCell where
(SudokuCell _ _ xval) == (SudokuCell _ _ yval) = xval == yval
data SudokuGroup = SudokuGroup { groupCells :: [[SudokuCell]] } deriving Show
data SudokuTable = SudokuTable { tableGroups :: [[SudokuGroup]] } deriving Show
--sudokuGroupGetCell :: SudokuGroup -> Int -> Int -> SudokuCell
--sudokuGroupGetCell group row column = if (length cells == 0) then -1 else ((cells !! row) !! column)