Some Q code
fib: {[n]
$[n<2; n; fib[n-1]+fib[n-2]]
}
module FieldExtension where | |
{- | |
This module lets you define the exact Fibonacci function using the mathematically | |
elegant definition in terms of phi = (1 + sqrt 5) / 2, without losing precision | |
due to calculations being carried out in floating point. | |
phi :: Q5 | |
phi = 0.5 :+ 0.5 |
# -*- coding: utf-8 -*- | |
import re | |
import sys | |
import locale | |
from bs4 import BeautifulSoup | |
from urllib2 import urlopen | |
%% Read in files and extrapolate mortality rate | |
x = csv.read('life.csv','format', '%f %f'); | |
age = x{1}; | |
prob = x{2}; | |
model = stats.lm(log(prob(61:end)), log(age(61:100))); | |
pfun = @(a) util.if_(a<60, @()prob(a), util.if_(a>121, 1, exp(model.beta(1) + model.beta(2) * log(a)))); |
## Output of brew --config | |
crntaylor:opencv crntaylor$ brew --config | |
HOMEBREW_VERSION: 0.9.4 | |
ORIGIN: https://github.com/mxcl/homebrew | |
HEAD: 7be8b458f96da9d37d009c1a96888419f646c7cf | |
HOMEBREW_PREFIX: /usr/local | |
HOMEBREW_CELLAR: /usr/local/Cellar | |
CPU: quad-core 64-bit sandybridge | |
OS X: 10.7.5-x86_64 |
function code = mcode(x) | |
% MCODE Returns a char array containing Matlab code that evaluates to the | |
% object x. That is, the two quantities | |
% | |
% >> x | |
% >> eval(mcode(x)) | |
% | |
% should be identical. | |
% |
function search(query,path) | |
% Download full size images from Google image search. Saves image files | |
% locally. Do not print or republish images without permission. | |
% | |
% Based on Python code by Craig Quiter at https://gist.github.com/crizCraig/2816295 | |
% | |
% Requires the JSONLab package, available from | |
% http://www.mathworks.com/matlabcentral/fileexchange/33381-jsonlab-a-toolbox-to-encodedecode-json-files-in-matlaboctave | |
% | |
% USAGE |
Given a class representing covariant functors between categories | |
> import Control.Category | |
> class (Category hom, Category hom') => Covariant f hom hom' where | |
> cmap :: hom a b -> hom' (f a) (f b) | |
and a class for adjunctions | |
> class (Covariant f hom hom', Covariant g hom' hom) => Adjunction f g hom hom' where |
{-# LANGUAGE NoImplicitPrelude | |
, MultiParamTypeClasses | |
, FlexibleInstances | |
, FunctionalDependencies | |
, UndecidableInstances #-} | |
import Prelude hiding (id, (.)) | |
import qualified Prelude |
{-# LANGUAGE FlexibleContexts, UndecidableInstances, RankNTypes, ConstraintKinds #-} | |
module ADT where | |
------------ | |
-- Part 1 -- | |
------------ | |
-- The unit type '1', equivalent to '()' |