/doc/report/app_code.tex
LaTeX | 50 lines | 47 code | 3 blank | 0 comment | 0 complexity | 1fba2c9394934ac918a7b365426a3a88 MD5 | raw file
1\chapter{Code} 2 3\section{OCaml} 4\subsection{froc-list.ml} 5\label{app:froc-list} 6\begin{alltt} 7class ['a] flist = 8object (self) 9 val mutable first = [] 10 val mutable last = [] 11 val mutable fs = [] 12 method lift (f : 'a -> unit) = 13 begin 14 let l o = ignore (Froc.lift f o) in 15 fs <- f :: fs; 16 List.iter l first; 17 List.iter l (List.rev last) 18 end 19 method lift_all o = 20 begin 21 let l f = ignore (Froc.lift f o) in 22 List.iter l fs 23 end 24 method list = List.rev_append (List.rev first) (List.rev last) 25 method push o = self#lift_all o; first <- o :: first 26 method push_end o = self#lift_all o; last <- o :: last 27 method pop = let hd = List.hd first in first <- List.tl first; hd 28 method pop_end = let hd = List.hd last in last <- List.tl last; hd 29end 30\end{alltt} 31\section{JavaScript} 32 33\section{Shell} 34\subsection{get-world-bank-data.sh} 35\label{app:data} 36\begin{alltt} 37#!/bin/sh 38if [ "\$1" = "gdp" ] 39then 40 OUT="gdp" 41 URL="http://api.worldbank.org/countries/all/indicators/NY.GDP.MKTP.CD" 42else 43 OUT="life" 44 URL="http://api.worldbank.org/countries/all/indicators/SP.DYN.LE00.IN" 45fi 46 47for n in \$(seq 1 245) 48 do wget -O \${OUT}-\${n}.json \${URL}?format=json\&per_page=50\&page=\${n} && sleep 5 49done 50\end{alltt}