This file contains hidden or 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
<body> | |
<div id="chart"></div> | |
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script> | |
<pre id="table3" style="display:none"> | |
"Table 3: Estimated territorial greenhouse gas emissions by source category, UK 1990-2018" | |
Coverage: United Kingdom Million tonnes carbon dioxide equivalent (MtCO2e) | |
Sector More Detail 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 | |
Energy supply 278.0 275.6 264.2 246.4 237.6 238.0 238.6 222.7 225.6 212.6 221.6 231.4 228.8 234.7 232.4 231.5 235.9 230.4 223.6 200.4 207.4 192.7 203.3 190.1 165.2 145.3 121.8 112.3 104.9 | |
Power stations 204.2 200.8 188.7 171.2 167.0 163.9 163.6 150.9 156.1 147.9 159.4 170.3 165.9 175.1 174.7 174.0 182.9 178.7 173.6 151.8 158.1 145.4 159.4 148.4 125.2 105.0 83.0 73.1 66.8 | |
Refineries 17.9 18.6 19.1 20.0 19.5 20.2 20.7 20.5 20.0 18.1 17.3 17.1 19.3 18.7 18.4 19.9 18.0 17.8 17.3 16.5 |
This file contains hidden or 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
-- Read all about this program in the official Elm guide: | |
-- https://guide.elm-lang.org/architecture/user_input/forms.html | |
import Html exposing (..) | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (onInput, onClick) | |
main = | |
Html.beginnerProgram |
This file contains hidden or 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 React from 'react' | |
import ReactDOM from 'react-dom' | |
class App extends Component { | |
getInitialState(){ | |
return {data: ''} | |
} | |
componentWillMount(){ | |
this.props.dataPromise.then(data => this.setState({data})) | |
} |
This file contains hidden or 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
const Reader = { | |
of: a => { return _ => a }, | |
map: f => run => { | |
return x => f(run(x)) | |
}, | |
contramap: f => run => { | |
return x => run(f(x)) | |
}, | |
chain: f => run => { | |
return x => f(run(x))(x) |
This file contains hidden or 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
const Task = fork => ({ | |
map: f => Task((reject, resolve)=>{ fork(reject, x => { resolve(f(x)) }) }), | |
chain: f => Task((reject, resolve)=>{ fork(reject, x => { f(x).fork(reject, resolve) }) }), | |
join: () => Task(fork).chain(i=>i), | |
ap: A => A.map(a => Task(fork).map(f => f(a))).join(), | |
fork | |
}) | |
Task.of = x => Task((_,resolve)=>{ resolve(x)}) |
This file contains hidden or 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
const Pattern = testers => transformers => val => { | |
const match = Object.keys(testers).find(k => testers[k](val)) | |
return transformers[match](val) | |
} | |
const Num = Pattern({ | |
Odd: n => n % 2, | |
Even: n => !(n % 2) | |
}) |
This file contains hidden or 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
const gameIsWon = ({word, correctGuesses, wrongGuesses}) => wordIsGuessed(word, correctGuesses) | |
const gameIsLost = ({word, correctGuesses, wrongGuesses}) => listGTE10(wrongGuesses) | |
const wordIsGuessed = (word, guesses) => word.split('').every(c => guesses.includes(c)) | |
const letterInWord = (letter, word) => word.split('').includes(letter) | |
const listGTE10 = (list) => Array.isArray(list) && list.length >= 10 | |
function playHangman({word, correctGuesses, wrongGuesses}){ | |
const letter = prompt('Guess a letter') | |
const goodGuess = letterInWord(letter, word) | |
const gameState = goodGuess? {word, correctGuesses: [letter, ...correctGuesses], wrongGuesses } : {word, correctGuesses, wrongGuesses: [letter, ...wrongGuesses]} |
This file contains hidden or 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
const branchLetter = ({full, sub},letter) => { | |
sub[letter] = sub[letter] || {} | |
return {full, sub: sub[letter] } | |
} | |
const indexWord = (trie, word) => { | |
const {full, sub} = word.split('').reduce(branchLetter, {full:trie, sub: trie}) | |
return full | |
} |
This file contains hidden or 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
Diff = (before, changes) => { return { | |
map: f => { | |
const after = f(before) | |
const newChanges = diff(before, after) | |
return Diff(after, [...changes, ...newChanges]) | |
} | |
}} |
NewerOlder